diff options
author | Ted Gould <ted@gould.cx> | 2012-02-23 00:00:41 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-02-23 00:00:41 -0600 |
commit | 8dc3a0013a6fd0d8ab54edf0944f842da751c4e7 (patch) | |
tree | 6fd29cf2911bd992ab436cf5cf02e34f05dbfe16 /libdbusmenu-gtk | |
parent | aeee68e0dd671630e9d1ffa4c8bee5dd78db2066 (diff) | |
parent | 3a9221c21feb1701119db5079bf3e350c0cb0aac (diff) | |
download | libdbusmenu-8dc3a0013a6fd0d8ab54edf0944f842da751c4e7.tar.gz libdbusmenu-8dc3a0013a6fd0d8ab54edf0944f842da751c4e7.tar.bz2 libdbusmenu-8dc3a0013a6fd0d8ab54edf0944f842da751c4e7.zip |
Import upstream version 0.5.92
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 098de67..435c808 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; } @@ -123,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; @@ -205,6 +209,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 +318,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 |