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
1=== modified file 'configure.ac'
2--- configure.ac 2012-08-31 17:49:26 +0000
3+++ configure.ac 2012-09-14 07:02:18 +0000
4@@ -38,7 +38,7 @@
5 # Dependencies
6 ###########################
7
8-GTK_REQUIRED_VERSION=3.5.12
9+GTK_REQUIRED_VERSION=3.5.17
10 GIO_UNIX_REQUIRED_VERSION=2.33.10
11 INDICATOR_REQUIRED_VERSION=0.3.19
12 GLIB_REQUIRED_VERSION=2.33.10
13
14=== modified file 'src/indicator-messages.c'
15--- src/indicator-messages.c 2012-09-05 19:04:04 +0000
16+++ src/indicator-messages.c 2012-09-14 07:02:18 +0000
17@@ -58,7 +58,6 @@
18 IndicatorObject parent;
19 IndicatorServiceManager * service;
20 GActionGroup *actions;
21- GMenu *menu_wrapper;
22 GMenuModel *menu;
23 GtkWidget *image;
24 GtkWidget *gtkmenu;
25@@ -121,8 +120,7 @@
26 g_signal_connect (self->service, "connection-change",
27 G_CALLBACK (service_connection_changed), self);
28
29- self->menu_wrapper = g_menu_new ();
30- self->gtkmenu = gtk_menu_new_from_model (G_MENU_MODEL (self->menu_wrapper));
31+ self->gtkmenu = gtk_menu_new ();
32 g_object_ref_sink (self->gtkmenu);
33
34 self->image = g_object_ref_sink (gtk_image_new ());
35@@ -142,7 +140,6 @@
36 g_return_if_fail(self != NULL);
37
38 g_clear_object (&self->service);
39- g_clear_object (&self->menu_wrapper);
40 g_clear_object (&self->actions);
41 g_clear_object (&self->menu);
42 g_clear_object (&self->gtkmenu);
43@@ -184,8 +181,7 @@
44 g_signal_handlers_disconnect_by_func (self->menu, menu_items_changed, self);
45 g_clear_object (&self->menu);
46 }
47- if (g_menu_model_get_n_items (G_MENU_MODEL (self->menu_wrapper)) == 1)
48- g_menu_remove (self->menu_wrapper, 0);
49+ gtk_menu_shell_bind_model (GTK_MENU_SHELL (self->gtkmenu), NULL, NULL, FALSE);
50
51 if (connected == FALSE)
52 return;
53@@ -308,14 +304,11 @@
54
55 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);
56 if (popup) {
57- GMenuItem *item;
58-
59- item = g_menu_item_new_section (NULL, popup);
60- g_menu_item_set_attribute (item, "action-namespace",
61- "s", get_name_hint (INDICATOR_OBJECT (self)));
62- g_menu_append_item (self->menu_wrapper, item);
63-
64- g_object_unref (item);
65+ gtk_menu_shell_bind_model (GTK_MENU_SHELL (self->gtkmenu),
66+ popup,
67+ get_name_hint (INDICATOR_OBJECT (self)),
68+ TRUE);
69+
70 g_object_unref (popup);
71 }
72 }
73@@ -331,13 +324,10 @@
74
75 g_return_if_fail (position == 0);
76
77- if (added == 1) {
78+ if (added == 1)
79 indicator_messages_add_toplevel_menu (self);
80- }
81- else if (removed == 1) {
82- g_menu_remove (self->menu_wrapper, 0);
83+ else if (removed == 1)
84 indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE);
85- }
86 }
87
88 static void
89
90=== modified file 'src/messages-service.c'
91--- src/messages-service.c 2012-09-06 13:14:00 +0000
92+++ src/messages-service.c 2012-09-14 07:02:18 +0000
93@@ -132,7 +132,8 @@
94 g_menu_insert_section (menu, 0, NULL, chat_section);
95 }
96
97- g_object_unref (first_section);
98+ if (first_section != NULL)
99+ g_object_unref (first_section);
100 }
101
102 static void

Subscribers

People subscribed via source and target branches