Merge lp:~charlesk/libdbusmenu/lp-959821 into lp:libdbusmenu/0.6
- lp-959821
- Merge into trunk.0.6
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 410 |
Merged at revision: | 407 |
Proposed branch: | lp:~charlesk/libdbusmenu/lp-959821 |
Merge into: | lp:libdbusmenu/0.6 |
Diff against target: |
466 lines (+165/-114) 1 file modified
libdbusmenu-gtk/parser.c (+165/-114) |
To merge this branch: | bzr merge lp:~charlesk/libdbusmenu/lp-959821 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+101255@code.launchpad.net |
Commit message
Description of the change
This patch includes code cleanup too, so here's a guide to what's going on, ordered by line number:
* g_intern_
* parser_data_free() has new warnings to notify if we're fail to disconnect from the right number of signals. This was added because odd callbacks seem to be a recurring theme for this code in LP.
* dbusmenu_
* update_icon() had an unnecessary conditional that could have caused the wrong GtkImage for being monitored for changes. I suspect that this is the cause behind bug #959821, although I'm not able to reproduce the bug in testing.
* Fix a memory leak in widget_notify_cb() where prop_value wasn't cleaned up if the "label" property changed.
Preview Diff
1 | === modified file 'libdbusmenu-gtk/parser.c' |
2 | --- libdbusmenu-gtk/parser.c 2012-03-21 12:20:21 +0000 |
3 | +++ libdbusmenu-gtk/parser.c 2012-04-09 16:33:19 +0000 |
4 | @@ -61,7 +61,6 @@ |
5 | DbusmenuMenuitem * mi); |
6 | static void update_icon (DbusmenuMenuitem * menuitem, |
7 | ParserData * pdata, |
8 | - GtkImageMenuItem * gmenuitem, |
9 | GtkImage * image); |
10 | static GtkWidget * find_menu_label (GtkWidget * widget); |
11 | static void label_notify_cb (GtkWidget * widget, |
12 | @@ -106,6 +105,61 @@ |
13 | GParamSpec * pspec, |
14 | gpointer data); |
15 | |
16 | +/*** |
17 | +**** |
18 | +***/ |
19 | + |
20 | +static const char * interned_str_accessible_name = NULL; |
21 | +static const char * interned_str_active = NULL; |
22 | +static const char * interned_str_always_show_image = NULL; |
23 | +static const char * interned_str_file = NULL; |
24 | +static const char * interned_str_gicon = NULL; |
25 | +static const char * interned_str_icon_name = NULL; |
26 | +static const char * interned_str_icon_set = NULL; |
27 | +static const char * interned_str_image = NULL; |
28 | +static const char * interned_str_label = NULL; |
29 | +static const char * interned_str_mask = NULL; |
30 | +static const char * interned_str_parent = NULL; |
31 | +static const char * interned_str_pixbuf_animation = NULL; |
32 | +static const char * interned_str_pixbuf = NULL; |
33 | +static const char * interned_str_pixmap = NULL; |
34 | +static const char * interned_str_sensitive = NULL; |
35 | +static const char * interned_str_stock = NULL; |
36 | +static const char * interned_str_storage_type = NULL; |
37 | +static const char * interned_str_submenu = NULL; |
38 | +static const char * interned_str_visible = NULL; |
39 | + |
40 | +static void |
41 | +ensure_interned_strings_loaded (void) |
42 | +{ |
43 | + if (G_UNLIKELY(interned_str_file == NULL)) |
44 | + { |
45 | + interned_str_accessible_name = g_intern_static_string ("accessible-name"); |
46 | + interned_str_active = g_intern_static_string ("active"); |
47 | + interned_str_always_show_image = g_intern_static_string ("always-show-image"); |
48 | + interned_str_file = g_intern_static_string ("file"); |
49 | + interned_str_gicon = g_intern_static_string ("gicon"); |
50 | + interned_str_icon_name = g_intern_static_string ("icon-name"); |
51 | + interned_str_icon_set = g_intern_static_string ("icon-set"); |
52 | + interned_str_image = g_intern_static_string ("image"); |
53 | + interned_str_label = g_intern_static_string ("label"); |
54 | + interned_str_mask = g_intern_static_string ("mask"); |
55 | + interned_str_parent = g_intern_static_string ("parent"); |
56 | + interned_str_pixbuf_animation = g_intern_static_string ("pixbuf-animation"); |
57 | + interned_str_pixbuf = g_intern_static_string ("pixbuf"); |
58 | + interned_str_pixmap = g_intern_static_string ("pixmap"); |
59 | + interned_str_sensitive = g_intern_static_string ("sensitive"); |
60 | + interned_str_stock = g_intern_static_string ("stock"); |
61 | + interned_str_storage_type = g_intern_static_string ("storage-type"); |
62 | + interned_str_submenu = g_intern_static_string ("submenu"); |
63 | + interned_str_visible = g_intern_static_string ("visible"); |
64 | + } |
65 | +} |
66 | + |
67 | +/*** |
68 | +**** |
69 | +***/ |
70 | + |
71 | /** |
72 | * dbusmenu_gtk_parse_menu_structure: |
73 | * @widget: A #GtkMenuItem or #GtkMenuShell to turn into a #DbusmenuMenuitem |
74 | @@ -163,73 +217,76 @@ |
75 | } |
76 | |
77 | static void |
78 | -parse_data_free (gpointer data) |
79 | +parser_data_free (ParserData * pdata) |
80 | { |
81 | - ParserData *pdata = (ParserData *)data; |
82 | + g_return_if_fail (pdata != NULL); |
83 | |
84 | - if (pdata != NULL && pdata->label != NULL) { |
85 | - g_signal_handlers_disconnect_matched(pdata->label, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
86 | - 0, 0, NULL, G_CALLBACK(label_notify_cb), NULL); |
87 | + if (pdata->label != NULL) { |
88 | + gint i = 0; |
89 | + i += g_signal_handlers_disconnect_matched(pdata->label, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
90 | + 0, 0, NULL, G_CALLBACK(label_notify_cb), NULL); |
91 | + g_warn_if_fail (i != 1); |
92 | g_object_remove_weak_pointer(G_OBJECT(pdata->label), (gpointer*)&pdata->label); |
93 | } |
94 | |
95 | - if (pdata != NULL && pdata->action != NULL) { |
96 | - g_signal_handlers_disconnect_matched(pdata->action, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
97 | - 0, 0, NULL, G_CALLBACK(action_notify_cb), NULL); |
98 | + if (pdata->action != NULL) { |
99 | + gint i = 0; |
100 | + i += g_signal_handlers_disconnect_matched(pdata->action, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
101 | + 0, 0, NULL, G_CALLBACK(action_notify_cb), NULL); |
102 | + g_warn_if_fail (i != 1); |
103 | g_object_remove_weak_pointer(G_OBJECT(pdata->action), (gpointer*)&pdata->action); |
104 | } |
105 | |
106 | - if (pdata != NULL && pdata->widget != NULL) { |
107 | - g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
108 | - 0, 0, NULL, G_CALLBACK(widget_notify_cb), NULL); |
109 | - g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
110 | - 0, 0, NULL, G_CALLBACK(widget_add_cb), NULL); |
111 | - g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
112 | - 0, 0, NULL, G_CALLBACK(accel_changed), NULL); |
113 | - g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
114 | - 0, 0, NULL, G_CALLBACK(checkbox_toggled), NULL); |
115 | - g_signal_handlers_disconnect_matched(pdata->widget, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
116 | - 0, 0, NULL, G_CALLBACK(menuitem_notify_cb), NULL); |
117 | - g_object_remove_weak_pointer(G_OBJECT(pdata->widget), (gpointer*)&pdata->widget); |
118 | + if (pdata->widget != NULL) { |
119 | + GObject * o = G_OBJECT(pdata->widget); |
120 | + gint i = 0; |
121 | + i += g_signal_handlers_disconnect_matched(o, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
122 | + 0, 0, NULL, G_CALLBACK(widget_notify_cb), NULL); |
123 | + i += g_signal_handlers_disconnect_matched(o, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
124 | + 0, 0, NULL, G_CALLBACK(widget_add_cb), NULL); |
125 | + i += g_signal_handlers_disconnect_matched(o, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
126 | + 0, 0, NULL, G_CALLBACK(accel_changed), NULL); |
127 | + i += g_signal_handlers_disconnect_matched(o, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
128 | + 0, 0, NULL, G_CALLBACK(checkbox_toggled), NULL); |
129 | + i += g_signal_handlers_disconnect_matched(o, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
130 | + 0, 0, NULL, G_CALLBACK(menuitem_notify_cb), NULL); |
131 | + g_warn_if_fail (i != 5); |
132 | + g_object_remove_weak_pointer(o, (gpointer*)&pdata->widget); |
133 | + /* since the DbusmenuMenuitem is being destroyed, uncache it from the GtkWidget */ |
134 | + g_object_steal_data(o, CACHED_MENUITEM); |
135 | } |
136 | |
137 | - if (pdata != NULL && pdata->shell != NULL) { |
138 | - g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
139 | - 0, 0, NULL, G_CALLBACK(item_inserted_cb), NULL); |
140 | - g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
141 | - 0, 0, NULL, G_CALLBACK(item_removed_cb), NULL); |
142 | + if (pdata->shell != NULL) { |
143 | + gint i = 0; |
144 | + i += g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
145 | + 0, 0, NULL, G_CALLBACK(item_inserted_cb), NULL); |
146 | + i += g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
147 | + 0, 0, NULL, G_CALLBACK(item_removed_cb), NULL); |
148 | + g_warn_if_fail (i != 2); |
149 | g_object_remove_weak_pointer(G_OBJECT(pdata->shell), (gpointer*)&pdata->shell); |
150 | } |
151 | |
152 | - if (pdata != NULL && pdata->image != NULL) { |
153 | - g_signal_handlers_disconnect_matched(pdata->image, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
154 | - 0, 0, NULL, G_CALLBACK(image_notify_cb), NULL); |
155 | + if (pdata->image != NULL) { |
156 | + gint i = 0; |
157 | + i += g_signal_handlers_disconnect_matched(pdata->image, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
158 | + 0, 0, NULL, G_CALLBACK(image_notify_cb), NULL); |
159 | + g_warn_if_fail (i != 1); |
160 | g_object_remove_weak_pointer(G_OBJECT(pdata->image), (gpointer*)&pdata->image); |
161 | } |
162 | |
163 | - if (pdata != NULL && pdata->accessible != NULL) { |
164 | - g_signal_handlers_disconnect_matched(pdata->accessible, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
165 | - 0, 0, NULL, G_CALLBACK(a11y_name_notify_cb), NULL); |
166 | - g_object_remove_weak_pointer(G_OBJECT(pdata->accessible), (gpointer*)&pdata->accessible); |
167 | - } |
168 | + if (pdata->accessible != NULL) { |
169 | + gint i = 0; |
170 | + i += g_signal_handlers_disconnect_matched(pdata->accessible, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, |
171 | + 0, 0, NULL, G_CALLBACK(a11y_name_notify_cb), NULL); |
172 | + g_warn_if_fail (i != 1); |
173 | + g_object_remove_weak_pointer(G_OBJECT(pdata->accessible), (gpointer*)&pdata->accessible); |
174 | + } |
175 | |
176 | g_free(pdata); |
177 | |
178 | return; |
179 | } |
180 | |
181 | -/* Called when the dbusmenu item that we're keeping around |
182 | - is finalized */ |
183 | -static void |
184 | -dbusmenu_item_freed (gpointer data, GObject * obj) |
185 | -{ |
186 | - ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); |
187 | - |
188 | - if (pdata != NULL && pdata->widget != NULL) { |
189 | - g_object_steal_data(G_OBJECT(pdata->widget), CACHED_MENUITEM); |
190 | - } |
191 | -} |
192 | - |
193 | /* Gets the positon of the child with its' parent if it has one. |
194 | Returns -1 if the position is unable to be calculated. */ |
195 | static gint |
196 | @@ -265,9 +322,7 @@ |
197 | DbusmenuMenuitem * item = dbusmenu_menuitem_new(); |
198 | |
199 | ParserData *pdata = g_new0 (ParserData, 1); |
200 | - g_object_set_data_full(G_OBJECT(item), PARSER_DATA, pdata, parse_data_free); |
201 | - |
202 | - g_object_weak_ref(G_OBJECT(item), dbusmenu_item_freed, NULL); |
203 | + g_object_set_data_full(G_OBJECT(item), PARSER_DATA, pdata, (GDestroyNotify)parser_data_free); |
204 | |
205 | pdata->widget = widget; |
206 | g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget); |
207 | @@ -558,7 +613,7 @@ |
208 | |
209 | if (GTK_IS_IMAGE (image)) |
210 | { |
211 | - update_icon (mi, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); |
212 | + update_icon (mi, pdata, GTK_IMAGE (image)); |
213 | } |
214 | } |
215 | |
216 | @@ -682,7 +737,9 @@ |
217 | GParamSpec *pspec, |
218 | gpointer data) |
219 | { |
220 | - if (pspec->name == g_intern_static_string ("visible")) |
221 | + ensure_interned_strings_loaded (); |
222 | + |
223 | + if (pspec->name == interned_str_visible) |
224 | { |
225 | GtkWidget * new_toplevel = gtk_widget_get_toplevel (widget); |
226 | GtkWidget * old_toplevel = GTK_WIDGET(data); |
227 | @@ -715,7 +772,7 @@ |
228 | } |
229 | |
230 | static void |
231 | -update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * gmenuitem, GtkImage *image) |
232 | +update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImage *image) |
233 | { |
234 | GdkPixbuf * pixbuf = NULL; |
235 | const gchar * icon_name = NULL; |
236 | @@ -724,12 +781,8 @@ |
237 | GtkIconInfo * info; |
238 | gint width; |
239 | |
240 | - /* Check to see if we're changing the image. If so, we need to track |
241 | - that little bugger */ |
242 | - /* Why check for gmenuitem being NULL? Because there are some cases where |
243 | - we can't get it easily, and those mean it's not changed just the icon |
244 | - underneith, so we can ignore these larger impacts */ |
245 | - if (image != GTK_IMAGE(pdata->image) && gmenuitem != NULL) { |
246 | + /* Check to see if we're changing the image. If so, we need to track that little bugger */ |
247 | + if (image != GTK_IMAGE(pdata->image)) { |
248 | |
249 | if (pdata->image != NULL) { |
250 | g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), menuitem); |
251 | @@ -894,10 +947,12 @@ |
252 | DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; |
253 | GValue prop_value = {0}; |
254 | |
255 | + ensure_interned_strings_loaded (); |
256 | + |
257 | g_value_init (&prop_value, pspec->value_type); |
258 | g_object_get_property (G_OBJECT (widget), pspec->name, &prop_value); |
259 | |
260 | - if (pspec->name == g_intern_static_string ("label")) |
261 | + if (pspec->name == interned_str_label) |
262 | { |
263 | gchar * text = sanitize_label (GTK_LABEL (widget)); |
264 | dbusmenu_menuitem_property_set (child, |
265 | @@ -905,7 +960,7 @@ |
266 | text); |
267 | g_free (text); |
268 | } |
269 | - else if (pspec->name == g_intern_static_string ("parent")) |
270 | + else if (pspec->name == interned_str_parent) |
271 | { |
272 | if (GTK_WIDGET (g_value_get_object (&prop_value)) == NULL) |
273 | { |
274 | @@ -929,55 +984,53 @@ |
275 | } |
276 | |
277 | static void |
278 | -image_notify_cb (GtkWidget *widget, |
279 | - GParamSpec *pspec, |
280 | - gpointer data) |
281 | +image_notify_cb (GtkWidget * image, GParamSpec * pspec, gpointer data) |
282 | { |
283 | - DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; |
284 | + ensure_interned_strings_loaded(); |
285 | |
286 | - if (pspec->name == g_intern_static_string ("file") || |
287 | - pspec->name == g_intern_static_string ("gicon") || |
288 | - pspec->name == g_intern_static_string ("icon-name") || |
289 | - pspec->name == g_intern_static_string ("icon-set") || |
290 | - pspec->name == g_intern_static_string ("image") || |
291 | - pspec->name == g_intern_static_string ("mask") || |
292 | - pspec->name == g_intern_static_string ("pixbuf") || |
293 | - pspec->name == g_intern_static_string ("pixbuf-animation") || |
294 | - pspec->name == g_intern_static_string ("pixmap") || |
295 | - pspec->name == g_intern_static_string ("stock") || |
296 | - pspec->name == g_intern_static_string ("storage-type")) |
297 | + if (pspec->name == interned_str_file || |
298 | + pspec->name == interned_str_gicon || |
299 | + pspec->name == interned_str_icon_name || |
300 | + pspec->name == interned_str_icon_set || |
301 | + pspec->name == interned_str_image || |
302 | + pspec->name == interned_str_mask || |
303 | + pspec->name == interned_str_pixbuf || |
304 | + pspec->name == interned_str_pixbuf_animation || |
305 | + pspec->name == interned_str_pixmap || |
306 | + pspec->name == interned_str_stock || |
307 | + pspec->name == interned_str_storage_type) |
308 | { |
309 | + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); |
310 | ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); |
311 | - update_icon (mi, pdata, NULL, GTK_IMAGE (widget)); |
312 | + update_icon (mi, pdata, GTK_IMAGE (image)); |
313 | } |
314 | } |
315 | |
316 | static void |
317 | -action_notify_cb (GtkAction *action, |
318 | - GParamSpec *pspec, |
319 | - gpointer data) |
320 | +action_notify_cb (GtkAction *action, GParamSpec * pspec, gpointer data) |
321 | { |
322 | - DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; |
323 | + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); |
324 | + ensure_interned_strings_loaded (); |
325 | |
326 | - if (pspec->name == g_intern_static_string ("sensitive")) |
327 | + if (pspec->name == interned_str_sensitive) |
328 | { |
329 | dbusmenu_menuitem_property_set_bool (mi, |
330 | DBUSMENU_MENUITEM_PROP_ENABLED, |
331 | gtk_action_is_sensitive (action)); |
332 | } |
333 | - else if (pspec->name == g_intern_static_string ("visible")) |
334 | + else if (pspec->name == interned_str_visible) |
335 | { |
336 | dbusmenu_menuitem_property_set_bool (mi, |
337 | DBUSMENU_MENUITEM_PROP_VISIBLE, |
338 | gtk_action_is_visible (action)); |
339 | } |
340 | - else if (pspec->name == g_intern_static_string ("active")) |
341 | + else if (pspec->name == interned_str_active) |
342 | { |
343 | dbusmenu_menuitem_property_set_int (mi, |
344 | DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, |
345 | gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); |
346 | } |
347 | - else if (pspec->name == g_intern_static_string ("label")) |
348 | + else if (pspec->name == interned_str_label) |
349 | { |
350 | gchar * text = sanitize_label_text (gtk_action_get_label (action)); |
351 | dbusmenu_menuitem_property_set (mi, |
352 | @@ -988,23 +1041,23 @@ |
353 | } |
354 | |
355 | static void |
356 | -a11y_name_notify_cb (AtkObject *accessible, |
357 | - GParamSpec *pspec, |
358 | - gpointer data) |
359 | +a11y_name_notify_cb (AtkObject * accessible, GParamSpec * pspec, gpointer data) |
360 | { |
361 | - DbusmenuMenuitem *item = (DbusmenuMenuitem *)data; |
362 | - GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); |
363 | - GtkWidget *label = find_menu_label (widget); |
364 | - const gchar *label_text = gtk_label_get_text (GTK_LABEL (label)); |
365 | - const gchar *name = atk_object_get_name (accessible); |
366 | + ensure_interned_strings_loaded (); |
367 | |
368 | /* If an application sets the accessible name to NULL, then a subsequent |
369 | * call to get the accessible name from the Atk object should return the same |
370 | * string as the text of the menu item label, in which case, we want to clear |
371 | * the accessible description property of the dbusmenu item. |
372 | */ |
373 | - if (pspec->name == g_intern_static_string ("accessible-name")) |
374 | + if (pspec->name == interned_str_accessible_name) |
375 | { |
376 | + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(data); |
377 | + GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); |
378 | + GtkWidget *label = find_menu_label (widget); |
379 | + const gchar *label_text = gtk_label_get_text (GTK_LABEL (label)); |
380 | + const gchar *name = atk_object_get_name (accessible); |
381 | + |
382 | if (!g_strcmp0 (name, label_text)) |
383 | dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, NULL); |
384 | else |
385 | @@ -1099,54 +1152,52 @@ |
386 | } |
387 | |
388 | static void |
389 | -widget_notify_cb (GtkWidget *widget, |
390 | - GParamSpec *pspec, |
391 | - gpointer data) |
392 | +widget_notify_cb (GtkWidget * widget, GParamSpec * pspec, gpointer data) |
393 | { |
394 | - DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; |
395 | GValue prop_value = {0}; |
396 | + DbusmenuMenuitem * child = DBUSMENU_MENUITEM(data); |
397 | + g_return_if_fail (child != NULL); |
398 | + |
399 | + ensure_interned_strings_loaded (); |
400 | |
401 | g_value_init (&prop_value, pspec->value_type); |
402 | g_object_get_property (G_OBJECT (widget), pspec->name, &prop_value); |
403 | |
404 | - if (pspec->name == g_intern_static_string ("sensitive")) |
405 | + if (pspec->name == interned_str_sensitive) |
406 | { |
407 | dbusmenu_menuitem_property_set_bool (child, |
408 | DBUSMENU_MENUITEM_PROP_ENABLED, |
409 | g_value_get_boolean (&prop_value)); |
410 | } |
411 | - else if (pspec->name == g_intern_static_string ("label")) |
412 | + else if (pspec->name == interned_str_label) |
413 | { |
414 | - if (handle_first_label (child)) |
415 | + if (!handle_first_label (child)) |
416 | { |
417 | - return; |
418 | + dbusmenu_menuitem_property_set (child, |
419 | + DBUSMENU_MENUITEM_PROP_LABEL, |
420 | + g_value_get_string (&prop_value)); |
421 | } |
422 | - |
423 | - dbusmenu_menuitem_property_set (child, |
424 | - DBUSMENU_MENUITEM_PROP_LABEL, |
425 | - g_value_get_string (&prop_value)); |
426 | } |
427 | - else if (pspec->name == g_intern_static_string ("visible")) |
428 | + else if (pspec->name == interned_str_visible) |
429 | { |
430 | dbusmenu_menuitem_property_set_bool (child, |
431 | DBUSMENU_MENUITEM_PROP_VISIBLE, |
432 | g_value_get_boolean (&prop_value)); |
433 | } |
434 | - else if (pspec->name == g_intern_static_string ("always-show-image")) |
435 | + else if (pspec->name == interned_str_always_show_image) |
436 | { |
437 | GtkWidget *image = NULL; |
438 | g_object_get(widget, "image", &image, NULL); |
439 | ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(child), PARSER_DATA); |
440 | - update_icon (child, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE(image)); |
441 | + update_icon (child, pdata, GTK_IMAGE(image)); |
442 | } |
443 | - else if (pspec->name == g_intern_static_string ("image")) |
444 | + else if (pspec->name == interned_str_image) |
445 | { |
446 | - GtkWidget *image; |
447 | - image = GTK_WIDGET (g_value_get_object (&prop_value)); |
448 | + GtkWidget * image = GTK_WIDGET (g_value_get_object (&prop_value)); |
449 | ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(child), PARSER_DATA); |
450 | - update_icon (child, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); |
451 | + update_icon (child, pdata, GTK_IMAGE (image)); |
452 | } |
453 | - else if (pspec->name == g_intern_static_string ("parent")) |
454 | + else if (pspec->name == interned_str_parent) |
455 | { |
456 | /* |
457 | * We probably should have added a 'remove' method to the |
458 | @@ -1166,7 +1217,7 @@ |
459 | } |
460 | } |
461 | } |
462 | - else if (pspec->name == g_intern_static_string ("submenu")) |
463 | + else if (pspec->name == interned_str_submenu) |
464 | { |
465 | /* The underlying submenu got swapped out. Let's see what it is now. */ |
466 | /* First, delete any children that may exist currently. */ |
A lot of cleanups!