From 12ab8f4476b500c21747514cfbec272d0cbd5ada Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 10 Mar 2010 16:14:46 -0600 Subject: If we get an icon that is too big, we have to scale it. --- libindicator/indicator-image-helper.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 76ac3c2..53776c4 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -1,4 +1,5 @@ +#include #include "indicator-image-helper.h" const gchar * INDICATOR_NAMES_DATA = "indicator-names-data"; @@ -50,6 +51,16 @@ refresh_image (GtkImage * image) return; } + /* Scale icon if all we get is something too big. */ + if (gdk_pixbuf_get_height(pixbuf) > icon_size) { + gfloat scale = (gfloat)icon_size / (gfloat)gdk_pixbuf_get_height(pixbuf); + gint width = round(gdk_pixbuf_get_width(pixbuf) * scale); + + GdkPixbuf * scaled = gdk_pixbuf_scale_simple(pixbuf, width, icon_size, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(pixbuf)); + pixbuf = scaled; + } + /* Put the pixbuf on the image */ gtk_image_set_from_pixbuf(image, pixbuf); g_object_unref(G_OBJECT(pixbuf)); -- cgit v1.2.3