Merge lp:~attente/gnome-screensaver/lp1225514 into lp:~ubuntu-desktop/gnome-screensaver/ubuntu

Proposed by William Hua
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~attente/gnome-screensaver/lp1225514
Merge into: lp:~ubuntu-desktop/gnome-screensaver/ubuntu
Diff against target: 373 lines (+353/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/32_input_sources_switcher.patch (+345/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~attente/gnome-screensaver/lp1225514
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+193152@code.launchpad.net

Commit message

* debian/patches/32_input_sources_switcher.patch:
  - Use input sources instead of XKB layouts.

Description of the change

* debian/patches/32_input_sources_switcher.patch:
  - Use input sources instead of XKB layouts.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks good and works fine, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-05-28 12:33:11 +0000
+++ debian/changelog 2013-10-29 22:30:08 +0000
@@ -1,3 +1,10 @@
1gnome-screensaver (3.6.1-0ubuntu7) UNRELEASED; urgency=low
2
3 * debian/patches/32_input_sources_switcher.patch:
4 - Use input sources instead of XKB layouts.
5
6 -- William Hua <william.hua@canonical.com> Tue, 29 Oct 2013 11:21:38 -0700
7
1gnome-screensaver (3.6.1-0ubuntu6) saucy; urgency=low8gnome-screensaver (3.6.1-0ubuntu6) saucy; urgency=low
29
3 * No-change rebuild against latest gnome-desktop310 * No-change rebuild against latest gnome-desktop3
411
=== added file 'debian/patches/32_input_sources_switcher.patch'
--- debian/patches/32_input_sources_switcher.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/32_input_sources_switcher.patch 2013-10-29 22:30:08 +0000
@@ -0,0 +1,345 @@
1--- a/src/gs-lock-plug.c
2+++ b/src/gs-lock-plug.c
3@@ -36,14 +36,17 @@
4 #include <gdk/gdkx.h>
5 #include <gtk/gtk.h>
6
7-#ifdef WITH_KBD_LAYOUT_INDICATOR
8-#include <libgnomekbd/gkbd-indicator.h>
9-#endif
10+#define GNOME_DESKTOP_USE_UNSTABLE_API
11+#include <libgnome-desktop/gnome-xkb-info.h>
12
13 #include "gs-lock-plug.h"
14
15 #include "gs-debug.h"
16
17+#define INPUT_SOURCES_SCHEMA "org.gnome.desktop.input-sources"
18+#define SOURCES_KEY "sources"
19+#define CURRENT_KEY "current"
20+
21 #define GDM_FLEXISERVER_COMMAND "gdmflexiserver"
22 #define GDM_FLEXISERVER_ARGS "--startnew Standard"
23
24@@ -83,7 +86,10 @@
25 GtkWidget *auth_switch_button;
26 GtkWidget *auth_logout_button;
27
28- GtkWidget *auth_prompt_kbd_layout_indicator;
29+ GSettings *input_sources_settings;
30+ GtkWidget *input_sources_label;
31+ GPtrArray *input_sources;
32+ guint input_source;
33
34 int kbd_lock_mode;
35 gboolean switch_enabled;
36@@ -1446,6 +1452,135 @@
37 g_free (name);
38 }
39
40+struct InputSource
41+{
42+ gchar *name;
43+ gboolean unique;
44+ guint subscript;
45+ guint index;
46+};
47+
48+typedef struct InputSource InputSource;
49+
50+static void
51+input_source_free (gpointer data)
52+{
53+ InputSource *input_source = data;
54+ g_free (input_source->name);
55+ g_free (data);
56+}
57+
58+static void
59+input_sources_current_changed_cb (GSettings *settings,
60+ gchar *key,
61+ gpointer user_data)
62+{
63+ GSLockPlug *plug = GS_LOCK_PLUG (user_data);
64+ guint current = g_settings_get_uint (settings, CURRENT_KEY);
65+ guint i;
66+
67+ for (i = 0; i < plug->priv->input_sources->len; i++) {
68+ InputSource *input_source = g_ptr_array_index (plug->priv->input_sources, i);
69+
70+ if (input_source->index == current) {
71+ if (!input_source->unique) {
72+ gchar *markup = g_markup_printf_escaped ("%s<sub><small>%u</small></sub>", input_source->name, input_source->subscript);
73+ gtk_label_set_markup (GTK_LABEL (plug->priv->input_sources_label), markup);
74+ g_free (markup);
75+ } else {
76+ gtk_label_set_text (GTK_LABEL (plug->priv->input_sources_label), input_source->name);
77+ }
78+
79+ break;
80+ }
81+ }
82+}
83+
84+static void
85+gs_lock_plug_init_input_sources (GSLockPlug *plug)
86+{
87+ GnomeXkbInfo *xkb_info;
88+ GVariant *sources;
89+ GVariantIter iter;
90+ const gchar *type;
91+ const gchar *name;
92+ guint current;
93+ guint i;
94+
95+ if (plug->priv->input_sources != NULL)
96+ return;
97+
98+ plug->priv->input_sources_settings = g_settings_new (INPUT_SOURCES_SCHEMA);
99+ sources = g_settings_get_value (plug->priv->input_sources_settings, SOURCES_KEY);
100+ current = g_settings_get_uint (plug->priv->input_sources_settings, CURRENT_KEY);
101+
102+ plug->priv->input_sources = g_ptr_array_new_full (g_variant_n_children (sources), input_source_free);
103+ plug->priv->input_source = 0;
104+
105+ xkb_info = gnome_xkb_info_new ();
106+
107+ g_variant_iter_init (&iter, sources);
108+ for (i = 0; g_variant_iter_next (&iter, "(&s&s)", &type, &name); i++) {
109+ if (g_strcmp0 (type, "xkb") == 0) {
110+ InputSource *input_source;
111+ const gchar *short_name;
112+ gint j;
113+
114+ gnome_xkb_info_get_layout_info (xkb_info, name, NULL, &short_name, NULL, NULL);
115+
116+ input_source = g_new0 (InputSource, 1);
117+ input_source->name = g_strdup (short_name);
118+ input_source->unique = TRUE;
119+ input_source->subscript = 1;
120+ input_source->index = i;
121+
122+ if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
123+ input_source->name[0] = g_ascii_toupper (input_source->name[0]);
124+
125+ for (j = plug->priv->input_sources->len - 1; j >= 0; j--) {
126+ InputSource *input_source_j = g_ptr_array_index (plug->priv->input_sources, j);
127+
128+ if (g_strcmp0 (input_source_j->name, input_source->name) == 0) {
129+ input_source_j->unique = FALSE;
130+ input_source->unique = FALSE;
131+ input_source->subscript = input_source_j->subscript + 1;
132+ break;
133+ }
134+ }
135+
136+ if (input_source->index == current)
137+ plug->priv->input_source = plug->priv->input_sources->len;
138+
139+ g_ptr_array_add (plug->priv->input_sources, input_source);
140+ }
141+ }
142+
143+ g_object_unref (xkb_info);
144+ g_variant_unref (sources);
145+
146+ g_signal_connect (plug->priv->input_sources_settings,
147+ "changed::" CURRENT_KEY,
148+ G_CALLBACK (input_sources_current_changed_cb),
149+ plug);
150+}
151+
152+static gboolean
153+layout_indicator_clicked_cb (GtkWidget *widget,
154+ GdkEvent *event,
155+ gpointer user_data)
156+{
157+ GSLockPlug *plug;
158+ InputSource *input_source;
159+
160+ plug = GS_LOCK_PLUG (user_data);
161+ plug->priv->input_source++;
162+ plug->priv->input_source %= plug->priv->input_sources->len;
163+ input_source = g_ptr_array_index (plug->priv->input_sources, plug->priv->input_source);
164+ g_settings_set_uint (plug->priv->input_sources_settings, CURRENT_KEY, input_source->index);
165+
166+ return TRUE;
167+}
168+
169 static void
170 create_page_one (GSLockPlug *plug)
171 {
172@@ -1453,6 +1588,7 @@
173 GtkWidget *vbox;
174 GtkWidget *vbox2;
175 GtkWidget *hbox;
176+ GtkWidget *hbox2;
177
178 gs_profile_start ("page one");
179
180@@ -1473,10 +1609,6 @@
181 gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
182 gtk_container_set_border_width (GTK_CONTAINER (vbox2), 10);
183
184-#ifdef WITH_KBD_LAYOUT_INDICATOR
185- gtk_box_pack_start (GTK_BOX (hbox), plug->priv->auth_prompt_kbd_layout_indicator, FALSE, FALSE, 0);
186-#endif
187-
188 /* Change appearance if we're running under Unity */
189 if (g_getenv ("XDG_CURRENT_DESKTOP") &&
190 strcmp (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0) {
191@@ -1491,11 +1623,38 @@
192 gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_prompt_label), 0, 0);
193 gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_prompt_label, FALSE, FALSE, 0);
194
195+ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
196 plug->priv->auth_prompt_entry = gtk_entry_new ();
197- gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_prompt_entry, TRUE, TRUE, 6);
198
199 gtk_label_set_mnemonic_widget (GTK_LABEL (plug->priv->auth_prompt_label),
200 plug->priv->auth_prompt_entry);
201+ gtk_box_pack_start (GTK_BOX (hbox2), plug->priv->auth_prompt_entry, TRUE, TRUE, 6);
202+
203+ /* Layout indicator */
204+#ifdef WITH_KBD_LAYOUT_INDICATOR
205+ gs_lock_plug_init_input_sources (plug);
206+
207+ if (plug->priv->input_sources->len > 1) {
208+ GtkWidget *layout_indicator;
209+
210+ layout_indicator = gtk_event_box_new ();
211+ plug->priv->input_sources_label = gtk_label_new (NULL);
212+ input_sources_current_changed_cb (plug->priv->input_sources_settings, CURRENT_KEY, plug);
213+ g_signal_connect (layout_indicator, "button-release-event", G_CALLBACK (layout_indicator_clicked_cb), plug);
214+ gtk_widget_set_size_request (layout_indicator, 50, 40);
215+
216+ gtk_container_add (GTK_CONTAINER (layout_indicator), plug->priv->input_sources_label);
217+ gtk_box_pack_start (GTK_BOX (hbox2),
218+ layout_indicator,
219+ FALSE,
220+ FALSE,
221+ 6);
222+
223+ gtk_widget_show_all (hbox2);
224+ }
225+#endif
226+
227+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 6);
228
229 plug->priv->auth_capslock_label = gtk_label_new ("");
230 gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_capslock_label), 0, 0.5);
231@@ -1514,11 +1673,38 @@
232 gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_prompt_label), 0, 0.5);
233 gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_prompt_label, FALSE, FALSE, 0);
234
235+ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
236 plug->priv->auth_prompt_entry = gtk_entry_new ();
237- gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_prompt_entry, TRUE, TRUE, 0);
238
239 gtk_label_set_mnemonic_widget (GTK_LABEL (plug->priv->auth_prompt_label),
240 plug->priv->auth_prompt_entry);
241+ gtk_box_pack_start (GTK_BOX (hbox2), plug->priv->auth_prompt_entry, TRUE, TRUE, 6);
242+
243+ /* Layout indicator */
244+#ifdef WITH_KBD_LAYOUT_INDICATOR
245+ gs_lock_plug_init_input_sources (plug);
246+
247+ if (plug->priv->input_sources->len > 1) {
248+ GtkWidget *layout_indicator;
249+
250+ layout_indicator = gtk_event_box_new ();
251+ plug->priv->input_sources_label = gtk_label_new (NULL);
252+ input_sources_current_changed_cb (plug->priv->input_sources_settings, CURRENT_KEY, plug);
253+ g_signal_connect (layout_indicator, "button-release-event", G_CALLBACK (layout_indicator_clicked_cb), plug);
254+ gtk_widget_set_size_request (layout_indicator, 50, 40);
255+
256+ gtk_container_add (GTK_CONTAINER (layout_indicator), plug->priv->input_sources_label);
257+ gtk_box_pack_start (GTK_BOX (hbox2),
258+ layout_indicator,
259+ FALSE,
260+ FALSE,
261+ 6);
262+
263+ gtk_widget_show_all (hbox2);
264+ }
265+#endif
266+
267+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0);
268
269 plug->priv->auth_capslock_label = gtk_label_new ("");
270 gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_capslock_label), 0.5, 0.5);
271@@ -1595,8 +1781,6 @@
272 plug->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
273 gtk_container_add (GTK_CONTAINER (plug->priv->frame), plug->priv->vbox);
274
275- plug->priv->auth_prompt_kbd_layout_indicator = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
276-
277 /* Notebook */
278 plug->priv->notebook = gtk_notebook_new ();
279 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (plug->priv->notebook), FALSE);
280@@ -1609,33 +1793,6 @@
281
282 gtk_widget_show_all (plug->priv->frame);
283
284- /* Layout indicator */
285-#ifdef WITH_KBD_LAYOUT_INDICATOR
286- if (plug->priv->auth_prompt_kbd_layout_indicator != NULL) {
287- XklEngine *engine;
288-
289- engine = xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
290- if (xkl_engine_get_num_groups (engine) > 1) {
291- GtkWidget *layout_indicator;
292-
293- layout_indicator = gkbd_indicator_new ();
294- gkbd_indicator_set_parent_tooltips (GKBD_INDICATOR (layout_indicator), TRUE);
295- gtk_box_pack_start (GTK_BOX (plug->priv->auth_prompt_kbd_layout_indicator),
296- layout_indicator,
297- FALSE,
298- FALSE,
299- 6);
300-
301- gtk_widget_show_all (layout_indicator);
302- gtk_widget_show (plug->priv->auth_prompt_kbd_layout_indicator);
303- } else {
304- gtk_widget_hide (plug->priv->auth_prompt_kbd_layout_indicator);
305- }
306-
307- g_object_unref (engine);
308- }
309-#endif
310-
311 if (plug->priv->auth_switch_button != NULL) {
312 if (plug->priv->switch_enabled) {
313 gtk_widget_show_all (plug->priv->auth_switch_button);
314@@ -1705,6 +1862,19 @@
315
316 g_return_if_fail (plug->priv != NULL);
317
318+ if (plug->priv->input_sources != NULL)
319+ g_ptr_array_unref (plug->priv->input_sources);
320+
321+ if (plug->priv->input_sources_label != NULL) {
322+ g_signal_handlers_disconnect_by_data (plug->priv->input_sources_label, plug);
323+ g_object_unref (plug->priv->input_sources_label);
324+ }
325+
326+ if (plug->priv->input_sources_settings != NULL) {
327+ g_signal_handlers_disconnect_by_data (plug->priv->input_sources_settings, plug);
328+ g_object_unref (plug->priv->input_sources_settings);
329+ }
330+
331 g_free (plug->priv->logout_command);
332
333 remove_response_idle (plug);
334--- a/configure.ac
335+++ b/configure.ac
336@@ -66,7 +66,8 @@
337
338 PKG_CHECK_MODULES(GNOME_SCREENSAVER_DIALOG,
339 gthread-2.0
340- gtk+-3.0 >= $GTK_REQUIRED_VERSION)
341+ gtk+-3.0 >= $GTK_REQUIRED_VERSION
342+ gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION)
343 AC_SUBST(GNOME_SCREENSAVER_DIALOG_CFLAGS)
344 AC_SUBST(GNOME_SCREENSAVER_DIALOG_LIBS)
345
0346
=== modified file 'debian/patches/series'
--- debian/patches/series 2013-05-01 17:59:44 +0000
+++ debian/patches/series 2013-10-29 22:30:08 +0000
@@ -19,3 +19,4 @@
1929_handle_expired_creds.patch1929_handle_expired_creds.patch
2030_ubuntu-lock-on-suspend_gsetting.patch2030_ubuntu-lock-on-suspend_gsetting.patch
2131_lock_screen_on_suspend.patch2131_lock_screen_on_suspend.patch
2232_input_sources_switcher.patch

Subscribers

People subscribed via source and target branches

to all changes: