aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-10 16:14:46 -0600
committerTed Gould <ted@gould.cx>2010-03-10 16:14:46 -0600
commit12ab8f4476b500c21747514cfbec272d0cbd5ada (patch)
tree383eb822ab3f95b3daae5fb8458ba8dd60b45c18 /libindicator
parent37f0f3400bce36b98e89595bdbb694bec7139ee2 (diff)
downloadlibayatana-indicator-12ab8f4476b500c21747514cfbec272d0cbd5ada.tar.gz
libayatana-indicator-12ab8f4476b500c21747514cfbec272d0cbd5ada.tar.bz2
libayatana-indicator-12ab8f4476b500c21747514cfbec272d0cbd5ada.zip
If we get an icon that is too big, we have to scale it.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-image-helper.c11
1 files changed, 11 insertions, 0 deletions
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 <math.h>
#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));