diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-03 11:25:29 +0100 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-03 11:25:29 +0100 |
commit | 844e1b508be157342695aa852e81c1c3756511fd (patch) | |
tree | 11971c44ee160d35e4b773cbe5c4cdfd5437d957 | |
parent | 8a1bdd708c6bca61cc35589c132bf4bb98069a64 (diff) | |
download | libayatana-indicator-844e1b508be157342695aa852e81c1c3756511fd.tar.gz libayatana-indicator-844e1b508be157342695aa852e81c1c3756511fd.tar.bz2 libayatana-indicator-844e1b508be157342695aa852e81c1c3756511fd.zip |
IndicatorImageHelper: let's use the actual icon file if its height is less than ICON_SIZE
-rw-r--r-- | libindicator/indicator-image-helper.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index da6a4e8..dd32cb2 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -70,9 +70,23 @@ refresh_image (GtkImage * image) } if (icon_info != NULL) { - gtk_image_set_from_gicon(image, icon_names, GTK_ICON_SIZE_LARGE_TOOLBAR); + GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon_info, NULL); + + if (gdk_pixbuf_get_height(pixbuf) < ICON_SIZE) { + gtk_image_set_from_file(image, icon_filename); + } else { + gtk_image_set_from_gicon(image, icon_names, GTK_ICON_SIZE_LARGE_TOOLBAR); + } + g_object_unref (pixbuf); } else if (icon_filename != NULL) { gtk_image_set_from_file(image, icon_filename); + + gint height; + gdk_pixbuf_get_file_info(icon_filename, NULL, &height); + + if (height > ICON_SIZE) { + gtk_image_set_pixel_size(image, ICON_SIZE); + } } else if (G_IS_LOADABLE_ICON(icon_names)) { /* Build a pixbuf if needed */ GdkPixbuf * pixbuf = NULL; @@ -108,19 +122,6 @@ refresh_image (GtkImage * image) } } - /* Make sure that we load the icon at its original size, if not higher than IMAGE_SIZE */ - gint pixel_size = 0; - - if (icon_filename) { - gint height; - gdk_pixbuf_get_file_info(icon_filename, NULL, &height); - - if (height > ICON_SIZE) - pixel_size = ICON_SIZE; - } - - gtk_image_set_pixel_size(image, pixel_size); - if (icon_info != NULL) { #if GTK_CHECK_VERSION(3, 8, 0) g_object_unref(icon_info); |