Merge lp:~attente/unity-gtk-module/1208019 into lp:unity-gtk-module/14.04

Proposed by William Hua
Status: Merged
Approved by: Charles Kerr
Approved revision: 331
Merged at revision: 321
Proposed branch: lp:~attente/unity-gtk-module/1208019
Merge into: lp:unity-gtk-module/14.04
Diff against target: 418 lines (+104/-82)
8 files modified
lib/unity-gtk-action-group.c (+10/-35)
lib/unity-gtk-action-group.h (+0/-4)
lib/unity-gtk-menu-item-private.h (+1/-2)
lib/unity-gtk-menu-item.c (+82/-16)
lib/unity-gtk-menu-section.c (+1/-1)
lib/unity-gtk-menu-shell.c (+5/-13)
lib/unity-gtk-menu-shell.h (+0/-1)
src/main.c (+5/-10)
To merge this branch: bzr merge lp:~attente/unity-gtk-module/1208019
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+212063@code.launchpad.net

Commit message

Fix Eclipse and DBeaver menus.

Description of the change

Fix Eclipse and DBeaver menus.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Very nice work :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/unity-gtk-action-group.c'
2--- lib/unity-gtk-action-group.c 2013-12-13 17:42:54 +0000
3+++ lib/unity-gtk-action-group.c 2014-03-20 22:09:10 +0000
4@@ -120,38 +120,13 @@
5
6 if (old_group != old_old_group)
7 {
8- if (group->old_group_action_state_changed_handler_id)
9- {
10- g_assert (old_old_group != NULL);
11- g_signal_handler_disconnect (old_old_group, group->old_group_action_state_changed_handler_id);
12- group->old_group_action_state_changed_handler_id = 0;
13- }
14-
15- if (group->old_group_action_enabled_changed_handler_id)
16- {
17- g_assert (old_old_group != NULL);
18- g_signal_handler_disconnect (old_old_group, group->old_group_action_enabled_changed_handler_id);
19- group->old_group_action_enabled_changed_handler_id = 0;
20- }
21-
22- if (group->old_group_action_removed_handler_id)
23- {
24- g_assert (old_old_group != NULL);
25- g_signal_handler_disconnect (old_old_group, group->old_group_action_removed_handler_id);
26- group->old_group_action_removed_handler_id = 0;
27- }
28-
29- if (group->old_group_action_added_handler_id)
30- {
31- g_assert (old_old_group != NULL);
32- g_signal_handler_disconnect (old_old_group, group->old_group_action_added_handler_id);
33- group->old_group_action_added_handler_id = 0;
34- }
35-
36 if (old_old_group != NULL)
37 {
38- gchar **names = g_action_group_list_actions (old_old_group);
39-
40+ gchar **names;
41+
42+ g_signal_handlers_disconnect_by_data (old_old_group, group);
43+
44+ names = g_action_group_list_actions (old_old_group);
45 group->old_group = NULL;
46 g_object_unref (old_old_group);
47
48@@ -171,10 +146,10 @@
49 gchar **names = g_action_group_list_actions (old_group);
50
51 group->old_group = g_object_ref (old_group);
52- group->old_group_action_added_handler_id = g_signal_connect (old_group, "action-added", G_CALLBACK (unity_gtk_action_group_handle_group_action_added), group);
53- group->old_group_action_removed_handler_id = g_signal_connect (old_group, "action-removed", G_CALLBACK (unity_gtk_action_group_handle_group_action_removed), group);
54- group->old_group_action_enabled_changed_handler_id = g_signal_connect (old_group, "action-enabled-changed", G_CALLBACK (unity_gtk_action_group_handle_group_action_enabled_changed), group);
55- group->old_group_action_state_changed_handler_id = g_signal_connect (old_group, "action-state-changed", G_CALLBACK (unity_gtk_action_group_handle_group_action_state_changed), group);
56+ g_signal_connect (old_group, "action-added", G_CALLBACK (unity_gtk_action_group_handle_group_action_added), group);
57+ g_signal_connect (old_group, "action-removed", G_CALLBACK (unity_gtk_action_group_handle_group_action_removed), group);
58+ g_signal_connect (old_group, "action-enabled-changed", G_CALLBACK (unity_gtk_action_group_handle_group_action_enabled_changed), group);
59+ g_signal_connect (old_group, "action-state-changed", G_CALLBACK (unity_gtk_action_group_handle_group_action_state_changed), group);
60
61 if (names != NULL)
62 {
63@@ -672,7 +647,7 @@
64 name = gtk_menu_item_get_label (menu_item);
65
66 if (name == NULL || name[0] == '\0')
67- name = gtk_menu_item_get_nth_label (menu_item, 0);
68+ name = gtk_menu_item_get_nth_label_label (menu_item, 0);
69
70 if (name != NULL && name[0] == '\0')
71 name = NULL;
72
73=== modified file 'lib/unity-gtk-action-group.h'
74--- lib/unity-gtk-action-group.h 2013-02-19 11:55:57 +0000
75+++ lib/unity-gtk-action-group.h 2014-03-20 22:09:10 +0000
76@@ -51,10 +51,6 @@
77
78 /*< private >*/
79 GActionGroup *old_group;
80- gulong old_group_action_added_handler_id;
81- gulong old_group_action_removed_handler_id;
82- gulong old_group_action_enabled_changed_handler_id;
83- gulong old_group_action_state_changed_handler_id;
84 GHashTable *actions_by_name;
85 GHashTable *names_by_radio_menu_item;
86 };
87
88=== modified file 'lib/unity-gtk-menu-item-private.h'
89--- lib/unity-gtk-menu-item-private.h 2014-03-06 20:27:26 +0000
90+++ lib/unity-gtk-menu-item-private.h 2014-03-20 22:09:10 +0000
91@@ -47,7 +47,6 @@
92
93 /*< private >*/
94 GtkMenuItem *menu_item;
95- gulong menu_item_notify_handler_id;
96 UnityGtkMenuShell *parent_shell;
97 UnityGtkMenuShell *child_shell;
98 guchar child_shell_valid : 1;
99@@ -90,7 +89,7 @@
100 void unity_gtk_menu_item_print (UnityGtkMenuItem *item,
101 guint indent) G_GNUC_INTERNAL;
102
103-const gchar * gtk_menu_item_get_nth_label (GtkMenuItem *menu_item,
104+const gchar * gtk_menu_item_get_nth_label_label (GtkMenuItem *menu_item,
105 guint index) G_GNUC_INTERNAL;
106
107 G_END_DECLS
108
109=== modified file 'lib/unity-gtk-menu-item.c'
110--- lib/unity-gtk-menu-item.c 2014-03-06 20:27:26 +0000
111+++ lib/unity-gtk-menu-item.c 2014-03-20 22:09:10 +0000
112@@ -57,12 +57,11 @@
113 }
114 }
115
116-const gchar *
117+static GtkLabel *
118 gtk_menu_item_get_nth_label (GtkMenuItem *menu_item,
119 guint index)
120 {
121 UnityGtkSearch search;
122- const gchar *label = NULL;
123
124 g_return_val_if_fail (GTK_IS_MENU_ITEM (menu_item), NULL);
125
126@@ -72,10 +71,25 @@
127
128 g_object_get_nth_object (G_OBJECT (menu_item), &search);
129
130- if (search.object != NULL)
131- label = gtk_label_get_label (GTK_LABEL (search.object));
132-
133- return label != NULL && label[0] != '\0' ? label : NULL;
134+ return search.object != NULL ? GTK_LABEL (search.object) : NULL;
135+}
136+
137+const gchar *
138+gtk_menu_item_get_nth_label_label (GtkMenuItem *menu_item,
139+ guint index)
140+{
141+ GtkLabel *label;
142+ const gchar *label_label;
143+
144+ g_return_val_if_fail (GTK_IS_MENU_ITEM (menu_item), NULL);
145+
146+ label = gtk_menu_item_get_nth_label (menu_item, index);
147+ label_label = NULL;
148+
149+ if (label != NULL)
150+ label_label = gtk_label_get_label (label);
151+
152+ return label_label != NULL && label_label[0] != '\0' ? label_label : NULL;
153 }
154
155 static GtkImage *
156@@ -295,9 +309,12 @@
157 GParamSpec *pspec,
158 gpointer user_data)
159 {
160+ static const gchar *label_name;
161+
162 UnityGtkMenuItem *item;
163 UnityGtkMenuShell *parent_shell;
164 GObject *menu_item;
165+ const gchar *name;
166
167 g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (user_data));
168
169@@ -308,24 +325,62 @@
170 g_return_if_fail (parent_shell != NULL);
171 g_warn_if_fail (object == menu_item);
172
173- unity_gtk_menu_shell_handle_item_notify (parent_shell, item, g_param_spec_get_name (pspec));
174+ if (label_name == NULL)
175+ label_name = g_intern_static_string ("label");
176+
177+ name = g_param_spec_get_name (pspec);
178+
179+ if (name != label_name)
180+ unity_gtk_menu_shell_handle_item_notify (parent_shell, item, name);
181+}
182+
183+static void
184+unity_gtk_menu_item_handle_label_notify (GObject *object,
185+ GParamSpec *pspec,
186+ gpointer user_data)
187+{
188+ static const gchar *label_name;
189+
190+ UnityGtkMenuItem *item;
191+ UnityGtkMenuShell *parent_shell;
192+ const gchar *name;
193+
194+ g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (user_data));
195+
196+ item = UNITY_GTK_MENU_ITEM (user_data);
197+ parent_shell = item->parent_shell;
198+
199+ g_return_if_fail (parent_shell != NULL);
200+
201+ if (label_name == NULL)
202+ label_name = g_intern_static_string ("label");
203+
204+ name = g_param_spec_get_name (pspec);
205+
206+ if (name == label_name)
207+ unity_gtk_menu_shell_handle_item_notify (parent_shell, item, name);
208 }
209
210 static void
211 unity_gtk_menu_item_set_menu_item (UnityGtkMenuItem *item,
212 GtkMenuItem *menu_item)
213 {
214+ GtkLabel *label;
215+
216 g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item));
217
218 if (menu_item != item->menu_item)
219 {
220 UnityGtkMenuShell *child_shell = item->child_shell;
221
222- if (item->menu_item_notify_handler_id)
223+ if (item->menu_item != NULL)
224 {
225- g_warn_if_fail (item->menu_item != NULL);
226- g_signal_handler_disconnect (item->menu_item, item->menu_item_notify_handler_id);
227- item->menu_item_notify_handler_id = 0;
228+ label = gtk_menu_item_get_nth_label (item->menu_item, 0);
229+
230+ if (label != NULL)
231+ g_signal_handlers_disconnect_by_data (label, item);
232+
233+ g_signal_handlers_disconnect_by_data (item->menu_item, item);
234 }
235
236 if (child_shell != NULL)
237@@ -339,7 +394,20 @@
238 item->menu_item = menu_item;
239
240 if (menu_item != NULL)
241- item->menu_item_notify_handler_id = g_signal_connect (menu_item, "notify", G_CALLBACK (unity_gtk_menu_item_handle_item_notify), item);
242+ {
243+ g_signal_connect (menu_item, "notify", G_CALLBACK (unity_gtk_menu_item_handle_item_notify), item);
244+
245+ /* ensure label is available */
246+ gtk_menu_item_get_label (menu_item);
247+ label = gtk_menu_item_get_nth_label (menu_item, 0);
248+
249+ if (label != NULL)
250+ g_signal_connect (label, "notify", G_CALLBACK (unity_gtk_menu_item_handle_label_notify), item);
251+
252+ /* LP: #1208019 */
253+ if (gtk_menu_item_get_submenu (menu_item) != NULL)
254+ g_signal_emit_by_name (gtk_menu_item_get_submenu (menu_item), "show");
255+ }
256 }
257 }
258
259@@ -587,7 +655,7 @@
260 }
261
262 if (label == NULL || label[0] == '\0')
263- label = gtk_menu_item_get_nth_label (item->menu_item, 0);
264+ label = gtk_menu_item_get_nth_label_label (item->menu_item, 0);
265
266 if (label != NULL && label[0] != '\0')
267 {
268@@ -709,9 +777,7 @@
269 g_print ("%s%u (%s *) %p\n", space, item->item_index, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (item)), item);
270
271 if (item->menu_item != NULL)
272- g_print ("%s %lu (%s *) %p\n", space, item->menu_item_notify_handler_id, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (item->menu_item)), item->menu_item);
273- else if (item->menu_item_notify_handler_id)
274- g_print ("%s %lu\n", space, item->menu_item_notify_handler_id);
275+ g_print ("%s (%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (item->menu_item)), item->menu_item);
276
277 if (item->parent_shell != NULL)
278 g_print ("%s (%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (item->parent_shell)), item->parent_shell);
279
280=== modified file 'lib/unity-gtk-menu-section.c'
281--- lib/unity-gtk-menu-section.c 2013-06-17 17:32:33 +0000
282+++ lib/unity-gtk-menu-section.c 2014-03-20 22:09:10 +0000
283@@ -166,7 +166,7 @@
284 }
285
286 if (accel_name == NULL)
287- accel_name = g_strdup (gtk_menu_item_get_nth_label (item->menu_item, 1));
288+ accel_name = g_strdup (gtk_menu_item_get_nth_label_label (item->menu_item, 1));
289
290 if (accel_name != NULL)
291 g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_ACCEL, g_variant_ref_sink (g_variant_new_string (accel_name)));
292
293=== modified file 'lib/unity-gtk-menu-shell.c'
294--- lib/unity-gtk-menu-shell.c 2014-03-06 20:27:26 +0000
295+++ lib/unity-gtk-menu-shell.c 2014-03-20 22:09:10 +0000
296@@ -731,12 +731,8 @@
297 if (shell->action_group != NULL)
298 unity_gtk_action_group_disconnect_shell (shell->action_group, shell);
299
300- if (shell->menu_shell_insert_handler_id)
301- {
302- g_assert (shell->menu_shell != NULL);
303- g_signal_handler_disconnect (shell->menu_shell, shell->menu_shell_insert_handler_id);
304- shell->menu_shell_insert_handler_id = 0;
305- }
306+ if (shell->menu_shell != NULL)
307+ g_signal_handlers_disconnect_by_data (shell->menu_shell, shell);
308
309 if (separator_indices != NULL)
310 {
311@@ -771,7 +767,7 @@
312 {
313 g_object_set_qdata_full (G_OBJECT (menu_shell), menu_shell_quark (), shell, (GDestroyNotify) unity_gtk_menu_shell_clear_menu_shell);
314
315- shell->menu_shell_insert_handler_id = g_signal_connect (menu_shell, "insert", G_CALLBACK (unity_gtk_menu_shell_handle_shell_insert), shell);
316+ g_signal_connect (menu_shell, "insert", G_CALLBACK (unity_gtk_menu_shell_handle_shell_insert), shell);
317 }
318 }
319 }
320@@ -781,8 +777,6 @@
321 {
322 g_return_if_fail (UNITY_GTK_IS_MENU_SHELL (shell));
323
324- shell->menu_shell_insert_handler_id = 0;
325-
326 unity_gtk_menu_shell_set_menu_shell (shell, NULL);
327 }
328
329@@ -800,7 +794,7 @@
330 unity_gtk_menu_shell_set_menu_shell (shell, NULL);
331
332 if (settings != NULL)
333- g_signal_handlers_disconnect_by_func (settings, unity_gtk_menu_shell_handle_settings_notify, shell);
334+ g_signal_handlers_disconnect_by_data (settings, shell);
335
336 G_OBJECT_CLASS (unity_gtk_menu_shell_parent_class)->dispose (object);
337 }
338@@ -1085,9 +1079,7 @@
339 g_print ("%s(%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (shell)), shell);
340
341 if (shell->menu_shell != NULL)
342- g_print ("%s %lu (%s *) %p\n", space, shell->menu_shell_insert_handler_id, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (shell->menu_shell)), shell->menu_shell);
343- else if (shell->menu_shell_insert_handler_id)
344- g_print ("%s %lu\n", space, shell->menu_shell_insert_handler_id);
345+ g_print ("%s (%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (shell->menu_shell)), shell->menu_shell);
346
347 if (shell->items != NULL)
348 {
349
350=== modified file 'lib/unity-gtk-menu-shell.h'
351--- lib/unity-gtk-menu-shell.h 2014-02-26 05:40:41 +0000
352+++ lib/unity-gtk-menu-shell.h 2014-03-20 22:09:10 +0000
353@@ -51,7 +51,6 @@
354
355 /*< private >*/
356 GtkMenuShell *menu_shell;
357- gulong menu_shell_insert_handler_id;
358 gboolean has_mnemonics;
359 GPtrArray *items;
360 GPtrArray *sections;
361
362=== modified file 'src/main.c'
363--- src/main.c 2013-11-27 15:54:38 +0000
364+++ src/main.c 2014-03-20 22:09:10 +0000
365@@ -27,7 +27,6 @@
366 */
367 static const char * const BLACKLIST[] =
368 {
369- "Eclipse",
370 "acroread",
371 "emacs",
372 "emacs23",
373@@ -70,7 +69,6 @@
374 struct _MenuShellData
375 {
376 GtkWindow *window;
377- gulong settings_notify_gtk_shell_shows_menubar_handler_id;
378 };
379
380 static void (* pre_hijacked_window_realize) (GtkWidget *widget);
381@@ -589,7 +587,6 @@
382 {
383 GtkWidget *window;
384 GtkSettings *settings;
385- MenuShellData *menu_shell_data;
386
387 g_return_if_fail (GTK_IS_MENU_BAR (widget));
388
389@@ -602,24 +599,22 @@
390 gtk_window_connect_menu_shell (GTK_WINDOW (window), GTK_MENU_SHELL (widget));
391
392 settings = gtk_widget_get_settings (widget);
393- menu_shell_data = gtk_menu_shell_get_menu_shell_data (GTK_MENU_SHELL (widget));
394- menu_shell_data->settings_notify_gtk_shell_shows_menubar_handler_id = g_signal_connect (settings, "notify::gtk-shell-shows-menubar", G_CALLBACK (gtk_settings_handle_gtk_shell_shows_menubar), widget);
395+ g_signal_connect (settings, "notify::gtk-shell-shows-menubar", G_CALLBACK (gtk_settings_handle_gtk_shell_shows_menubar), widget);
396 }
397
398 static void
399 hijacked_menu_bar_unrealize (GtkWidget *widget)
400 {
401+ GtkSettings *settings;
402 MenuShellData *menu_shell_data;
403
404 g_return_if_fail (GTK_IS_MENU_BAR (widget));
405
406+ settings = gtk_widget_get_settings (widget);
407 menu_shell_data = gtk_menu_shell_get_menu_shell_data (GTK_MENU_SHELL (widget));
408
409- if (menu_shell_data->settings_notify_gtk_shell_shows_menubar_handler_id)
410- {
411- g_signal_handler_disconnect (gtk_widget_get_settings (widget), menu_shell_data->settings_notify_gtk_shell_shows_menubar_handler_id);
412- menu_shell_data->settings_notify_gtk_shell_shows_menubar_handler_id = 0;
413- }
414+ if (settings != NULL)
415+ g_signal_handlers_disconnect_by_data (settings, widget);
416
417 if (menu_shell_data->window != NULL)
418 gtk_window_disconnect_menu_shell (menu_shell_data->window, GTK_MENU_SHELL (widget));

Subscribers

People subscribed via source and target branches