[gtk+] Ensure that GtkRange allocates enough space for the value
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Ensure that GtkRange allocates enough space for the value
- Date: Wed, 8 Jun 2016 01:33:54 +0000 (UTC)
commit 7f06f2818aaef1994cb7224d95522b956bfd4ab8
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 7 21:28:44 2016 -0400
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
gtk/gtkrange.c | 11 +++++++++++
gtk/gtkrange.h | 6 +++++-
gtk/gtkscale.c | 26 ++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 0b306e4..c124ca2 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -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
diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h
index b21e844..e78b3b5 100644
--- a/gtk/gtkrange.h
+++ b/gtk/gtkrange.h
@@ -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);
};
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 1a66d2c..43161a3 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -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;
@@ -1553,6 +1558,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,
GtkScale *scale)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]