aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2014-03-20 12:25:34 +1300
committerWilliam Hua <william.hua@canonical.com>2014-03-20 12:25:34 +1300
commita08ab0c4f8f80366eb7c08795e9d5407aef8ecff (patch)
treee9fcc6ec33592e9408bdd8a1b62090251bf81489
parentbe945fee7825c4852f558d6e2e77a196c184f9c5 (diff)
downloadayatana-indicator-keyboard-a08ab0c4f8f80366eb7c08795e9d5407aef8ecff.tar.gz
ayatana-indicator-keyboard-a08ab0c4f8f80366eb7c08795e9d5407aef8ecff.tar.bz2
ayatana-indicator-keyboard-a08ab0c4f8f80366eb7c08795e9d5407aef8ecff.zip
IBus panel is only available while IBus is running.
-rw-r--r--lib/main.vala82
-rw-r--r--po/indicator-keyboard.pot10
2 files changed, 53 insertions, 39 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 9e74ee84..55c46b02 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -38,6 +38,7 @@ public class Indicator.Keyboard.Service : Object {
private IBus.Bus? ibus;
private IBusPanel? ibus_panel;
+ private ulong ibus_connected_id;
private uint panel_timeout;
private Source[]? sources;
@@ -132,6 +133,43 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private IBusPanel? get_ibus_panel () {
+ if (ibus_panel == null && get_ibus ().is_connected ()) {
+ var connection = get_ibus ().get_connection ();
+ var name = "org.freedesktop.IBus.Panel";
+ var path = "/org/freedesktop/IBus/Panel";
+
+ try {
+ ibus_panel = connection.get_proxy_sync (name, path);
+
+ ((!) ibus_panel).properties_registered.connect ((variant) => {
+ var properties = new IBus.PropList ();
+ properties.deserialize (variant);
+
+ if (properties is IBus.PropList) {
+ handle_properties_registered ((!) (properties as IBus.PropList));
+ }
+ });
+ ((!) ibus_panel).property_updated.connect ((variant) => {
+ var type = IBus.PropType.NORMAL;
+ var state = IBus.PropState.INCONSISTENT;
+ var text = new IBus.Text.from_static_string ("");
+ var property = new IBus.Property ("", type, text, null, text, false, false, state, null);
+ property.deserialize (variant);
+
+ if (property is IBus.Property) {
+ handle_property_updated ((!) (property as IBus.Property));
+ }
+ });
+ } catch (IOError error) {
+ warning ("error: %s", error.message);
+ }
+ }
+
+ return ibus_panel;
+ }
+
+ [DBus (visible = false)]
public void up () {
if (loop == null) {
loop = new MainLoop ();
@@ -576,38 +614,12 @@ public class Indicator.Keyboard.Service : Object {
}
}
- if (ibus_panel == null && sources[i].is_ibus) {
- DBusConnection? connection = get_ibus ().get_connection ();
-
- if (connection != null) {
- var name = "org.freedesktop.IBus.Panel";
- var path = "/org/freedesktop/IBus/Panel";
-
- try {
- ibus_panel = ((!) connection).get_proxy_sync (name, path);
-
- ((!) ibus_panel).properties_registered.connect ((variant) => {
- var properties = new IBus.PropList ();
- properties.deserialize (variant);
-
- if (properties is IBus.PropList) {
- handle_properties_registered ((!) (properties as IBus.PropList));
- }
- });
- ((!) ibus_panel).property_updated.connect ((variant) => {
- var type = IBus.PropType.NORMAL;
- var state = IBus.PropState.INCONSISTENT;
- var text = new IBus.Text.from_static_string ("");
- var property = new IBus.Property ("", type, text, null, text, false, false, state, null);
- property.deserialize (variant);
-
- if (property is IBus.Property) {
- handle_property_updated ((!) (property as IBus.Property));
- }
- });
- } catch (IOError error) {
- warning ("error: %s", error.message);
- }
+ if (ibus_connected_id == 0 && sources[i].is_ibus) {
+ ibus_connected_id = get_ibus ().connected.connect (() => { get_ibus_panel (); });
+ get_ibus ().disconnected.connect (() => { ibus_panel = null; });
+
+ if (get_ibus ().is_connected ()) {
+ get_ibus_panel ();
}
}
}
@@ -774,9 +786,11 @@ public class Indicator.Keyboard.Service : Object {
if (ibus_menu == null) {
ibus_menu = new IBusMenu (get_action_group ());
((!) ibus_menu).activate.connect ((property, state) => {
- if (ibus_panel != null) {
+ var panel = get_ibus_panel ();
+
+ if (panel != null) {
try {
- ((!) ibus_panel).activate_property (property.key, state);
+ ((!) panel).activate_property (property.key, state);
} catch (IOError error) {
warning ("error: %s", error.message);
}
diff --git a/po/indicator-keyboard.pot b/po/indicator-keyboard.pot
index 090c84a3..5647f938 100644
--- a/po/indicator-keyboard.pot
+++ b/po/indicator-keyboard.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-03-19 18:04+1300\n"
+"POT-Creation-Date: 2014-03-20 12:25+1300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,19 +17,19 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../lib/main.vala:655
+#: ../lib/main.vala:667
#, c-format
msgid "%s input source"
msgstr ""
-#: ../lib/main.vala:801
+#: ../lib/main.vala:815
msgid "Character Map"
msgstr ""
-#: ../lib/main.vala:802
+#: ../lib/main.vala:816
msgid "Keyboard Layout Chart"
msgstr ""
-#: ../lib/main.vala:803
+#: ../lib/main.vala:817
msgid "Text Entry Settings..."
msgstr ""