From 844e1b508be157342695aa852e81c1c3756511fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 3 Mar 2014 11:25:29 +0100 Subject: IndicatorImageHelper: let's use the actual icon file if its height is less than ICON_SIZE --- libindicator/indicator-image-helper.c | 29 +++++++++++++++-------------- 1 file 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); -- cgit v1.2.3