aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-12 14:37:24 -0500
committerTed Gould <ted@gould.cx>2010-08-12 14:37:24 -0500
commite9c09c5412fb27a51e87397d7a229e266864a6c0 (patch)
tree291600bb51034080a65cba7cc758635779c81519 /libindicator
parent362a2d76391c48ab73538bc5c2106d00ec481c7f (diff)
parentbec9f56f7d1eae4f1cdcecf572babfec58e72d32 (diff)
downloadlibayatana-indicator-e9c09c5412fb27a51e87397d7a229e266864a6c0.tar.gz
libayatana-indicator-e9c09c5412fb27a51e87397d7a229e266864a6c0.tar.bz2
libayatana-indicator-e9c09c5412fb27a51e87397d7a229e266864a6c0.zip
Allowing for absolute file names for icons.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-image-helper.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c
index 2492227..6b11f6f 100644
--- a/libindicator/indicator-image-helper.c
+++ b/libindicator/indicator-image-helper.c
@@ -30,6 +30,9 @@ static void
refresh_image (GtkImage * image)
{
g_return_if_fail(GTK_IS_IMAGE(image));
+ const gchar * icon_filename = NULL;
+ GtkIconInfo * icon_info = NULL;
+ gint icon_size = 22;
GIcon * icon_names = (GIcon *)g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA);
g_return_if_fail(icon_names != NULL);
@@ -38,23 +41,30 @@ refresh_image (GtkImage * image)
GtkIconTheme * default_theme = gtk_icon_theme_get_default();
g_return_if_fail(default_theme != NULL);
- gint icon_size = 22;
-
/* Look through the themes for that icon */
- GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
+ icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
if (icon_info == NULL) {
- g_warning("Unable to find icon in theme.");
- return;
+ /* Try using the second item in the names, which should be the original filename supplied */
+ const gchar * const * names = g_themed_icon_get_names(G_THEMED_ICON( icon_names ));
+ if (names) {
+ icon_filename = names[1];
+ } else {
+ g_warning("Unable to find icon\n");
+ return;
+ }
+ } else {
+ /* Grab the filename */
+ icon_filename = gtk_icon_info_get_filename(icon_info);
}
-
- /* Grab the filename */
- const gchar * icon_filename = gtk_icon_info_get_filename(icon_info);
- g_return_if_fail(icon_filename != NULL); /* An error because we shouldn't get info without a filename */
+ g_return_if_fail(icon_filename != NULL); /* An error because we don't have a filename */
/* Build a pixbuf */
GError * error = NULL;
GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);
- gtk_icon_info_free(icon_info);
+
+ if (icon_info != NULL) {
+ gtk_icon_info_free(icon_info);
+ }
if (pixbuf == NULL) {
g_error("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
@@ -126,12 +136,14 @@ indicator_image_helper_update (GtkImage * image, const gchar * name)
g_return_if_fail(name != NULL);
g_return_if_fail(name[0] != '\0');
g_return_if_fail(image != NULL);
+ gboolean seen_previously = FALSE;
/* Build us a GIcon */
GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name);
+ g_warn_if_fail(icon_names != NULL);
g_return_if_fail(icon_names != NULL);
- gboolean seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
+ seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
/* Attach our names to the image */
g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref);