Dynamically detect when running under Unity: Bug #737258

This removes the --enable-unity ./configure flag in favor of detecting
the UI shell at runtime.
This commit is contained in:
Jim Nelson 2014-11-14 13:55:05 -08:00
parent 9cb7e6bd13
commit cbb21b2f9e
7 changed files with 28 additions and 39 deletions

6
configure vendored
View file

@ -24,8 +24,6 @@ configure_help() {
--disable-fatal-warnings
Disable Vala fatal warnings when compiling.
--enable-unity
Enable Unity interface changes.
--enable-ref-tracking
Enable reference tracking which is dumped to stdout when the program exits.
--disable-schemas-compile
@ -96,10 +94,6 @@ do
CMDLINE="${CMDLINE} -DREF_TRACKING=ON"
;;
--enable-unity)
CMDLINE="${CMDLINE} -DENABLE_UNITY=ON"
;;
--disable-schemas-compile)
CMDLINE="${CMDLINE} -DGSETTINGS_COMPILE=OFF"
CMDLINE="${CMDLINE} -DGSETTINGS_COMPILE_IN_PLACE=OFF"

2
debian/rules vendored
View file

@ -13,7 +13,7 @@
dh $@ --parallel
override_dh_auto_configure:
./configure --prefix=/usr --enable-unity
./configure --prefix=/usr
override_dh_strip:
dh_strip --dbg-package=geary-dbg

View file

@ -583,16 +583,6 @@ else ()
message(STATUS "Reference tracking: OFF")
endif ()
if (ENABLE_UNITY)
message(STATUS "Unity interface changes: ON")
set(EXTRA_VALA_OPTIONS
${EXTRA_VALA_OPTIONS}
--define=ENABLE_UNITY
)
else ()
message(STATUS "Unity interface changes: OFF")
endif ()
if (DISABLE_POODLE)
message(STATUS "POODLE SSLv3 fix: OFF")
set(EXTRA_VALA_OPTIONS

View file

@ -80,6 +80,11 @@ public class GearyApplication : Gtk.Application {
public Configuration config { get; private set; }
/**
* Indicates application is running under Ubuntu's Unity shell.
*/
public bool is_running_unity { get; private set; }
private static GearyApplication _instance = null;
private string bin;
@ -92,6 +97,8 @@ public class GearyApplication : Gtk.Application {
Object(application_id: APP_ID);
_instance = this;
is_running_unity = Geary.String.stri_equal(Environment.get_variable("XDG_CURRENT_DESKTOP"), "Unity");
}
// Application.run() calls this as an entry point.

View file

@ -78,10 +78,10 @@ public class MainWindow : Gtk.ApplicationWindow {
// Toolbar.
main_toolbar = new MainToolbar();
#if !ENABLE_UNITY
main_toolbar.show_close_button = true;
set_titlebar(main_toolbar);
#endif
if (!GearyApplication.instance.is_running_unity) {
main_toolbar.show_close_button = true;
set_titlebar(main_toolbar);
}
set_styling();
create_layout();
@ -218,9 +218,9 @@ public class MainWindow : Gtk.ApplicationWindow {
folder_paned.pack1(status_bar_box, false, false);
folder_paned.pack2(conversations_paned, true, false);
#if ENABLE_UNITY
main_layout.pack_start(main_toolbar, false, true, 0);
#endif
if (GearyApplication.instance.is_running_unity)
main_layout.pack_start(main_toolbar, false, true, 0);
main_layout.pack_end(folder_paned, true, true, 0);
add(main_layout);

View file

@ -56,10 +56,9 @@ public interface PillBar : Gtk.Container {
}
// Unity buttons are a bit tight
#if ENABLE_UNITY
if (b.image != null)
if (GearyApplication.instance.is_running_unity && b.image != null)
b.image.margin = b.image.margin + 4;
#endif
b.always_show_image = true;
if (!show_label)

View file

@ -16,21 +16,20 @@ public class ComposerWindow : Gtk.Window, ComposerContainer {
add(composer);
composer.subject_entry.changed.connect(() => {
#if ENABLE_UNITY
title
#else
composer.header.title
#endif
= Geary.String.is_empty(composer.subject_entry.text.strip()) ? DEFAULT_TITLE :
composer.subject_entry.text.strip();
string new_title = Geary.String.is_empty_or_whitespace(composer.subject_entry.text)
? DEFAULT_TITLE : composer.subject_entry.text.strip();
if (GearyApplication.instance.is_running_unity)
title = new_title;
else
composer.header.title = new_title;
});
composer.subject_entry.changed();
#if !ENABLE_UNITY
composer.header.show_close_button = true;
composer.header.parent.remove(composer.header);
set_titlebar(composer.header);
#endif
if (!GearyApplication.instance.is_running_unity) {
composer.header.show_close_button = true;
composer.header.parent.remove(composer.header);
set_titlebar(composer.header);
}
add_accel_group(composer.ui.get_accel_group());
show();