diff options
author | Andrzej <ndrwrdck@gmail.com> | 2013-04-03 22:33:51 +0100 |
---|---|---|
committer | Felipe Contreras <felipe.contreras@gmail.com> | 2013-10-09 16:28:48 -0500 |
commit | 141adddcf22d27a5eb274d341f2d3e3dec89a8a1 (patch) | |
tree | bc4a4cd31122bc2017756219f026778da00c21fb /libxfce4panel | |
parent | e95bed2192836d5501427a20b3378801ba1c9677 (diff) |
Bugfix in icon/pixbuf resizing code.
Icons were occasionally stretched to unnatural aspect ratio.
This could be observed e.g. in applications menu plugin in multi-row
panels and/or non-square icons.
Diffstat (limited to 'libxfce4panel')
-rw-r--r-- | libxfce4panel/xfce-panel-convenience.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c index a3f3be18..79023608 100644 --- a/libxfce4panel/xfce-panel-convenience.c +++ b/libxfce4panel/xfce-panel-convenience.c @@ -158,7 +158,7 @@ xfce_panel_pixbuf_from_source_at_size (const gchar *source, gchar *name; gchar *filename; gint src_w, src_h; - gdouble wratio, hratio; + gdouble ratio; GdkPixbuf *dest; GError *error = NULL; gint size = MIN (dest_width, dest_height); @@ -231,13 +231,11 @@ xfce_panel_pixbuf_from_source_at_size (const gchar *source, if (src_w > dest_width || src_h > dest_height) { /* calculate the new dimensions */ - wratio = (gdouble) src_w / (gdouble) size; - hratio = (gdouble) src_h / (gdouble) size; + ratio = MIN ((gdouble) dest_width / (gdouble) src_w, + (gdouble) dest_height / (gdouble) src_h); - if (hratio > wratio) - dest_width = rint (src_w / hratio); - else - dest_height = rint (src_h / wratio); + dest_width = rint (src_w * ratio); + dest_height = rint (src_h * ratio); dest = gdk_pixbuf_scale_simple (pixbuf, MAX (dest_width, 1), |