From 801ba1c7581b988e009c303f78ff341fd7f674c4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 5 Jan 2011 22:08:45 +0100 Subject: [PATCH] range: Update adjustment usage for sealing --- gtk/gtkrange.c | 135 ++++++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 68 deletions(-) diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index f4b19b0698..678a2dd2e4 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -976,7 +976,7 @@ gtk_range_set_min_slider_size (GtkRange *range, if (gtk_widget_is_drawable (GTK_WIDGET (range))) { priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); gtk_widget_queue_draw (GTK_WIDGET (range)); } } @@ -1025,7 +1025,7 @@ gtk_range_get_range_rect (GtkRange *range, priv = range->priv; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); *range_rect = priv->range_rect; } @@ -1054,7 +1054,7 @@ gtk_range_get_slider_range (GtkRange *range, priv = range->priv; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); if (slider_start) *slider_start = priv->slider_start; @@ -1088,7 +1088,7 @@ gtk_range_set_lower_stepper_sensitivity (GtkRange *range, priv->lower_sensitivity = sensitivity; priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); gtk_widget_queue_draw (GTK_WIDGET (range)); g_object_notify (G_OBJECT (range), "lower-stepper-sensitivity"); @@ -1139,7 +1139,7 @@ gtk_range_set_upper_stepper_sensitivity (GtkRange *range, priv->upper_sensitivity = sensitivity; priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); gtk_widget_queue_draw (GTK_WIDGET (range)); g_object_notify (G_OBJECT (range), "upper-stepper-sensitivity"); @@ -1256,7 +1256,7 @@ gtk_range_set_value (GtkRange *range, priv = range->priv; if (priv->restrict_to_fill_level) - value = MIN (value, MAX (priv->adjustment->lower, + value = MIN (value, MAX (gtk_adjustment_get_lower (priv->adjustment), priv->fill_level)); gtk_adjustment_set_value (priv->adjustment, value); @@ -1275,7 +1275,7 @@ gtk_range_get_value (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), 0.0); - return range->priv->adjustment->value; + return gtk_adjustment_get_value (range->priv->adjustment); } /** @@ -1633,7 +1633,7 @@ gtk_range_size_allocate (GtkWidget *widget, priv->recalc_marks = TRUE; priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); if (gtk_widget_get_realized (widget)) gdk_window_move_resize (priv->event_window, @@ -1675,7 +1675,7 @@ gtk_range_realize (GtkWidget *widget) GdkWindowAttr attributes; gint attributes_mask; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); gtk_widget_set_realized (widget, TRUE); @@ -1961,7 +1961,7 @@ gtk_range_draw (GtkWidget *widget, NULL); if (GTK_IS_SCALE (widget) && - priv->adjustment->upper == priv->adjustment->lower) + gtk_adjustment_get_upper (priv->adjustment) == gtk_adjustment_get_lower (priv->adjustment)) draw_trough = FALSE; if (gtk_widget_get_can_focus (GTK_WIDGET (range))) @@ -1978,7 +1978,7 @@ gtk_range_draw (GtkWidget *widget, priv->repaint_id = 0; gtk_range_calc_marks (range); - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); sensitive = gtk_widget_is_sensitive (widget); @@ -2107,8 +2107,8 @@ gtk_range_draw (GtkWidget *widget, gtk_style_context_restore (context); if (priv->show_fill_level && - priv->adjustment->upper - priv->adjustment->page_size - - priv->adjustment->lower != 0) + gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) - + gtk_adjustment_get_lower (priv->adjustment) != 0) { gdouble fill_level = priv->fill_level; gint fill_x = x; @@ -2120,18 +2120,18 @@ gtk_range_draw (GtkWidget *widget, gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); - fill_level = CLAMP (fill_level, priv->adjustment->lower, - priv->adjustment->upper - - priv->adjustment->page_size); + fill_level = CLAMP (fill_level, gtk_adjustment_get_lower (priv->adjustment), + gtk_adjustment_get_upper (priv->adjustment) - + gtk_adjustment_get_page_size (priv->adjustment)); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { fill_x = priv->trough.x; fill_width = (priv->slider.width + - (fill_level - priv->adjustment->lower) / - (priv->adjustment->upper - - priv->adjustment->lower - - priv->adjustment->page_size) * + (fill_level - gtk_adjustment_get_lower (priv->adjustment)) / + (gtk_adjustment_get_upper (priv->adjustment) - + gtk_adjustment_get_lower (priv->adjustment) - + gtk_adjustment_get_page_size (priv->adjustment)) * (priv->trough.width - priv->slider.width)); @@ -2142,10 +2142,10 @@ gtk_range_draw (GtkWidget *widget, { fill_y = priv->trough.y; fill_height = (priv->slider.height + - (fill_level - priv->adjustment->lower) / - (priv->adjustment->upper - - priv->adjustment->lower - - priv->adjustment->page_size) * + (fill_level - gtk_adjustment_get_lower (priv->adjustment)) / + (gtk_adjustment_get_upper (priv->adjustment) - + gtk_adjustment_get_lower (priv->adjustment) - + gtk_adjustment_get_page_size (priv->adjustment)) * (priv->trough.height - priv->slider.height)); @@ -2153,7 +2153,7 @@ gtk_range_draw (GtkWidget *widget, fill_y += priv->trough.height - fill_height; } - if (fill_level < priv->adjustment->upper - priv->adjustment->page_size) + if (fill_level < gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)) fill_detail = "trough-fill-level-full"; else fill_detail = "trough-fill-level"; @@ -2398,9 +2398,9 @@ coord_to_value (GtkRange *range, if (should_invert (range)) frac = 1.0 - frac; - value = priv->adjustment->lower + frac * (priv->adjustment->upper - - priv->adjustment->lower - - priv->adjustment->page_size); + value = gtk_adjustment_get_lower (priv->adjustment) + frac * (gtk_adjustment_get_upper (priv->adjustment) - + gtk_adjustment_get_lower (priv->adjustment) - + gtk_adjustment_get_page_size (priv->adjustment)); return value; } @@ -2466,7 +2466,7 @@ gtk_range_button_press (GtkWidget *widget, priv->orientation == GTK_ORIENTATION_VERTICAL ? event->y : event->x); - priv->trough_click_forward = click_value > priv->adjustment->value; + priv->trough_click_forward = click_value > gtk_adjustment_get_value (priv->adjustment); range_grab_add (range, device, MOUSE_TROUGH, event->button); scroll = range_get_scroll_for_grab (range); @@ -2597,7 +2597,7 @@ update_slider_position (GtkRange *range, { mark_value = priv->marks[i]; - if (fabs (priv->adjustment->value - mark_value) < 3 * mark_delta) + if (fabs (gtk_adjustment_get_value (priv->adjustment) - mark_value) < 3 * mark_delta) { if (fabs (new_value - mark_value) < (priv->slider_end - priv->slider_start) * 0.5 * mark_delta) { @@ -2696,13 +2696,13 @@ _gtk_range_get_wheel_delta (GtkRange *range, GdkScrollDirection direction) { GtkRangePrivate *priv = range->priv; - GtkAdjustment *adj = priv->adjustment; + GtkAdjustment *adjustment = priv->adjustment; gdouble delta; if (GTK_IS_SCROLLBAR (range)) - delta = pow (adj->page_size, 2.0 / 3.0); + delta = pow (gtk_adjustment_get_page_size (adjustment), 2.0 / 3.0); else - delta = adj->step_increment * 2; + delta = gtk_adjustment_get_step_increment (adjustment) * 2; if (direction == GDK_SCROLL_UP || direction == GDK_SCROLL_LEFT) @@ -2723,14 +2723,13 @@ gtk_range_scroll_event (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { - GtkAdjustment *adj = priv->adjustment; gdouble delta; gboolean handled; delta = _gtk_range_get_wheel_delta (range, event->direction); g_signal_emit (range, signals[CHANGE_VALUE], 0, - GTK_SCROLL_JUMP, adj->value + delta, + GTK_SCROLL_JUMP, gtk_adjustment_get_value (priv->adjustment) + delta, &handled); } @@ -2845,7 +2844,7 @@ gtk_range_adjustment_changed (GtkAdjustment *adjustment, priv->recalc_marks = TRUE; priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); /* now check whether the layout changed */ if (layout_changed (priv, &priv_aux)) @@ -2883,7 +2882,7 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment, GtkRangePrivate priv_aux = *priv; priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); /* now check whether the layout changed */ if (layout_changed (priv, &priv_aux) || @@ -2947,8 +2946,8 @@ step_back (GtkRange *range) gdouble newval; gboolean handled; - newval = priv->adjustment->value - priv->adjustment->step_increment; - apply_marks (range, priv->adjustment->value, &newval); + newval = gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_step_increment (priv->adjustment); + apply_marks (range, gtk_adjustment_get_value (priv->adjustment), &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_STEP_BACKWARD, newval, &handled); } @@ -2960,8 +2959,8 @@ step_forward (GtkRange *range) gdouble newval; gboolean handled; - newval = priv->adjustment->value + priv->adjustment->step_increment; - apply_marks (range, priv->adjustment->value, &newval); + newval = gtk_adjustment_get_value (priv->adjustment) + gtk_adjustment_get_step_increment (priv->adjustment); + apply_marks (range, gtk_adjustment_get_value (priv->adjustment), &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_STEP_FORWARD, newval, &handled); } @@ -2974,8 +2973,8 @@ page_back (GtkRange *range) gdouble newval; gboolean handled; - newval = priv->adjustment->value - priv->adjustment->page_increment; - apply_marks (range, priv->adjustment->value, &newval); + newval = gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_page_increment (priv->adjustment); + apply_marks (range, gtk_adjustment_get_value (priv->adjustment), &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_PAGE_BACKWARD, newval, &handled); } @@ -2987,8 +2986,8 @@ page_forward (GtkRange *range) gdouble newval; gboolean handled; - newval = priv->adjustment->value + priv->adjustment->page_increment; - apply_marks (range, priv->adjustment->value, &newval); + newval = gtk_adjustment_get_value (priv->adjustment) + gtk_adjustment_get_page_increment (priv->adjustment); + apply_marks (range, gtk_adjustment_get_value (priv->adjustment), &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_PAGE_FORWARD, newval, &handled); } @@ -3000,7 +2999,7 @@ scroll_begin (GtkRange *range) gboolean handled; g_signal_emit (range, signals[CHANGE_VALUE], 0, - GTK_SCROLL_START, priv->adjustment->lower, + GTK_SCROLL_START, gtk_adjustment_get_lower (priv->adjustment), &handled); } @@ -3011,7 +3010,7 @@ scroll_end (GtkRange *range) gdouble newval; gboolean handled; - newval = priv->adjustment->upper - priv->adjustment->page_size; + newval = gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_END, newval, &handled); } @@ -3021,7 +3020,7 @@ gtk_range_scroll (GtkRange *range, GtkScrollType scroll) { GtkRangePrivate *priv = range->priv; - gdouble old_value = priv->adjustment->value; + gdouble old_value = gtk_adjustment_get_value (priv->adjustment); switch (scroll) { @@ -3113,7 +3112,7 @@ gtk_range_scroll (GtkRange *range, break; } - return priv->adjustment->value != old_value; + return gtk_adjustment_get_value (priv->adjustment) != old_value; } static void @@ -3634,9 +3633,9 @@ gtk_range_calc_layout (GtkRange *range, * total_adjustment_range) times the trough height in pixels */ - if (priv->adjustment->upper - priv->adjustment->lower != 0) - height = ((bottom - top) * (priv->adjustment->page_size / - (priv->adjustment->upper - priv->adjustment->lower))); + if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0) + height = ((bottom - top) * (gtk_adjustment_get_page_size (priv->adjustment) / + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)))); else height = priv->min_slider_size; @@ -3648,9 +3647,9 @@ gtk_range_calc_layout (GtkRange *range, y = top; - if (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size != 0) - y += (bottom - top - height) * ((adjustment_value - priv->adjustment->lower) / - (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size)); + if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) != 0) + y += (bottom - top - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment))); y = CLAMP (y, top, bottom); @@ -3783,9 +3782,9 @@ gtk_range_calc_layout (GtkRange *range, * total_adjustment_range) times the trough width in pixels */ - if (priv->adjustment->upper - priv->adjustment->lower != 0) - width = ((right - left) * (priv->adjustment->page_size / - (priv->adjustment->upper - priv->adjustment->lower))); + if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0) + width = ((right - left) * (gtk_adjustment_get_page_size (priv->adjustment) / + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)))); else width = priv->min_slider_size; @@ -3797,9 +3796,9 @@ gtk_range_calc_layout (GtkRange *range, x = left; - if (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size != 0) - x += (right - left - width) * ((adjustment_value - priv->adjustment->lower) / - (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size)); + if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) != 0) + x += (right - left - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment))); x = CLAMP (x, left, right); @@ -3821,8 +3820,8 @@ gtk_range_calc_layout (GtkRange *range, { case GTK_SENSITIVITY_AUTO: priv->upper_sensitive = - (priv->adjustment->value < - (priv->adjustment->upper - priv->adjustment->page_size)); + (gtk_adjustment_get_value (priv->adjustment) < + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment))); break; case GTK_SENSITIVITY_ON: @@ -3838,7 +3837,7 @@ gtk_range_calc_layout (GtkRange *range, { case GTK_SENSITIVITY_AUTO: priv->lower_sensitive = - (priv->adjustment->value > priv->adjustment->lower); + (gtk_adjustment_get_value (priv->adjustment) > gtk_adjustment_get_lower (priv->adjustment)); break; case GTK_SENSITIVITY_ON: @@ -3915,11 +3914,11 @@ gtk_range_real_change_value (GtkRange *range, g_signal_emit (range, signals[ADJUST_BOUNDS], 0, value); if (priv->restrict_to_fill_level) - value = MIN (value, MAX (priv->adjustment->lower, + value = MIN (value, MAX (gtk_adjustment_get_lower (priv->adjustment), priv->fill_level)); - value = CLAMP (value, priv->adjustment->lower, - (priv->adjustment->upper - priv->adjustment->page_size)); + value = CLAMP (value, gtk_adjustment_get_lower (priv->adjustment), + (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment))); if (priv->round_digits >= 0) { @@ -3934,7 +3933,7 @@ gtk_range_real_change_value (GtkRange *range, value = floor ((value * power) + 0.5) / power; } - if (priv->adjustment->value != value) + if (gtk_adjustment_get_value (priv->adjustment) != value) { priv->need_recalc = TRUE;