[Xfce4-commits] <xfce4-panel:master> PanelImage: better support for non-square icons.
Nick Schermer
noreply at xfce.org
Sat Nov 30 17:12:11 CET 2013
Updating branch refs/heads/master
to e98950b9e5309de21f59305151e6f0028d0c8d5e (commit)
from 0c99581be09ea220ffee83cf749780893bf513fc (commit)
commit e98950b9e5309de21f59305151e6f0028d0c8d5e
Author: Andrzej <ndrwrdck at gmail.com>
Date: Mon Apr 15 00:09:06 2013 +0100
PanelImage: better support for non-square icons.
I thought this might be the reason for panel buttons growing infinitely.
It turned out to be something different but this change still improves
the sizing and makes it consistent with xfce_panel_pixbuf_from_source_at_size.
libxfce4panel/xfce-panel-image.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index b5afae6..7acb239 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -669,8 +669,7 @@ xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
gint dest_width,
gint dest_height)
{
- gdouble wratio;
- gdouble hratio;
+ gdouble ratio;
gint source_width;
gint source_height;
@@ -688,13 +687,12 @@ xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
return g_object_ref (G_OBJECT (source));
/* calculate the new dimensions */
- wratio = (gdouble) source_width / (gdouble) dest_width;
- hratio = (gdouble) source_height / (gdouble) dest_height;
- if (hratio > wratio)
- dest_width = rint (source_width / hratio);
- else
- dest_height = rint (source_height / wratio);
+ ratio = MIN ((gdouble) dest_width / (gdouble) source_width,
+ (gdouble) dest_height / (gdouble) source_height);
+
+ dest_width = rint (source_width * ratio);
+ dest_height = rint (source_height * ratio);
return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1),
MAX (dest_height, 1),
More information about the Xfce4-commits
mailing list