aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));