aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-12 14:42:07 -0500
committerTed Gould <ted@gould.cx>2010-08-12 14:42:07 -0500
commitccf75cad2e171b9cb2683a02fbb7276371cde40e (patch)
tree848d21daf223a3446bbfb197321faa44f8471edf /libindicator
parent13ebc6ddcc71a2594f06f00f36e4ed5ab7414a3b (diff)
parent94a94652592cab71ec64f75cca04e9b9052d05db (diff)
downloadlibayatana-indicator-ccf75cad2e171b9cb2683a02fbb7276371cde40e.tar.gz
libayatana-indicator-ccf75cad2e171b9cb2683a02fbb7276371cde40e.tar.bz2
libayatana-indicator-ccf75cad2e171b9cb2683a02fbb7276371cde40e.zip
* New upstream release.
* Allowing absolute paths in the image name (LP: #564034)
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/Makefile.in2
-rw-r--r--libindicator/indicator-image-helper.c34
2 files changed, 25 insertions, 11 deletions
diff --git a/libindicator/Makefile.in b/libindicator/Makefile.in
index ebe7648..0dddfe0 100644
--- a/libindicator/Makefile.in
+++ b/libindicator/Makefile.in
@@ -202,6 +202,8 @@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SED = @SED@
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);