From 8800a05d7dbdfb8ba5c6ce40fba69cad7a885920 Mon Sep 17 00:00:00 2001 From: William Hua Date: Fri, 13 Jun 2014 14:13:25 -0400 Subject: Pick IBus or Fcitx. --- lib/indicator-menu.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index 8e5661e2..115adc5f 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -22,7 +22,8 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { NONE = 0x0, DCONF = 0x1, IBUS = 0x2, - SETTINGS = 0x4 + FCITX = 0x4, + SETTINGS = 0x8 } private Options options; @@ -76,7 +77,9 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { sources_section.remove_all (); for (var i = 0; i < sources.length; i++) { - if (!sources[i].is_ibus || (options & Options.IBUS) != Options.NONE) { + if (sources[i].is_xkb || + (sources[i].is_ibus && (options & Options.IBUS) != Options.NONE) || + (sources[i].is_fcitx && (options & Options.FCITX) != Options.NONE)) { string action; if ((options & Options.DCONF) != Options.NONE) { -- cgit v1.2.3 From cd8ecdbcb0d936b6e6ef2b9bdf4253162299cfd4 Mon Sep 17 00:00:00 2001 From: William Hua Date: Mon, 15 Sep 2014 12:04:59 -0400 Subject: Hide indicator menu in desktop session when Fcitx is active. --- lib/indicator-menu.vala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index 115adc5f..a4587dd8 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -19,11 +19,12 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { public enum Options { - NONE = 0x0, - DCONF = 0x1, - IBUS = 0x2, - FCITX = 0x4, - SETTINGS = 0x8 + NONE = 0x00, + DCONF = 0x01, + XKB = 0x02, + IBUS = 0x04, + FCITX = 0x08, + SETTINGS = 0x10 } private Options options; @@ -77,9 +78,11 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { sources_section.remove_all (); for (var i = 0; i < sources.length; i++) { - if (sources[i].is_xkb || - (sources[i].is_ibus && (options & Options.IBUS) != Options.NONE) || - (sources[i].is_fcitx && (options & Options.FCITX) != Options.NONE)) { + var visible = (sources[i].is_xkb && (options & Options.XKB) != Options.NONE) || + (sources[i].is_ibus && (options & Options.IBUS) != Options.NONE) || + (sources[i].is_fcitx && (options & Options.FCITX) != Options.NONE); + + if (visible) { string action; if ((options & Options.DCONF) != Options.NONE) { -- cgit v1.2.3 From 9ec7c8f8f1d7ecb050764011114e568f558582e8 Mon Sep 17 00:00:00 2001 From: William Hua Date: Mon, 15 Sep 2014 12:22:22 -0400 Subject: Hide indicator when menu is empty. --- lib/indicator-menu.vala | 61 ++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'lib/indicator-menu.vala') 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); -- cgit v1.2.3 From 548bcac9f532e4ee29d2f10a0f1a1cdd66069d5f Mon Sep 17 00:00:00 2001 From: William Hua Date: Thu, 12 Feb 2015 10:25:28 -0500 Subject: Fix type signature of GLib.MenuModel.get_item_links (). --- lib/indicator-menu.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index 209fcbf1..77d4512e 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -131,7 +131,7 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { indicator_menu.get_item_attributes (item_index, out attributes); } - public override void get_item_links (int item_index, out HashTable? links) { + public override void get_item_links (int item_index, out HashTable links) { indicator_menu.get_item_links (item_index, out links); } -- cgit v1.2.3 From b3c420d16aae3374cca092e22cee1316716a91bb Mon Sep 17 00:00:00 2001 From: William Hua Date: Tue, 17 Feb 2015 15:40:38 -0500 Subject: Use shift operator. --- lib/indicator-menu.vala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index 77d4512e..ebc92024 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -19,12 +19,12 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { public enum Options { - NONE = 0x00, - DCONF = 0x01, - XKB = 0x02, - IBUS = 0x04, - FCITX = 0x08, - SETTINGS = 0x10 + NONE = 0, + DCONF = 1 << 0, + XKB = 1 << 1, + IBUS = 1 << 2, + FCITX = 1 << 3, + SETTINGS = 1 << 4 } private Options options; -- cgit v1.2.3 From c38ced78666aad06e32d5c5937b99c91b36e8729 Mon Sep 17 00:00:00 2001 From: William Hua Date: Tue, 17 Feb 2015 16:11:45 -0500 Subject: Check flags better. --- lib/indicator-menu.vala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index ebc92024..72441546 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -44,13 +44,13 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { submenu.append_section (null, sources_section); - if ((options & Options.IBUS) != Options.NONE) { + if (Options.IBUS in options) { properties_section = new IBusMenu (action_map); properties_section.activate.connect ((property, state) => { activate (property, state); }); submenu.append_section (null, properties_section); } - if ((options & Options.SETTINGS) != Options.NONE) { + if (Options.SETTINGS in options) { var settings_section = new Menu (); settings_section.append (_ ("Character Map"), "indicator.map"); settings_section.append (_ ("Keyboard Layout Chart"), "indicator.chart"); @@ -63,7 +63,7 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { 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) { + if (Options.DCONF in options) { indicator.set_attribute ("x-canonical-secondary-action", "s", "indicator.next"); indicator.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll"); } else { @@ -81,14 +81,14 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { sources_section.remove_all (); for (var i = 0; i < sources.length; i++) { - var visible = (sources[i].is_xkb && (options & Options.XKB) != Options.NONE) || - (sources[i].is_ibus && (options & Options.IBUS) != Options.NONE) || - (sources[i].is_fcitx && (options & Options.FCITX) != Options.NONE); + var visible = (sources[i].is_xkb && Options.XKB in options) || + (sources[i].is_ibus && Options.IBUS in options) || + (sources[i].is_fcitx && Options.FCITX in options); if (visible) { string action; - if ((options & Options.DCONF) != Options.NONE) { + if (Options.DCONF in options) { action = "indicator.current"; } else { action = "indicator.active"; @@ -108,13 +108,13 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { } public void set_properties (IBus.PropList properties) { - if ((options & Options.IBUS) != Options.NONE) { + if (Options.IBUS in options) { properties_section.set_properties (properties); } } public void update_property (IBus.Property property) { - if ((options & Options.IBUS) != Options.NONE) { + if (Options.IBUS in options) { properties_section.update_property (property); } } -- cgit v1.2.3 From c9a8ec0018435a4ccb0a1d700a77303939e87d54 Mon Sep 17 00:00:00 2001 From: William Hua Date: Wed, 18 Feb 2015 12:49:19 -0500 Subject: Remove unnecessary flag. We don't really need this flag any more since we decided to hide indicator-keyboard in the session when Fcitx is running since it has its own indicator. --- lib/indicator-menu.vala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/indicator-menu.vala') diff --git a/lib/indicator-menu.vala b/lib/indicator-menu.vala index 72441546..96bf64d6 100644 --- a/lib/indicator-menu.vala +++ b/lib/indicator-menu.vala @@ -23,8 +23,7 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { DCONF = 1 << 0, XKB = 1 << 1, IBUS = 1 << 2, - FCITX = 1 << 3, - SETTINGS = 1 << 4 + SETTINGS = 1 << 3 } private Options options; @@ -82,8 +81,7 @@ public class Indicator.Keyboard.IndicatorMenu : MenuModel { for (var i = 0; i < sources.length; i++) { var visible = (sources[i].is_xkb && Options.XKB in options) || - (sources[i].is_ibus && Options.IBUS in options) || - (sources[i].is_fcitx && Options.FCITX in options); + (sources[i].is_ibus && Options.IBUS in options); if (visible) { string action; -- cgit v1.2.3