--- src/xfdesktop-app-menu-item.c 2012-04-28 22:53:05.000000000 +0200 +++ src/xfdesktop-app-menu-item.c 2013-01-14 23:00:22.000000000 +0100 @@ -28,6 +28,10 @@ #include #endif +#ifdef HAVE_MATH_H +#include +#endif + #include #include @@ -170,6 +174,9 @@ { const gchar *icon_name; gint w, h, size; + gint src_w, src_h; + gdouble wratio, hratio; + GdkPixbuf *dest; GdkPixbuf *pixbuf = NULL; GtkWidget *image; GtkIconTheme *icon_theme; @@ -183,7 +190,34 @@ size = MIN(w, h); if (g_path_is_absolute (icon_name)) { - pixbuf = gdk_pixbuf_new_from_file_at_scale(icon_name, w, h, TRUE, NULL); + pixbuf = gdk_pixbuf_new_from_file(icon_name, NULL); + + /* scale the pixbuf if required */ + if (G_LIKELY (pixbuf != NULL)) + { + src_w = gdk_pixbuf_get_width (pixbuf); + src_h = gdk_pixbuf_get_height (pixbuf); + + if (src_w > w || src_h > h) + { + /* calculate the new dimensions */ + wratio = (gdouble) src_w / (gdouble) size; + hratio = (gdouble) src_h / (gdouble) size; + + if (hratio > wratio) + w = rint (src_w / hratio); + else + h = rint (src_h / wratio); + + dest = gdk_pixbuf_scale_simple (pixbuf, + MAX (w, 1), + MAX (h, 1), + GDK_INTERP_BILINEAR); + + g_object_unref (G_OBJECT (pixbuf)); + pixbuf = dest; + } + } } else { icon_theme = gtk_icon_theme_get_default(); pixbuf = gtk_icon_theme_load_icon(icon_theme, icon_name, size, 0, NULL);