[Xfce4-commits] <xfce4-panel:andrzejr/wrapper3> PanelImage: allow scaling the image down (below allocation)

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


Updating branch refs/heads/andrzejr/wrapper3
         to 8fff5877bbca65545f9dcfac788aa48fcf037f3e (commit)
       from 368aedcef78da3c753ef32882aca3b86fbec99c2 (commit)

commit 8fff5877bbca65545f9dcfac788aa48fcf037f3e
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Apr 17 02:24:58 2013 +0100

    PanelImage: allow scaling the image down (below allocation)
    
    Some containers (GtkBox(?)) refuse to allocate their child items below
    minimum requested size, even if that results in violating their own
    allocation.
    
    Reducing the minimum size allows these containers to iteratively
    reduce the size of the embedded PanelImage.
    
    When priv->size > 0 minimum size must be equal to the natural size.
    Otherwise icons displayed in menus will be too small (menus use
    a minimum size).

 libxfce4panel/xfce-panel-image.c |   38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index 5d17419..1783f39 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -358,24 +358,33 @@ xfce_panel_image_get_preferred_width (GtkWidget *widget,
 {
   XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
   GtkAllocation          alloc;
-  gint                   width;
+  gint                   width, width_min;
+#ifdef GTK_BUTTON_SIZING_FIX
+  gint                   correction;
+#endif
 
   if (priv->size > 0)
-    width = priv->size;
+    width = width_min = priv->size;
   else if (priv->pixbuf != NULL)
-    width = gdk_pixbuf_get_width (priv->pixbuf);
+    {
+      width = gdk_pixbuf_get_width (priv->pixbuf);
+      width_min = width / 2;
+    }
   else
     {
       gtk_widget_get_allocation (widget, &alloc);
       width = alloc.width;
+      width_min = width / 2;
     }
 
 #ifdef GTK_BUTTON_SIZING_FIX
-  width -= xfce_panel_image_padding_correction (widget);
+  correction = xfce_panel_image_padding_correction (widget);
+  width -= correction;
+  width_min -= correction;
 #endif
 
   if (minimum_width != NULL)
-    *minimum_width = width;
+    *minimum_width = width_min;
 
   if (natural_width != NULL)
     *natural_width = width;
@@ -390,24 +399,33 @@ xfce_panel_image_get_preferred_height (GtkWidget *widget,
 {
   XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
   GtkAllocation          alloc;
-  gint                   height;
+  gint                   height, height_min;
+#ifdef GTK_BUTTON_SIZING_FIX
+  gint                   correction;
+#endif
 
   if (priv->size > 0)
-    height = priv->size;
+    height = height_min = priv->size;
   else if (priv->pixbuf != NULL)
-    height = gdk_pixbuf_get_height (priv->pixbuf);
+    {
+      height = gdk_pixbuf_get_height (priv->pixbuf);
+      height_min = height / 2;
+    }
   else
     {
       gtk_widget_get_allocation (widget, &alloc);
       height = alloc.height;
+      height_min = height / 2;
     }
 
 #ifdef GTK_BUTTON_SIZING_FIX
-  height -= xfce_panel_image_padding_correction (widget);
+  correction = xfce_panel_image_padding_correction (widget);
+  height -= correction;
+  height_min -= correction;
 #endif
 
   if (minimum_height != NULL)
-    *minimum_height = height;
+    *minimum_height = height_min;
 
   if (natural_height != NULL)
     *natural_height = height;


More information about the Xfce4-commits mailing list