[Xfce4-commits] <xfce4-panel:master> PanelImage: allow scaling the image down (below allocation)
Nick Schermer
noreply at xfce.org
Sat Nov 30 17:12:15 CET 2013
Updating branch refs/heads/master
to 334f991cafbbe8d05f5ca9c5dac7ba4bba9a509e (commit)
from 25cea7e621eb61327165df6b6146295f74192609 (commit)
commit 334f991cafbbe8d05f5ca9c5dac7ba4bba9a509e
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