Merge lp:~larsu/indicator-messages/show-separators into lp:indicator-messages/12.10

Proposed by Lars Karlitski
Status: Merged
Merge reported by: Lars Karlitski
Merged at revision: not available
Proposed branch: lp:~larsu/indicator-messages/show-separators
Merge into: lp:indicator-messages/12.10
Diff against target: 102 lines (+12/-21)
3 files modified
configure.ac (+1/-1)
src/indicator-messages.c (+9/-19)
src/messages-service.c (+2/-1)
To merge this branch: bzr merge lp:~larsu/indicator-messages/show-separators
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
jenkins (community) continuous-integration Needs Fixing
Review via email: mp+124298@code.launchpad.net

Commit message

Show menu separators between sections

Previously, gtk didn't support changing the menu model on an already-created
GtkMenu. Since IndicatorObject doesn't allow changing the GtkMenu it exports
to the panel, IndicatorMessages created a menu with a single section, into
which the menu from the service was inserted (and removed when the service
died). This led to seperators not being shown, because separators are only
shown between top-level sections.

Gtk now has gtk_menu_shell_bind_model, which allows us to get rid of top-level
wrapper section.

Description of the change

Show menu separators between sections. Depends on a gtk+ patch [1] which will land in gtk+ very soon.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=682831

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Jenkins failed here because the patch relies on an unreleased gtk+.

314. By Lars Karlitski

messages-services: don't call g_object_unref with NULL

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

I haven't read the GTK+ patch, but if it behaves as described here then this patch looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2012-08-31 17:49:26 +0000
+++ configure.ac 2012-09-14 07:02:18 +0000
@@ -38,7 +38,7 @@
38# Dependencies 38# Dependencies
39###########################39###########################
4040
41GTK_REQUIRED_VERSION=3.5.1241GTK_REQUIRED_VERSION=3.5.17
42GIO_UNIX_REQUIRED_VERSION=2.33.1042GIO_UNIX_REQUIRED_VERSION=2.33.10
43INDICATOR_REQUIRED_VERSION=0.3.1943INDICATOR_REQUIRED_VERSION=0.3.19
44GLIB_REQUIRED_VERSION=2.33.1044GLIB_REQUIRED_VERSION=2.33.10
4545
=== modified file 'src/indicator-messages.c'
--- src/indicator-messages.c 2012-09-05 19:04:04 +0000
+++ src/indicator-messages.c 2012-09-14 07:02:18 +0000
@@ -58,7 +58,6 @@
58 IndicatorObject parent;58 IndicatorObject parent;
59 IndicatorServiceManager * service;59 IndicatorServiceManager * service;
60 GActionGroup *actions;60 GActionGroup *actions;
61 GMenu *menu_wrapper;
62 GMenuModel *menu;61 GMenuModel *menu;
63 GtkWidget *image;62 GtkWidget *image;
64 GtkWidget *gtkmenu;63 GtkWidget *gtkmenu;
@@ -121,8 +120,7 @@
121 g_signal_connect (self->service, "connection-change",120 g_signal_connect (self->service, "connection-change",
122 G_CALLBACK (service_connection_changed), self);121 G_CALLBACK (service_connection_changed), self);
123122
124 self->menu_wrapper = g_menu_new ();123 self->gtkmenu = gtk_menu_new ();
125 self->gtkmenu = gtk_menu_new_from_model (G_MENU_MODEL (self->menu_wrapper));
126 g_object_ref_sink (self->gtkmenu);124 g_object_ref_sink (self->gtkmenu);
127125
128 self->image = g_object_ref_sink (gtk_image_new ());126 self->image = g_object_ref_sink (gtk_image_new ());
@@ -142,7 +140,6 @@
142 g_return_if_fail(self != NULL);140 g_return_if_fail(self != NULL);
143141
144 g_clear_object (&self->service);142 g_clear_object (&self->service);
145 g_clear_object (&self->menu_wrapper);
146 g_clear_object (&self->actions);143 g_clear_object (&self->actions);
147 g_clear_object (&self->menu);144 g_clear_object (&self->menu);
148 g_clear_object (&self->gtkmenu);145 g_clear_object (&self->gtkmenu);
@@ -184,8 +181,7 @@
184 g_signal_handlers_disconnect_by_func (self->menu, menu_items_changed, self);181 g_signal_handlers_disconnect_by_func (self->menu, menu_items_changed, self);
185 g_clear_object (&self->menu);182 g_clear_object (&self->menu);
186 }183 }
187 if (g_menu_model_get_n_items (G_MENU_MODEL (self->menu_wrapper)) == 1)184 gtk_menu_shell_bind_model (GTK_MENU_SHELL (self->gtkmenu), NULL, NULL, FALSE);
188 g_menu_remove (self->menu_wrapper, 0);
189185
190 if (connected == FALSE)186 if (connected == FALSE)
191 return;187 return;
@@ -308,14 +304,11 @@
308304
309 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);305 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);
310 if (popup) {306 if (popup) {
311 GMenuItem *item;307 gtk_menu_shell_bind_model (GTK_MENU_SHELL (self->gtkmenu),
312308 popup,
313 item = g_menu_item_new_section (NULL, popup);309 get_name_hint (INDICATOR_OBJECT (self)),
314 g_menu_item_set_attribute (item, "action-namespace",310 TRUE);
315 "s", get_name_hint (INDICATOR_OBJECT (self)));311
316 g_menu_append_item (self->menu_wrapper, item);
317
318 g_object_unref (item);
319 g_object_unref (popup);312 g_object_unref (popup);
320 }313 }
321}314}
@@ -331,13 +324,10 @@
331324
332 g_return_if_fail (position == 0);325 g_return_if_fail (position == 0);
333326
334 if (added == 1) {327 if (added == 1)
335 indicator_messages_add_toplevel_menu (self);328 indicator_messages_add_toplevel_menu (self);
336 }329 else if (removed == 1)
337 else if (removed == 1) {
338 g_menu_remove (self->menu_wrapper, 0);
339 indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE);330 indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE);
340 }
341}331}
342332
343static void333static void
344334
=== modified file 'src/messages-service.c'
--- src/messages-service.c 2012-09-06 13:14:00 +0000
+++ src/messages-service.c 2012-09-14 07:02:18 +0000
@@ -132,7 +132,8 @@
132 g_menu_insert_section (menu, 0, NULL, chat_section);132 g_menu_insert_section (menu, 0, NULL, chat_section);
133 }133 }
134134
135 g_object_unref (first_section);135 if (first_section != NULL)
136 g_object_unref (first_section);
136}137}
137138
138static void139static void

Subscribers

People subscribed via source and target branches