[Xfce4-commits] <xfce4-panel:nick/gtk3> PanelImage: fixes to previous commit and cleanup.

Andrzej noreply at xfce.org
Tue Apr 16 00:36:01 CEST 2013


Updating branch refs/heads/nick/gtk3
         to e8ca9eea79ee65068edc43b8fc4b2236833de8c8 (commit)
       from 24bb01b13ddc57b77e6ddf14900a70f801d2c958 (commit)

commit e8ca9eea79ee65068edc43b8fc4b2236833de8c8
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Mon Apr 15 23:31:45 2013 +0100

    PanelImage: fixes to previous commit and cleanup.
    
    Correction has to be done in all cases, not only when the requested
    size is derived from allocation.

 libxfce4panel/xfce-panel-image.c |   46 +++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index 6d9687d..5d17419 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -116,10 +116,10 @@ static void       xfce_panel_image_set_property         (GObject         *object
 static void       xfce_panel_image_finalize             (GObject         *object);
 #if GTK_CHECK_VERSION (3, 0, 0)
 static void       xfce_panel_image_get_preferred_width  (GtkWidget       *widget,
-                                                         gint            *minimal_width,
+                                                         gint            *minimum_width,
                                                          gint            *natural_width);
 static void       xfce_panel_image_get_preferred_height (GtkWidget       *widget,
-                                                         gint            *minimal_height,
+                                                         gint            *minimum_height,
                                                          gint            *natural_height);
 #else
 static void       xfce_panel_image_size_request         (GtkWidget       *widget,
@@ -353,52 +353,64 @@ xfce_panel_image_padding_correction (GtkWidget *widget)
 #if GTK_CHECK_VERSION (3, 0, 0)
 static void
 xfce_panel_image_get_preferred_width (GtkWidget *widget,
-                                      gint      *minimal_width,
+                                      gint      *minimum_width,
                                       gint      *natural_width)
 {
   XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
   GtkAllocation          alloc;
+  gint                   width;
 
   if (priv->size > 0)
-    *minimal_width = priv->size;
+    width = priv->size;
   else if (priv->pixbuf != NULL)
-    *minimal_width = gdk_pixbuf_get_width (priv->pixbuf);
+    width = gdk_pixbuf_get_width (priv->pixbuf);
   else
     {
       gtk_widget_get_allocation (widget, &alloc);
+      width = alloc.width;
+    }
+
 #ifdef GTK_BUTTON_SIZING_FIX
-      alloc.width -= xfce_panel_image_padding_correction (widget);
+  width -= xfce_panel_image_padding_correction (widget);
 #endif
-      *minimal_width = alloc.width;
-    }
 
-  *natural_width = *minimal_width;
+  if (minimum_width != NULL)
+    *minimum_width = width;
+
+  if (natural_width != NULL)
+    *natural_width = width;
 }
 
 
 
 static void
 xfce_panel_image_get_preferred_height (GtkWidget *widget,
-                                       gint      *minimal_height,
+                                       gint      *minimum_height,
                                        gint      *natural_height)
 {
   XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
   GtkAllocation          alloc;
+  gint                   height;
 
   if (priv->size > 0)
-    *minimal_height = priv->size;
+    height = priv->size;
   else if (priv->pixbuf != NULL)
-    *minimal_height = gdk_pixbuf_get_height (priv->pixbuf);
+    height = gdk_pixbuf_get_height (priv->pixbuf);
   else
     {
       gtk_widget_get_allocation (widget, &alloc);
+      height = alloc.height;
+    }
+
 #ifdef GTK_BUTTON_SIZING_FIX
-      alloc.height -= xfce_panel_image_padding_correction (widget);
+  height -= xfce_panel_image_padding_correction (widget);
 #endif
-      *minimal_height = alloc.height;
-    }
 
-  *natural_height = *minimal_height;
+  if (minimum_height != NULL)
+    *minimum_height = height;
+
+  if (natural_height != NULL)
+    *natural_height = height;
 }
 #endif
 
@@ -481,7 +493,6 @@ xfce_panel_image_draw (GtkWidget *widget,
   GdkPixbuf             *rendered = NULL;
   GdkPixbuf             *pixbuf = priv->cache;
   GtkStyleContext       *context;
-  GtkAllocation          alloc;
 
   if (G_LIKELY (pixbuf != NULL))
     {
@@ -490,7 +501,6 @@ xfce_panel_image_draw (GtkWidget *widget,
       source_height = gdk_pixbuf_get_height (pixbuf);
 
       /* position */
-      gtk_widget_get_allocation (widget, &alloc);
       dest_x = (priv->width - source_width) / 2;
       dest_y = (priv->height - source_height) / 2;
 


More information about the Xfce4-commits mailing list