Merge lp:~mardy/libdbusmenu/lp937829 into lp:libdbusmenu/0.6

Proposed by Alberto Mardegan
Status: Merged
Approved by: Ted Gould
Approved revision: 376
Merged at revision: 375
Proposed branch: lp:~mardy/libdbusmenu/lp937829
Merge into: lp:libdbusmenu/0.6
Diff against target: 82 lines (+14/-19)
2 files modified
libdbusmenu-gtk/genericmenuitem.c (+13/-19)
tests/test-gtk-submenu-server.c (+1/-0)
To merge this branch: bzr merge lp:~mardy/libdbusmenu/lp937829
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
DBus Menu Team Pending
Review via email: mp+94111@code.launchpad.net

Commit message

Do not read the label text from the label widget

The label text stored in the widget might have been modified with markup.
Instead of reading it back from the widget, return the text as set by the
client, unmodified.

Alter the test-gtk-submenu so that the correct behaviour is checked for.

Description of the change

Do not read the label text from the label widget

The label text stored in the widget might have been modified with markup.
Instead of reading it back from the widget, return the text as set by the
client, unmodified.

Alter the test-gtk-submenu so that the correct behaviour is checked for.

To post a comment you must log in.
lp:~mardy/libdbusmenu/lp937829 updated
376. By Alberto Mardegan

Do not leak the label text

Also, fix the indentation from the previous commit.

Revision history for this message
Ted Gould (ted) wrote :

Works for me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/genericmenuitem.c'
2--- libdbusmenu-gtk/genericmenuitem.c 2012-01-16 11:57:11 +0000
3+++ libdbusmenu-gtk/genericmenuitem.c 2012-02-22 10:22:17 +0000
4@@ -43,6 +43,7 @@
5 GenericmenuitemCheckType check_type;
6 GenericmenuitemState state;
7 GenericmenuitemDisposition disposition;
8+ gchar * label_text;
9 };
10
11 /* Private macro */
12@@ -106,6 +107,7 @@
13 self->priv->check_type = GENERICMENUITEM_CHECK_TYPE_NONE;
14 self->priv->state = GENERICMENUITEM_STATE_UNCHECKED;
15 self->priv->disposition = GENERICMENUITEM_DISPOSITION_NORMAL;
16+ self->priv->label_text = NULL;
17
18 return;
19 }
20@@ -123,6 +125,8 @@
21 static void
22 genericmenuitem_finalize (GObject *object)
23 {
24+ Genericmenuitem * self = GENERICMENUITEM(object);
25+ g_free(self->priv->label_text);
26
27 G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object);
28 return;
29@@ -205,6 +209,12 @@
30 {
31 if (in_label == NULL) return;
32
33+ Genericmenuitem * item = GENERICMENUITEM(menu_item);
34+ if (in_label != item->priv->label_text) {
35+ g_free(item->priv->label_text);
36+ item->priv->label_text = g_strdup(in_label);
37+ }
38+
39 /* Build a label that might include the colors of the disposition
40 so that it gets rendered in the menuitem. */
41 gchar * local_label = NULL;
42@@ -308,25 +318,9 @@
43 static const gchar *
44 get_label (GtkMenuItem * menu_item)
45 {
46- GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item));
47- GtkLabel * labelw = NULL;
48-
49- /* Try to find if we have a label already */
50- if (child != NULL) {
51- if (GTK_IS_LABEL(child)) {
52- /* We've got a label, let's update it. */
53- labelw = GTK_LABEL(child);
54- } else if (GTK_IS_BOX(child)) {
55- /* Look for the label in the box */
56- gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw);
57- }
58- }
59-
60- if (labelw != NULL) {
61- return gtk_label_get_label(labelw);
62- }
63-
64- return NULL;
65+ Genericmenuitem * item = GENERICMENUITEM(menu_item);
66+
67+ return item->priv->label_text;
68 }
69
70 /* Make sure we don't toggle when there is an
71
72=== modified file 'tests/test-gtk-submenu-server.c'
73--- tests/test-gtk-submenu-server.c 2010-11-17 04:04:47 +0000
74+++ tests/test-gtk-submenu-server.c 2012-02-22 10:22:17 +0000
75@@ -64,6 +64,7 @@
76
77 DbusmenuMenuitem * item;
78 item = add_item(root, "Folder 1");
79+ dbusmenu_menuitem_property_set(item, "disposition", "alert");
80 add_item(item, "1.1");
81 add_item(item, "1.2");
82 add_item(item, "1.3");

Subscribers

People subscribed via source and target branches