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

Andrzej noreply at xfce.org
Mon Apr 15 02:20:01 CEST 2013


Updating branch refs/heads/nick/gtk3
         to e4e4a6a7783f4a3f5b6e13b88e3edc1e12b21936 (commit)
       from 60807d194f64eac5782244f30c29596eae643aff (commit)

commit e4e4a6a7783f4a3f5b6e13b88e3edc1e12b21936
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 files 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