From 35a2b6532854251f5aed2eba22549f12154a805e Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 22 Jan 2010 16:52:56 +0100 Subject: [PATCH] Bug 607082 - Add accessors for sealed GtkRange members Add accessors for range->range_rect, range->slider_range, range->slider_size_fixed and range->min_slider_size. Didn't add properties for any of them because thir purpose is mostly to enable proper subclassing. --- gtk/gtk.symbols | 6 ++ gtk/gtkrange.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkrange.h | 14 +++++ 3 files changed, 169 insertions(+) diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 6a910bb7d3..b35944e0f4 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3348,8 +3348,12 @@ gtk_range_get_fill_level gtk_range_get_flippable gtk_range_get_inverted gtk_range_get_lower_stepper_sensitivity +gtk_range_get_min_slider_size +gtk_range_get_range_rect gtk_range_get_restrict_to_fill_level gtk_range_get_show_fill_level +gtk_range_get_slider_range +gtk_range_get_slider_size_fixed gtk_range_get_type G_GNUC_CONST gtk_range_get_update_policy gtk_range_get_upper_stepper_sensitivity @@ -3360,9 +3364,11 @@ gtk_range_set_flippable gtk_range_set_increments gtk_range_set_inverted gtk_range_set_lower_stepper_sensitivity +gtk_range_set_min_slider_size gtk_range_set_range gtk_range_set_restrict_to_fill_level gtk_range_set_show_fill_level +gtk_range_set_slider_size_fixed gtk_range_set_update_policy gtk_range_set_upper_stepper_sensitivity gtk_range_set_value diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 18224e0240..90cd8cbdf2 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -889,6 +889,155 @@ gtk_range_get_flippable (GtkRange *range) return range->flippable; } +/** + * gtk_range_set_slider_size_fixed: + * @range: a #GtkRange + * @size_fixed: %TRUE to make the slider size constant + * + * Sets whether the range's slider has a fixed size, or a size that + * depends on it's adjustment's page size. + * + * This function is useful mainly for #GtkRange subclasses. + * + * Since: 2.20 + **/ +void +gtk_range_set_slider_size_fixed (GtkRange *range, + gboolean size_fixed) +{ + g_return_if_fail (GTK_IS_RANGE (range)); + + if (size_fixed != range->slider_size_fixed) + { + range->slider_size_fixed = size_fixed ? TRUE : FALSE; + + range->need_recalc = TRUE; + gtk_range_calc_layout (range, range->adjustment->value); + gtk_widget_queue_draw (GTK_WIDGET (range)); + } +} + +/** + * gtk_range_get_slider_size_fixed: + * @range: a #GtkRange + * + * This function is useful mainly for #GtkRange subclasses. + * + * See gtk_range_set_slider_size_fixed(). + * + * Return value: whether the range's slider has a fixed size. + * + * Since: 2.20 + **/ +gboolean +gtk_range_get_slider_size_fixed (GtkRange *range) +{ + g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); + + return range->slider_size_fixed; +} + +/** + * gtk_range_set_min_slider_size: + * @range: a #GtkRange + * @min_size: The slider's minimum size + * + * Sets the minimum size of the range's slider. + * + * This function is useful mainly for #GtkRange subclasses. + * + * Since: 2.20 + **/ +void +gtk_range_set_min_slider_size (GtkRange *range, + gboolean min_size) +{ + g_return_if_fail (GTK_IS_RANGE (range)); + g_return_if_fail (min_size > 0); + + if (min_size != range->min_slider_size) + { + range->min_slider_size = min_size; + + range->need_recalc = TRUE; + gtk_range_calc_layout (range, range->adjustment->value); + gtk_widget_queue_draw (GTK_WIDGET (range)); + } +} + +/** + * gtk_range_get_min_slider_size: + * @range: a #GtkRange + * + * This function is useful mainly for #GtkRange subclasses. + * + * See gtk_range_set_min_slider_size(). + * + * Return value: The minimum size of the range's slider. + * + * Since: 2.20 + **/ +gint +gtk_range_get_min_slider_size (GtkRange *range) +{ + g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); + + return range->min_slider_size; +} + +/** + * gtk_range_get_range_rect: + * @range: a #GtkRange + * @range_rect: return location for the range rectangle + * + * This function returns the area that contains the range's trough + * and its steppers, in widget->window coordinates. + * + * This function is useful mainly for #GtkRange subclasses. + * + * Since: 2.20 + **/ +void +gtk_range_get_range_rect (GtkRange *range, + GdkRectangle *range_rect) +{ + g_return_if_fail (GTK_IS_RANGE (range)); + g_return_if_fail (range_rect != NULL); + + gtk_range_calc_layout (range, range->adjustment->value); + + *range_rect = range->range_rect; +} + +/** + * gtk_range_get_slider_range: + * @range: a #GtkRange + * @slider_start: return location for the slider's start, or %NULL + * @slider_end: return location for the slider's end, or %NULL + * + * This function returns sliders range along the long dimension, + * in widget->window coordinates. + * + * This function is useful mainly for #GtkRange subclasses. + * + * Since: 2.20 + **/ +void +gtk_range_get_slider_range (GtkRange *range, + gint *slider_start, + gint *slider_end) +{ + g_return_if_fail (GTK_IS_RANGE (range)); + + gtk_range_calc_layout (range, range->adjustment->value); + + if (slider_start) + *slider_start = range->slider_start; + + if (slider_end) + *slider_end = range->slider_end; +} + /** * gtk_range_set_lower_stepper_sensitivity: * @range: a #GtkRange diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h index 268a5223e1..abfbc7c137 100644 --- a/gtk/gtkrange.h +++ b/gtk/gtkrange.h @@ -151,6 +151,20 @@ void gtk_range_set_flippable (GtkRange *range gboolean flippable); gboolean gtk_range_get_flippable (GtkRange *range); +void gtk_range_set_slider_size_fixed (GtkRange *range, + gboolean size_fixed); +gboolean gtk_range_get_slider_size_fixed (GtkRange *range); + +void gtk_range_set_min_slider_size (GtkRange *range, + gboolean min_size); +gint gtk_range_get_min_slider_size (GtkRange *range); + +void gtk_range_get_range_rect (GtkRange *range, + GdkRectangle *range_rect); +void gtk_range_get_slider_range (GtkRange *range, + gint *slider_start, + gint *slider_end); + void gtk_range_set_lower_stepper_sensitivity (GtkRange *range, GtkSensitivityType sensitivity); GtkSensitivityType gtk_range_get_lower_stepper_sensitivity (GtkRange *range);