aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore4
-rw-r--r--debian/control1
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/ibus-panel.vala26
-rw-r--r--lib/main.vala65
-rw-r--r--po/indicator-keyboard.pot4
6 files changed, 88 insertions, 13 deletions
diff --git a/.bzrignore b/.bzrignore
index 8c441a49..d1af5121 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -29,6 +29,8 @@ libtool
po/POTFILES
po/stamp-it
tests/config.vala
+tests/dconf-service
+tests/gvfs
tests/indicator-keyboard-test
tests/indicator-keyboard-test.trs
tests/indicator-keyboard-tests
@@ -39,4 +41,4 @@ m4/libtool.m4
m4/lt~obsolete.m4
m4/ltoptions.m4
m4/ltsugar.m4
-m4/ltversion.m4 \ No newline at end of file
+m4/ltversion.m4
diff --git a/debian/control b/debian/control
index 4148227e..585af9c5 100644
--- a/debian/control
+++ b/debian/control
@@ -30,6 +30,7 @@ Package: indicator-keyboard
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends},
+Breaks: ibus (<< 1.5.5-1ubuntu3),
Description: Keyboard indicator
This package contains the keyboard indicator, which should show as an icon in
the top panel when using the Unity environment. It can be used to switch
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 89d8464f..9abf5ada 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -10,6 +10,7 @@ indicator_keyboard_service_SOURCES = main.vala \
source.vala \
common.vala \
ibus-menu.vala \
+ ibus-panel.vala \
indicator-menu.vala \
window-stack.vala \
unity-greeter.vala
diff --git a/lib/ibus-panel.vala b/lib/ibus-panel.vala
new file mode 100644
index 00000000..460b1eac
--- /dev/null
+++ b/lib/ibus-panel.vala
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: William Hua <william.hua@canonical.com>
+ */
+
+[DBus (name="com.canonical.IBus.Panel.Private")]
+public interface IBusPanel : Object {
+
+ public abstract void activate_property (string name, uint state) throws IOError;
+
+ public signal void properties_registered (Variant variant);
+ public signal void property_updated (Variant variant);
+}
diff --git a/lib/main.vala b/lib/main.vala
index 473c52d1..8d8c213f 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -37,7 +37,8 @@ public class Indicator.Keyboard.Service : Object {
private uint focused_window_id;
private IBus.Bus? ibus;
- private IBus.PanelService? panel_service;
+ private IBusPanel? ibus_panel;
+ private ulong ibus_connected_id;
private uint panel_timeout;
private Source[]? sources;
@@ -135,6 +136,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 ();
@@ -579,11 +617,12 @@ public class Indicator.Keyboard.Service : Object {
}
}
- if (panel_service == null && sources[i].is_ibus) {
- if (get_ibus ().request_name (IBus.SERVICE_PANEL, IBus.BusNameFlag.REPLACE_EXISTING) > 0) {
- panel_service = new IBus.PanelService (get_ibus ().get_connection ());
- ((!) panel_service).register_properties.connect (handle_registered_properties);
- ((!) panel_service).update_property.connect (handle_updated_property);
+ 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 ();
}
}
}
@@ -593,7 +632,7 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
- private void handle_registered_properties (IBus.PropList list) {
+ private void handle_properties_registered (IBus.PropList list) {
if (panel_timeout > 0) {
GLib.Source.remove (panel_timeout);
panel_timeout = 0;
@@ -607,7 +646,7 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
- private void handle_updated_property (IBus.Property property) {
+ private void handle_property_updated (IBus.Property property) {
get_desktop_menu ().update_property (property);
}
@@ -713,8 +752,14 @@ public class Indicator.Keyboard.Service : Object {
desktop_menu = new IndicatorMenu (get_action_group ());
((!) desktop_menu).set_sources (get_sources ());
((!) desktop_menu).activate.connect ((property, state) => {
- if (panel_service != null) {
- ((!) panel_service).property_activate (property.key, state);
+ var panel = get_ibus_panel ();
+
+ if (panel != null) {
+ try {
+ ((!) 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 77ccdb88..38d5e005 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-27 11:31+1300\n"
+"POT-Creation-Date: 2014-03-27 23:39+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,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../lib/main.vala:631
+#: ../lib/main.vala:670
#, c-format
msgid "%s input source"
msgstr ""