aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2014-09-15 12:22:22 -0400
committerWilliam Hua <william.hua@canonical.com>2014-09-15 12:22:22 -0400
commit9ec7c8f8f1d7ecb050764011114e568f558582e8 (patch)
treedbe4ae0fbdb7f012249976753a7bd5b21cb840ec
parentcd8ecdbcb0d936b6e6ef2b9bdf4253162299cfd4 (diff)
downloadayatana-indicator-keyboard-9ec7c8f8f1d7ecb050764011114e568f558582e8.tar.gz
ayatana-indicator-keyboard-9ec7c8f8f1d7ecb050764011114e568f558582e8.tar.bz2
ayatana-indicator-keyboard-9ec7c8f8f1d7ecb050764011114e568f558582e8.zip
Hide indicator when menu is empty.
-rw-r--r--lib/indicator-menu.vala61
1 files changed, 32 insertions, 29 deletions
diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala
index a4587dd8..209fcbf1 100644
--- a/lib/indicator-menu.vala
+++ b/lib/indicator-menu.vala
@@ -34,42 +34,45 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel {
private IBusMenu properties_section;
public IndicatorMenu (ActionMap? action_map = null, Options options = Options.NONE) {
- var submenu = new Menu ();
+ this.options = options;
+ indicator_menu = new Menu ();
sources_section = new Menu ();
- submenu.append_section (null, sources_section);
- if ((options & Options.IBUS) != Options.NONE) {
- properties_section = new IBusMenu (action_map);
- properties_section.activate.connect ((property, state) => { activate (property, state); });
- submenu.append_section (null, properties_section);
- }
+ if ((options & ~Options.DCONF) != Options.NONE) {
+ var submenu = new Menu ();
- if ((options & Options.SETTINGS) != Options.NONE) {
- var settings_section = new Menu ();
- settings_section.append (_ ("Character Map"), "indicator.map");
- settings_section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
- settings_section.append (_ ("Text Entry Settings..."), "indicator.settings");
- submenu.append_section (null, settings_section);
- }
+ submenu.append_section (null, sources_section);
- var indicator = new MenuItem.submenu (null, submenu);
- indicator.set_detailed_action ("indicator.indicator");
- indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
-
- /* We need special mouse actions on the lock screen. */
- if ((options & Options.DCONF) != Options.NONE) {
- indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next");
- indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll");
- } else {
- indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.locked_next");
- indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.locked_scroll");
- }
+ if ((options & Options.IBUS) != Options.NONE) {
+ properties_section = new IBusMenu (action_map);
+ properties_section.activate.connect ((property, state) => { activate (property, state); });
+ submenu.append_section (null, properties_section);
+ }
- indicator_menu = new Menu ();
- indicator_menu.append_item (indicator);
+ if ((options & Options.SETTINGS) != Options.NONE) {
+ var settings_section = new Menu ();
+ settings_section.append (_ ("Character Map"), "indicator.map");
+ settings_section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
+ settings_section.append (_ ("Text Entry Settings..."), "indicator.settings");
+ submenu.append_section (null, settings_section);
+ }
- this.options = options;
+ var indicator = new MenuItem.submenu (null, submenu);
+ indicator.set_detailed_action ("indicator.indicator");
+ indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
+
+ /* We need special mouse actions on the lock screen. */
+ if ((options & Options.DCONF) != Options.NONE) {
+ indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next");
+ indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll");
+ } else {
+ indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.locked_next");
+ indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.locked_scroll");
+ }
+
+ indicator_menu.append_item (indicator);
+ }
}
public signal void activate (IBus.Property property, IBus.PropState state);