diff options
author | Matthias Clasen <mclasen@redhat.com> | 2009-05-03 12:45:54 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2009-05-03 13:00:30 -0400 |
commit | 5325959fe2054491d7dcfe6ea3a1333d0465ae7e (patch) | |
tree | f7a314e32a2316c2b722e0fec801319df445d466 /gtk | |
parent | 49e1700bb27bda87292af36f318a48a33852ccc9 (diff) | |
download | gtk+-5325959fe2054491d7dcfe6ea3a1333d0465ae7e.tar.gz |
Update to explain the situation.
2008-09-23 Matthias Clasen <mclasen@redhat.com>
* README.in: Update to explain the situation.
* gtk/gtkadjustment.c: Revert to the old behaviour of allowing
values in the range [lower, upper]. Relying on the possibility
to set values in the [upper - page_size, upper] subrange is
considered deprecated, though, and will trigger a warning.
* gtk/gtkcombobox.c:
* gtk/gtkiconview.c:
* gtk/gtkrange.c:
* gtk/gtkscrolledwindow.c:
* gtk/gtktreeview.c: Add the CLAMPing back that was removed after
the GtkAdjustment behaviour change.
svn path=/branches/gtk-2-14/; revision=21499
Conflicts:
ChangeLog.pre-2-14
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkadjustment.c | 6 | ||||
-rw-r--r-- | gtk/gtkcombobox.c | 8 | ||||
-rw-r--r-- | gtk/gtkiconview.c | 52 | ||||
-rw-r--r-- | gtk/gtkrange.c | 6 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 8 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 22 |
6 files changed, 66 insertions, 36 deletions
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c index dd1b3f609d..49f5008ec2 100644 --- a/gtk/gtkadjustment.c +++ b/gtk/gtkadjustment.c @@ -359,11 +359,7 @@ gtk_adjustment_set_value (GtkAdjustment *adjustment, { g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - /* don't use CLAMP() so we don't end up below lower if upper - page_size - * is smaller than lower - */ - value = MIN (value, adjustment->upper - adjustment->page_size); - value = MAX (value, adjustment->lower); + value = CLAMP (value, adjustment->lower, adjustment->upper); if (value != adjustment->value) { diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 57a975d0ef..eb669a031a 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -4018,13 +4018,13 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, adj->lower < adj->value) { value = adj->value - (tree_view->allocation.x - x + 1); - gtk_adjustment_set_value (adj, value); + gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size)); } else if (x >= tree_view->allocation.x + tree_view->allocation.width && adj->upper - adj->page_size > adj->value) { value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1); - gtk_adjustment_set_value (adj, MAX (value, 0.0)); + gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size)); } } @@ -4035,13 +4035,13 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, adj->lower < adj->value) { value = adj->value - (tree_view->allocation.y - y + 1); - gtk_adjustment_set_value (adj, value); + gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size)); } else if (y >= tree_view->allocation.height && adj->upper - adj->page_size > adj->value) { value = adj->value + (y - tree_view->allocation.height + 1); - gtk_adjustment_set_value (adj, MAX (value, 0.0)); + gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size)); } } } diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 78d24d7134..c93a574d04 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -1471,7 +1471,7 @@ gtk_icon_view_size_allocate (GtkWidget *widget, hadjustment->upper = MAX (allocation->width, icon_view->priv->width); if (hadjustment->value > hadjustment->upper - hadjustment->page_size) - gtk_adjustment_set_value (hadjustment, hadjustment->upper - hadjustment->page_size); + gtk_adjustment_set_value (hadjustment, MAX (0, hadjustment->upper - hadjustment->page_size)); vadjustment->page_size = allocation->height; vadjustment->page_increment = allocation->height * 0.9; @@ -1480,7 +1480,7 @@ gtk_icon_view_size_allocate (GtkWidget *widget, vadjustment->upper = MAX (allocation->height, icon_view->priv->height); if (vadjustment->value > vadjustment->upper - vadjustment->page_size) - gtk_adjustment_set_value (vadjustment, vadjustment->upper - vadjustment->page_size); + gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size)); if (GTK_WIDGET_REALIZED (widget) && icon_view->priv->scroll_to_path) @@ -1638,11 +1638,17 @@ gtk_icon_view_expose (GtkWidget *widget, static gboolean rubberband_scroll_timeout (gpointer data) { - GtkIconView *icon_view = data; + GtkIconView *icon_view; + gdouble value; + + icon_view = data; + + value = MIN (icon_view->priv->vadjustment->value + + icon_view->priv->scroll_value_diff, + icon_view->priv->vadjustment->upper - + icon_view->priv->vadjustment->page_size); - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + - icon_view->priv->scroll_value_diff); + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); gtk_icon_view_update_rubberband (icon_view); @@ -4349,7 +4355,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view, { gint x, y; gint focus_width; - gfloat offset; + gfloat offset, value; gtk_widget_style_get (GTK_WIDGET (icon_view), "focus-line-width", &focus_width, @@ -4359,15 +4365,17 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view, offset = y + item->y - focus_width - row_align * (GTK_WIDGET (icon_view)->allocation.height - item->height); - - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + offset); + value = CLAMP (icon_view->priv->vadjustment->value + offset, + icon_view->priv->vadjustment->lower, + icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); offset = x + item->x - focus_width - col_align * (GTK_WIDGET (icon_view)->allocation.width - item->width); - - gtk_adjustment_set_value (icon_view->priv->hadjustment, - icon_view->priv->hadjustment->value + offset); + value = CLAMP (icon_view->priv->hadjustment->value + offset, + icon_view->priv->hadjustment->lower, + icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->hadjustment, value); gtk_adjustment_changed (icon_view->priv->hadjustment); gtk_adjustment_changed (icon_view->priv->vadjustment); @@ -6407,6 +6415,7 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) { gint px, py, x, y, width, height; gint hoffset, voffset; + gfloat value; gdk_window_get_pointer (GTK_WIDGET (icon_view)->window, &px, &py, NULL); gdk_window_get_geometry (GTK_WIDGET (icon_view)->window, &x, &y, &width, &height, NULL); @@ -6421,12 +6430,19 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) hoffset = MAX (px - (x + width - 2 * SCROLL_EDGE_SIZE), 0); if (voffset != 0) - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + voffset); - + { + value = CLAMP (icon_view->priv->vadjustment->value + voffset, + icon_view->priv->vadjustment->lower, + icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); + } if (hoffset != 0) - gtk_adjustment_set_value (icon_view->priv->hadjustment, - icon_view->priv->hadjustment->value + hoffset); + { + value = CLAMP (icon_view->priv->hadjustment->value + hoffset, + icon_view->priv->hadjustment->lower, + icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->hadjustment, value); + } } diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 0c1b313b5a..ce4e5e4282 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -990,6 +990,9 @@ gtk_range_set_range (GtkRange *range, value = MIN (value, MAX (range->adjustment->lower, range->layout->fill_level)); + value = CLAMP (value, range->adjustment->lower, + (range->adjustment->upper - range->adjustment->page_size)); + gtk_adjustment_set_value (range->adjustment, value); gtk_adjustment_changed (range->adjustment); } @@ -1014,6 +1017,9 @@ gtk_range_set_value (GtkRange *range, value = MIN (value, MAX (range->adjustment->lower, range->layout->fill_level)); + value = CLAMP (value, range->adjustment->lower, + (range->adjustment->upper - range->adjustment->page_size)); + gtk_adjustment_set_value (range->adjustment, value); } diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index b1b4184396..e1ef6333bb 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1190,6 +1190,8 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window, break; } + value = CLAMP (value, adjustment->lower, adjustment->upper - adjustment->page_size); + gtk_adjustment_set_value (adjustment, value); return TRUE; @@ -1573,11 +1575,13 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget, if (range && GTK_WIDGET_VISIBLE (range)) { GtkAdjustment *adj = GTK_RANGE (range)->adjustment; - gdouble delta; + gdouble delta, new_value; delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event->direction); - gtk_adjustment_set_value (adj, adj->value + delta); + new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size); + + gtk_adjustment_set_value (adj, new_value); return TRUE; } diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 5078cdb8dc..caa517c07a 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -3620,6 +3620,7 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view) GdkRectangle visible_rect; gint y; gint offset; + gfloat value; gdk_window_get_pointer (tree_view->priv->bin_window, NULL, &y, NULL); y += tree_view->priv->dy; @@ -3635,8 +3636,9 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view) return; } - gtk_adjustment_set_value (tree_view->priv->vadjustment, - MAX (tree_view->priv->vadjustment->value + offset, 0.0)); + value = CLAMP (tree_view->priv->vadjustment->value + offset, 0.0, + tree_view->priv->vadjustment->upper - tree_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (tree_view->priv->vadjustment, value); } static gboolean @@ -3645,6 +3647,7 @@ gtk_tree_view_horizontal_autoscroll (GtkTreeView *tree_view) GdkRectangle visible_rect; gint x; gint offset; + gfloat value; gdk_window_get_pointer (tree_view->priv->bin_window, &x, NULL, NULL); @@ -3660,8 +3663,9 @@ gtk_tree_view_horizontal_autoscroll (GtkTreeView *tree_view) } offset = offset/3; - gtk_adjustment_set_value (tree_view->priv->hadjustment, - MAX (tree_view->priv->hadjustment->value + offset, 0.0)); + value = CLAMP (tree_view->priv->hadjustment->value + offset, + 0.0, tree_view->priv->hadjustment->upper - tree_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (tree_view->priv->hadjustment, value); return TRUE; @@ -8964,7 +8968,11 @@ gtk_tree_view_clamp_column_visible (GtkTreeView *tree_view, } } - gtk_adjustment_set_value (tree_view->priv->hadjustment, x); + gtk_adjustment_set_value (tree_view->priv->hadjustment, + CLAMP (x, + tree_view->priv->hadjustment->lower, + tree_view->priv->hadjustment->upper + - tree_view->priv->hadjustment->page_size)); } else { @@ -11613,9 +11621,9 @@ gtk_tree_view_scroll_to_point (GtkTreeView *tree_view, vadj = tree_view->priv->vadjustment; if (tree_x != -1) - gtk_adjustment_set_value (hadj, tree_x); + gtk_adjustment_set_value (hadj, CLAMP (tree_x, hadj->lower, hadj->upper - hadj->page_size)); if (tree_y != -1) - gtk_adjustment_set_value (vadj, tree_y); + gtk_adjustment_set_value (vadj, CLAMP (tree_y, vadj->lower, vadj->upper - vadj->page_size)); } /** |