[Xfce4-commits] <ristretto:ristretto-0.0> honor thumbnail dimensions in the thumbnail-bar

Stephan Arts noreply at xfce.org
Sun Oct 23 19:17:46 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to 609d230ce3dad3b9d51d67858ea88dce0e79d5ee (commit)
       from 08a57e5f3c7c487d909059e85f46129bfa91c6a2 (commit)

commit 609d230ce3dad3b9d51d67858ea88dce0e79d5ee
Author: Stephan Arts <stephan at xfce.org>
Date:   Sat Jun 6 18:06:03 2009 +0200

    honor thumbnail dimensions in the thumbnail-bar

 src/thumbnail.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/thumbnail.c b/src/thumbnail.c
index 1a5de6b..8609b21 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -162,6 +162,8 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
 
     GtkStateType state = GTK_WIDGET_STATE(widget);
     GdkPixbuf *pixbuf;
+    guint pixbuf_height = 0;
+    guint pixbuf_width = 0;
 
     if(thumb->priv->image)
     {
@@ -193,7 +195,21 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
 
         if(pixbuf)
         {
-            pixbuf = gdk_pixbuf_scale_simple (pixbuf, widget->allocation.width, widget->allocation.height, GDK_INTERP_BILINEAR);
+            pixbuf_height = gdk_pixbuf_get_height (pixbuf);
+            pixbuf_width = gdk_pixbuf_get_width (pixbuf);
+
+            if (pixbuf_height > pixbuf_width)
+            {
+                pixbuf_width = widget->allocation.height * pixbuf_width / pixbuf_height;
+                pixbuf_height = widget->allocation.height;
+            }
+            else
+            {
+                pixbuf_height = widget->allocation.width * pixbuf_height / pixbuf_width;
+                pixbuf_width = widget->allocation.width;
+            }
+
+            pixbuf = gdk_pixbuf_scale_simple (pixbuf, pixbuf_width, pixbuf_height, GDK_INTERP_BILINEAR);
             gdk_draw_pixbuf(GDK_DRAWABLE(widget->window),
                             NULL,
                             pixbuf,


More information about the Xfce4-commits mailing list