From 0c3006bfaac388b88b2597e0959e0ded3bd7be96 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 22 Feb 2012 12:02:01 +0200 Subject: 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. --- libdbusmenu-gtk/genericmenuitem.c | 28 ++++++++++------------------ tests/test-gtk-submenu-server.c | 1 + 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 098de67..bdbd190 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -43,6 +43,7 @@ struct _GenericmenuitemPrivate { GenericmenuitemCheckType check_type; GenericmenuitemState state; GenericmenuitemDisposition disposition; + gchar * label_text; }; /* Private macro */ @@ -106,6 +107,7 @@ genericmenuitem_init (Genericmenuitem *self) self->priv->check_type = GENERICMENUITEM_CHECK_TYPE_NONE; self->priv->state = GENERICMENUITEM_STATE_UNCHECKED; self->priv->disposition = GENERICMENUITEM_DISPOSITION_NORMAL; + self->priv->label_text = NULL; return; } @@ -205,6 +207,12 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) { if (in_label == NULL) return; + Genericmenuitem * item = GENERICMENUITEM(menu_item); + if (in_label != item->priv->label_text) { + g_free (item->priv->label_text); + item->priv->label_text = g_strdup(in_label); + } + /* Build a label that might include the colors of the disposition so that it gets rendered in the menuitem. */ gchar * local_label = NULL; @@ -308,25 +316,9 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) static const gchar * get_label (GtkMenuItem * menu_item) { - GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); - GtkLabel * labelw = NULL; - - /* Try to find if we have a label already */ - if (child != NULL) { - if (GTK_IS_LABEL(child)) { - /* We've got a label, let's update it. */ - labelw = GTK_LABEL(child); - } else if (GTK_IS_BOX(child)) { - /* Look for the label in the box */ - gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); - } - } - - if (labelw != NULL) { - return gtk_label_get_label(labelw); - } + Genericmenuitem * item = GENERICMENUITEM(menu_item); - return NULL; + return item->priv->label_text; } /* Make sure we don't toggle when there is an diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index 9c4d7d4..1d38a44 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -64,6 +64,7 @@ on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) DbusmenuMenuitem * item; item = add_item(root, "Folder 1"); + dbusmenu_menuitem_property_set(item, "disposition", "alert"); add_item(item, "1.1"); add_item(item, "1.2"); add_item(item, "1.3"); -- cgit v1.2.3 From 1d4ba72aceeb1ca0e65154cb969d95756e9163ca Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 22 Feb 2012 12:19:05 +0200 Subject: Do not leak the label text Also, fix the indentation from the previous commit. --- libdbusmenu-gtk/genericmenuitem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index bdbd190..435c808 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -125,6 +125,8 @@ genericmenuitem_dispose (GObject *object) static void genericmenuitem_finalize (GObject *object) { + Genericmenuitem * self = GENERICMENUITEM(object); + g_free(self->priv->label_text); G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); return; @@ -209,7 +211,7 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) Genericmenuitem * item = GENERICMENUITEM(menu_item); if (in_label != item->priv->label_text) { - g_free (item->priv->label_text); + g_free(item->priv->label_text); item->priv->label_text = g_strdup(in_label); } -- cgit v1.2.3 From fff9cc9a74a4dff4a424f3da3f2d6e82ff4266b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 22 Feb 2012 23:55:58 -0600 Subject: Removing this test as it doesn't work properly with GTK currently --- tests/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index db2d469..6824c1c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,8 +25,10 @@ TESTS += \ test-gtk-label \ test-gtk-shortcut \ test-gtk-reorder \ - test-gtk-submenu \ test-gtk-parser-test +# Not working with GTK3 and a critical grab that is in +# the GTK3 code. +# test-gtk-submenu endif # The Python test only work on the system copy of -- cgit v1.2.3 From 3a9221c21feb1701119db5079bf3e350c0cb0aac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 22 Feb 2012 23:56:07 -0600 Subject: 0.5.92 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index aef35a0..274875f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.5.91, ted@canonical.com) +AC_INIT(libdbusmenu, 0.5.92, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.5.91, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.5.92, [-Wno-portability]) AM_MAINTAINER_MODE @@ -165,7 +165,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=4 -LIBDBUSMENU_REVISION=8 +LIBDBUSMENU_REVISION=9 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3