diff options
author | Ted Gould <ted@gould.cx> | 2009-12-16 16:26:49 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2009-12-16 16:26:49 -0600 |
commit | 4cc0915b394bb63dad3018d342d4baf57fd215f0 (patch) | |
tree | 6fe922657f698b25e3096b6fe2c612c279049efb | |
parent | cd561a9dad4d1d82e5c03fc89780130cc75ece01 (diff) | |
download | libdbusmenu-4cc0915b394bb63dad3018d342d4baf57fd215f0.tar.gz libdbusmenu-4cc0915b394bb63dad3018d342d4baf57fd215f0.tar.bz2 libdbusmenu-4cc0915b394bb63dad3018d342d4baf57fd215f0.zip |
Switching the client over to creating generic items.
-rw-r--r-- | libdbusmenu-gtk/client.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 66862d3..325399d 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client.h" #include "menuitem.h" +#include "genericmenuitem.h" /* Prototypes */ static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass); @@ -362,8 +363,8 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu /* Note: not checking parent, it's reasonable for it to be NULL */ GtkMenuItem * gmi; - gmi = GTK_MENU_ITEM(gtk_menu_item_new_with_label(dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL))); - gtk_menu_item_set_use_underline (gmi, TRUE); + gmi = GTK_MENU_ITEM(g_object_new(GENERICMENUITEM_TYPE, NULL)); + gtk_menu_item_set_label(gmi, dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL)); if (gmi != NULL) { dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -416,7 +417,12 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV { /* We're only looking at these two properties here */ g_return_if_fail(!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON) || !g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)); - const gchar * value = g_value_get_string(invalue); + + const gchar * value = NULL; + + if (invalue != NULL && G_VALUE_TYPE(invalue) == G_TYPE_STRING) { + value = g_value_get_string(invalue); + } if (value == NULL || value[0] == '\0') { /* This means that we're unsetting a value. */ @@ -435,12 +441,12 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV g_warning("Oddly we're handling image properties on a menuitem that doesn't have any GTK structures associated with it."); return; } - GtkWidget * gtkimage = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gimi)); + GtkWidget * gtkimage = genericmenuitem_get_image(GENERICMENUITEM(gimi)); if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)) { /* If we have an image already built from a name that is way better than a pixbuf. Keep it. */ - if (gtk_image_get_storage_type(GTK_IMAGE(gtkimage)) == GTK_IMAGE_ICON_NAME) { + if (gtkimage != NULL && gtk_image_get_storage_type(GTK_IMAGE(gtkimage)) == GTK_IMAGE_ICON_NAME) { return; } } @@ -493,7 +499,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV } - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gimi), gtkimage); + genericmenuitem_set_image(GENERICMENUITEM(gimi), gtkimage); return; } |