[Xfce4-commits] <xfce4-panel:andrzejr/wrapper3> PanelImage: better support for non-square icons.

Andrzej noreply at xfce.org
Mon Aug 26 00:26:04 CEST 2013


Updating branch refs/heads/andrzejr/wrapper3
         to 87ce7cdb2d348715d90793c563d7a747114f69e8 (commit)
       from 50462009c0fa6ab1097f393dee97042b1be4471e (commit)

commit 87ce7cdb2d348715d90793c563d7a747114f69e8
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