Merge lp:~attente/indicator-keyboard/1290881 into lp:indicator-keyboard

Proposed by William Hua
Status: Superseded
Proposed branch: lp:~attente/indicator-keyboard/1290881
Merge into: lp:indicator-keyboard
Diff against target: 202 lines (+88/-15)
5 files modified
debian/control (+1/-0)
lib/Makefile.am (+1/-0)
lib/ibus-panel.vala (+26/-0)
lib/main.vala (+55/-10)
po/indicator-keyboard.pot (+5/-5)
To merge this branch: bzr merge lp:~attente/indicator-keyboard/1290881
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
PS Jenkins bot (community) continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+211666@code.launchpad.net

This proposal has been superseded by a proposal from 2014-03-28.

Commit message

Use Ubuntu-specific IBus D-Bus API so that we don't have to replace the old IBus panel service in order to inspect and activate IBus engine properties.

Description of the change

Use Ubuntu-specific IBus D-Bus API so that we don't have to replace the old IBus panel service in order to inspect and activate IBus engine properties.

This branch depends on the IBus patch attached at https://bugs.launchpad.net/indicator-keyboard/+bug/1290881.

To post a comment you must log in.
310. By William Hua

Breaks IBus << 1.5.5-1ubuntu3.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
311. By William Hua

Check if IBus is connected before checking engine properties.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

LGTM.

review: Approve
312. By William Hua

IBus panel is only available while IBus is running.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks! The new ibus got uploaded (still in the unapproved queue due to beta freeze though), we can land that one next

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-11-22 16:44:45 +0000
3+++ debian/control 2014-03-19 23:26:13 +0000
4@@ -30,6 +30,7 @@
5 Architecture: any
6 Depends: ${misc:Depends},
7 ${shlibs:Depends},
8+Breaks: ibus (<< 1.5.5-1ubuntu3),
9 Description: Keyboard indicator
10 This package contains the keyboard indicator, which should show as an icon in
11 the top panel when using the Unity environment. It can be used to switch
12
13=== modified file 'lib/Makefile.am'
14--- lib/Makefile.am 2014-02-19 16:10:54 +0000
15+++ lib/Makefile.am 2014-03-19 23:26:13 +0000
16@@ -10,6 +10,7 @@
17 source.vala \
18 common.vala \
19 ibus-menu.vala \
20+ ibus-panel.vala \
21 window-stack.vala \
22 unity-greeter.vala
23 indicator_keyboard_service_VALAFLAGS = $(AM_VALAFLAGS) \
24
25=== added file 'lib/ibus-panel.vala'
26--- lib/ibus-panel.vala 1970-01-01 00:00:00 +0000
27+++ lib/ibus-panel.vala 2014-03-19 23:26:13 +0000
28@@ -0,0 +1,26 @@
29+/*
30+ * Copyright 2014 Canonical Ltd.
31+ *
32+ * This program is free software: you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License as published by
34+ * the Free Software Foundation, version 3 of the License.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details.
40+ *
41+ * You should have received a copy of the GNU General Public License
42+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
43+ *
44+ * Authors: William Hua <william.hua@canonical.com>
45+ */
46+
47+[DBus (name="com.canonical.IBus.Panel.Private")]
48+public interface IBusPanel : Object {
49+
50+ public abstract void activate_property (string name, uint state) throws IOError;
51+
52+ public signal void properties_registered (Variant variant);
53+ public signal void property_updated (Variant variant);
54+}
55
56=== modified file 'lib/main.vala'
57--- lib/main.vala 2014-02-27 19:37:55 +0000
58+++ lib/main.vala 2014-03-19 23:26:13 +0000
59@@ -37,7 +37,8 @@
60 private uint focused_window_id;
61
62 private IBus.Bus? ibus;
63- private IBus.PanelService? panel_service;
64+ private IBusPanel? ibus_panel;
65+ private ulong ibus_connected_id;
66 private uint panel_timeout;
67
68 private Source[]? sources;
69@@ -132,6 +133,43 @@
70 }
71
72 [DBus (visible = false)]
73+ private IBusPanel? get_ibus_panel () {
74+ if (ibus_panel == null && get_ibus ().is_connected ()) {
75+ var connection = get_ibus ().get_connection ();
76+ var name = "org.freedesktop.IBus.Panel";
77+ var path = "/org/freedesktop/IBus/Panel";
78+
79+ try {
80+ ibus_panel = connection.get_proxy_sync (name, path);
81+
82+ ((!) ibus_panel).properties_registered.connect ((variant) => {
83+ var properties = new IBus.PropList ();
84+ properties.deserialize (variant);
85+
86+ if (properties is IBus.PropList) {
87+ handle_properties_registered ((!) (properties as IBus.PropList));
88+ }
89+ });
90+ ((!) ibus_panel).property_updated.connect ((variant) => {
91+ var type = IBus.PropType.NORMAL;
92+ var state = IBus.PropState.INCONSISTENT;
93+ var text = new IBus.Text.from_static_string ("");
94+ var property = new IBus.Property ("", type, text, null, text, false, false, state, null);
95+ property.deserialize (variant);
96+
97+ if (property is IBus.Property) {
98+ handle_property_updated ((!) (property as IBus.Property));
99+ }
100+ });
101+ } catch (IOError error) {
102+ warning ("error: %s", error.message);
103+ }
104+ }
105+
106+ return ibus_panel;
107+ }
108+
109+ [DBus (visible = false)]
110 public void up () {
111 if (loop == null) {
112 loop = new MainLoop ();
113@@ -576,11 +614,12 @@
114 }
115 }
116
117- if (panel_service == null && sources[i].is_ibus) {
118- if (get_ibus ().request_name (IBus.SERVICE_PANEL, IBus.BusNameFlag.REPLACE_EXISTING) > 0) {
119- panel_service = new IBus.PanelService (get_ibus ().get_connection ());
120- ((!) panel_service).register_properties.connect (handle_registered_properties);
121- ((!) panel_service).update_property.connect (handle_updated_property);
122+ if (ibus_connected_id == 0 && sources[i].is_ibus) {
123+ ibus_connected_id = get_ibus ().connected.connect (() => { get_ibus_panel (); });
124+ get_ibus ().disconnected.connect (() => { ibus_panel = null; });
125+
126+ if (get_ibus ().is_connected ()) {
127+ get_ibus_panel ();
128 }
129 }
130 }
131@@ -590,7 +629,7 @@
132 }
133
134 [DBus (visible = false)]
135- private void handle_registered_properties (IBus.PropList list) {
136+ private void handle_properties_registered (IBus.PropList list) {
137 if (panel_timeout > 0) {
138 GLib.Source.remove (panel_timeout);
139 panel_timeout = 0;
140@@ -604,7 +643,7 @@
141 }
142
143 [DBus (visible = false)]
144- private void handle_updated_property (IBus.Property property) {
145+ private void handle_property_updated (IBus.Property property) {
146 get_ibus_menu ().update_property (property);
147 }
148
149@@ -747,8 +786,14 @@
150 if (ibus_menu == null) {
151 ibus_menu = new IBusMenu (get_action_group ());
152 ((!) ibus_menu).activate.connect ((property, state) => {
153- if (panel_service != null) {
154- ((!) panel_service).property_activate (property.key, state);
155+ var panel = get_ibus_panel ();
156+
157+ if (panel != null) {
158+ try {
159+ ((!) panel).activate_property (property.key, state);
160+ } catch (IOError error) {
161+ warning ("error: %s", error.message);
162+ }
163 }
164 });
165 }
166
167=== modified file 'po/indicator-keyboard.pot'
168--- po/indicator-keyboard.pot 2013-09-27 15:10:19 +0000
169+++ po/indicator-keyboard.pot 2014-03-19 23:26:13 +0000
170@@ -8,7 +8,7 @@
171 msgstr ""
172 "Project-Id-Version: PACKAGE VERSION\n"
173 "Report-Msgid-Bugs-To: \n"
174-"POT-Creation-Date: 2013-09-27 16:28+0200\n"
175+"POT-Creation-Date: 2014-03-20 12:25+1300\n"
176 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
177 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
178 "Language-Team: LANGUAGE <LL@li.org>\n"
179@@ -17,19 +17,19 @@
180 "Content-Type: text/plain; charset=CHARSET\n"
181 "Content-Transfer-Encoding: 8bit\n"
182
183-#: ../lib/main.vala:427
184+#: ../lib/main.vala:667
185 #, c-format
186 msgid "%s input source"
187 msgstr ""
188
189-#: ../lib/main.vala:525
190+#: ../lib/main.vala:815
191 msgid "Character Map"
192 msgstr ""
193
194-#: ../lib/main.vala:526
195+#: ../lib/main.vala:816
196 msgid "Keyboard Layout Chart"
197 msgstr ""
198
199-#: ../lib/main.vala:527
200+#: ../lib/main.vala:817
201 msgid "Text Entry Settings..."
202 msgstr ""

Subscribers

People subscribed via source and target branches

to all changes: