range: remove range_size_request vfunc

It's unneeded in GtkScale and named after the gtk2 size_request function
This commit is contained in:
Timm Bäder 2019-08-09 12:08:51 +02:00
parent b4a6d69f5d
commit ebc0d3760f
3 changed files with 42 additions and 48 deletions

View File

@ -1381,17 +1381,6 @@ gtk_range_measure (GtkWidget *widget,
*minimum += border.top + border.bottom; *minimum += border.top + border.bottom;
*natural += border.top + border.bottom; *natural += border.top + border.bottom;
} }
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 static void

View File

@ -71,11 +71,6 @@ struct _GtkRangeClass
GtkScrollType scroll, GtkScrollType scroll,
gdouble new_value); gdouble new_value);
void (* get_range_size_request) (GtkRange *range,
GtkOrientation orientation,
gint *minimum,
gint *natural);
/*< private > */ /*< private > */
gpointer padding[8]; gpointer padding[8];

View File

@ -197,10 +197,6 @@ static void gtk_scale_measure (GtkWidget *widget,
int *natural_baseline); int *natural_baseline);
static void gtk_scale_get_range_border (GtkRange *range, static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border); 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_finalize (GObject *object);
static void gtk_scale_snapshot (GtkWidget *widget, static void gtk_scale_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot); GtkSnapshot *snapshot);
@ -665,7 +661,6 @@ gtk_scale_class_init (GtkScaleClass *class)
widget_class->measure = gtk_scale_measure; widget_class->measure = gtk_scale_measure;
range_class->get_range_border = gtk_scale_get_range_border; range_class->get_range_border = gtk_scale_get_range_border;
range_class->get_range_size_request = gtk_scale_get_range_size_request;
range_class->value_changed = gtk_scale_value_changed; range_class->value_changed = gtk_scale_value_changed;
class->get_layout_offsets = gtk_scale_real_get_layout_offsets; class->get_layout_offsets = gtk_scale_real_get_layout_offsets;
@ -1220,12 +1215,12 @@ gtk_scale_get_has_origin (GtkScale *scale)
* gtk_scale_set_value_pos: * gtk_scale_set_value_pos:
* @scale: a #GtkScale * @scale: a #GtkScale
* @pos: the position in which the current value is displayed * @pos: the position in which the current value is displayed
* *
* Sets the position in which the current value is displayed. * Sets the position in which the current value is displayed.
*/ */
void void
gtk_scale_set_value_pos (GtkScale *scale, gtk_scale_set_value_pos (GtkScale *scale,
GtkPositionType pos) GtkPositionType pos)
{ {
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale); GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
GtkWidget *widget; GtkWidget *widget;
@ -1238,9 +1233,7 @@ gtk_scale_set_value_pos (GtkScale *scale,
widget = GTK_WIDGET (scale); widget = GTK_WIDGET (scale);
update_value_position (scale); update_value_position (scale);
gtk_widget_queue_resize (widget);
if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget))
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_VALUE_POS]); g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_VALUE_POS]);
} }
@ -1361,27 +1354,6 @@ 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_get_instance_private (GTK_SCALE (range));
/* Ensure the range requests enough size for our value */
if (priv->value_widget)
gtk_widget_measure (priv->value_widget,
orientation, -1,
minimum, natural,
NULL, NULL);
else
{
*minimum = 0;
*natural = 0;
}
}
static void static void
gtk_scale_measure_mark (GtkGizmo *gizmo, gtk_scale_measure_mark (GtkGizmo *gizmo,
GtkOrientation orientation, GtkOrientation orientation,
@ -1466,6 +1438,7 @@ gtk_scale_measure (GtkWidget *widget,
{ {
GtkScale *scale = GTK_SCALE (widget); GtkScale *scale = GTK_SCALE (widget);
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale); GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
GtkOrientation scale_orientation;
GTK_WIDGET_CLASS (gtk_scale_parent_class)->measure (widget, GTK_WIDGET_CLASS (gtk_scale_parent_class)->measure (widget,
orientation, orientation,
@ -1473,7 +1446,9 @@ gtk_scale_measure (GtkWidget *widget,
minimum, natural, minimum, natural,
minimum_baseline, natural_baseline); minimum_baseline, natural_baseline);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == orientation) scale_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
if (scale_orientation == orientation)
{ {
int top_marks_size = 0, bottom_marks_size = 0, marks_size; int top_marks_size = 0, bottom_marks_size = 0, marks_size;
@ -1493,6 +1468,41 @@ gtk_scale_measure (GtkWidget *widget,
*minimum = MAX (*minimum, marks_size); *minimum = MAX (*minimum, marks_size);
*natural = MAX (*natural, marks_size); *natural = MAX (*natural, marks_size);
} }
if (priv->value_widget)
{
int min, nat;
gtk_widget_measure (priv->value_widget, orientation, -1, &min, &nat, NULL, NULL);
if (priv->value_pos == GTK_POS_TOP ||
priv->value_pos == GTK_POS_BOTTOM)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
*minimum = MAX (*minimum, min);
*natural = MAX (*natural, nat);
}
else
{
*minimum += min;
*natural += nat;
}
}
else
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
*minimum += min;
*natural += nat;
}
else
{
*minimum = MAX (*minimum, min);
*natural = MAX (*natural, nat);
}
}
}
} }
static void static void