From b0d252aed4071e95a648fbcf9f102f816fbd1725 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Mar 2010 16:24:26 -0500 Subject: Flipping things around a little bit so that if we get an error, we'll still build the default icon. --- src/indicator-session.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 10e8684..57ead25 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -243,11 +243,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0 || !g_file_test(icon_name, G_FILE_TEST_EXISTS)) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); - usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); - g_object_unref(gicon); - } else { + if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) != 0 && g_file_test(icon_name, G_FILE_TEST_EXISTS)) { gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); @@ -256,10 +252,18 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl if (error == NULL) { usericon = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); } else { + g_warning("Unable to load user icon '%s': %s", icon_name, error->message); g_error_free(error); } } + + if (usericon == NULL) { + GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); + usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); + g_object_unref(gicon); + } } if (usericon != NULL) { gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); -- cgit v1.2.3