Commit 7f06f281 authored by Matthias Clasen's avatar Matthias Clasen

Ensure that GtkRange allocates enough space for the value

This is a long-standing problem of GtkScale.

https://bugzilla.gnome.org/show_bug.cgi?id=766372
https://bugzilla.gnome.org/show_bug.cgi?id=578626
https://bugzilla.gnome.org/show_bug.cgi?id=79229
parent dce4003c
......@@ -1894,6 +1894,17 @@ gtk_range_size_request (GtkWidget *widget,
gtk_css_gadget_get_preferred_size (priv->gadget, orientation, -1,
minimum, natural,
NULL, NULL);
if (GTK_RANGE_GET_CLASS (range)->get_range_size_request)
{
gint min, nat;
GTK_RANGE_GET_CLASS (range)->get_range_size_request (range, orientation,
&min, &nat);
*minimum = MAX (*minimum, min);
*natural = MAX (*natural, nat);
}
}
static void
......
......@@ -78,11 +78,15 @@ struct _GtkRangeClass
GtkScrollType scroll,
gdouble new_value);
void (* get_range_size_request) (GtkRange *range,
GtkOrientation orientation,
gint *minimum,
gint *natural);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
......
......@@ -198,6 +198,10 @@ static void gtk_scale_get_preferred_height (GtkWidget *widget,
gint *natural);
static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border);
static void gtk_scale_get_range_size_request (GtkRange *range,
GtkOrientation orientation,
gint *minimum,
gint *natural);
static void gtk_scale_finalize (GObject *object);
static void gtk_scale_value_style_changed (GtkCssNode *node,
GtkCssStyleChange *change,
......@@ -718,6 +722,7 @@ gtk_scale_class_init (GtkScaleClass *class)
widget_class->get_preferred_height = gtk_scale_get_preferred_height;
range_class->get_range_border = gtk_scale_get_range_border;
range_class->get_range_size_request = gtk_scale_get_range_size_request;
class->get_layout_offsets = gtk_scale_real_get_layout_offsets;
......@@ -1552,6 +1557,27 @@ gtk_scale_get_range_border (GtkRange *range,
}
}
static void
gtk_scale_get_range_size_request (GtkRange *range,
GtkOrientation orientation,
gint *minimum,
gint *natural)
{
GtkScalePrivate *priv = GTK_SCALE (range)->priv;
/* Ensure the range requests enough size for our value */
if (priv->value_gadget)
gtk_css_gadget_get_preferred_size (priv->value_gadget,
orientation, -1,
minimum, natural,
NULL, NULL);
else
{
*minimum = 0;
*natural = 0;
}
}
static void
gtk_scale_value_style_changed (GtkCssNode *node,
GtkCssStyleChange *change,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment