[gtk+] Revert "Forward-port a GtkAdjustment compatibility fix"
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Revert "Forward-port a GtkAdjustment compatibility fix"
- Date: Mon, 24 May 2010 13:39:53 +0000 (UTC)
commit b18b33ae8234982dcc4e694358cbcbc32c3e7e3a
Author: Javier Jardón <jjardon gnome org>
Date: Mon May 24 04:04:10 2010 +0200
Revert "Forward-port a GtkAdjustment compatibility fix"
In the early 2.14.x releases, GtkAdjustment was changed to enforce
that values are restricted to the range [lower, upper - page_size].
This has always been the documented behaviour, and the recommended
practice is to set page_size to 0 when using adjustments for simple
scalar values, like in a slider or spin button.
Due to the large number of applications that are affected by this
change, the behaviour has been reverted to the old behaviour in
2.14.3, with an explicit warning that this change will be
reintroduced in 2.90.
This reverts commit e6373738fc9c53c95e467a3681fcd3426fd94d13.
https://bugzilla.gnome.org/show_bug.cgi?id=619474
README.in | 14 ++++--------
gtk/gtkadjustment.c | 6 ++++-
gtk/gtkcombobox.c | 8 +++---
gtk/gtkiconview.c | 52 ++++++++++++++++------------------------------
gtk/gtkrange.c | 6 -----
gtk/gtkscrolledwindow.c | 8 +-----
gtk/gtkspinbutton.c | 9 --------
gtk/gtktreeview.c | 22 ++++++-------------
8 files changed, 41 insertions(+), 84 deletions(-)
---
diff --git a/README.in b/README.in
index f7108ac..bcd8c4e 100644
--- a/README.in
+++ b/README.in
@@ -111,15 +111,11 @@ Release notes for 2.14
to GTK_SENSITIVITY_ON, so that the button is always sensitive or
GTK_SENSITIVITY_OFF to make it insensitive respectively.
-* In the early 2.14.x releases, GtkAdjustment was changed to enforce
- that values are restricted to the range [lower, upper - page_size].
- This has always been the documented behaviour, and the recommended
- practice is to set page_size to 0 when using adjustments for simple
- scalar values, like in a slider or spin button.
- Due to the large number of applications that are affected by this
- change, the behaviour has been reverted to the old behaviour in
- 2.14.3, with an explicit warning that this change will be
- reintroduced in 2.90.
+* GtkAdjustment now enforces that values are restricted to the
+ range [lower, upper - page_size]. This has always been the documented
+ behaviour, and the recommended practice is to set page_size to 0
+ when using adjustments for simple scalar values, like in a slider
+ or spin button.
* gdk-pixbuf will use GIO for mime type detection if possible. For
this to work, shared-mime-info needs to be installed and XDG_DATA_DIRS
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c
index 49f5008..dd1b3f6 100644
--- a/gtk/gtkadjustment.c
+++ b/gtk/gtkadjustment.c
@@ -359,7 +359,11 @@ gtk_adjustment_set_value (GtkAdjustment *adjustment,
{
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- value = CLAMP (value, adjustment->lower, adjustment->upper);
+ /* 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);
if (value != adjustment->value)
{
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index fd92dd0..23b159b 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -4056,13 +4056,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, CLAMP (value, adj->lower, adj->upper - adj->page_size));
+ gtk_adjustment_set_value (adj, value);
}
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, CLAMP (value, 0.0, adj->upper - adj->page_size));
+ gtk_adjustment_set_value (adj, MAX (value, 0.0));
}
}
@@ -4073,13 +4073,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, CLAMP (value, adj->lower, adj->upper - adj->page_size));
+ gtk_adjustment_set_value (adj, value);
}
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, CLAMP (value, 0.0, adj->upper - adj->page_size));
+ gtk_adjustment_set_value (adj, MAX (value, 0.0));
}
}
}
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index ebb63a1..4f07208 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1496,7 +1496,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, MAX (0, hadjustment->upper - hadjustment->page_size));
+ gtk_adjustment_set_value (hadjustment, hadjustment->upper - hadjustment->page_size);
vadjustment->page_size = allocation->height;
vadjustment->page_increment = allocation->height * 0.9;
@@ -1505,7 +1505,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, MAX (0, vadjustment->upper - vadjustment->page_size));
+ gtk_adjustment_set_value (vadjustment, vadjustment->upper - vadjustment->page_size);
if (gtk_widget_get_realized (widget) &&
icon_view->priv->scroll_to_path)
@@ -1668,17 +1668,11 @@ gtk_icon_view_expose (GtkWidget *widget,
static gboolean
rubberband_scroll_timeout (gpointer 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);
+ GtkIconView *icon_view = data;
- gtk_adjustment_set_value (icon_view->priv->vadjustment, value);
+ gtk_adjustment_set_value (icon_view->priv->vadjustment,
+ icon_view->priv->vadjustment->value +
+ icon_view->priv->scroll_value_diff);
gtk_icon_view_update_rubberband (icon_view);
@@ -4380,7 +4374,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
{
gint x, y;
gint focus_width;
- gfloat offset, value;
+ gfloat offset;
gtk_widget_style_get (GTK_WIDGET (icon_view),
"focus-line-width", &focus_width,
@@ -4390,17 +4384,15 @@ 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);
- 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);
+
+ gtk_adjustment_set_value (icon_view->priv->vadjustment,
+ icon_view->priv->vadjustment->value + offset);
offset = x + item->x - focus_width -
col_align * (GTK_WIDGET (icon_view)->allocation.width - item->width);
- 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_set_value (icon_view->priv->hadjustment,
+ icon_view->priv->hadjustment->value + offset);
gtk_adjustment_changed (icon_view->priv->hadjustment);
gtk_adjustment_changed (icon_view->priv->vadjustment);
@@ -6485,7 +6477,6 @@ 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);
@@ -6500,19 +6491,12 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view)
hoffset = MAX (px - (x + width - 2 * SCROLL_EDGE_SIZE), 0);
if (voffset != 0)
- {
- 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);
- }
+ gtk_adjustment_set_value (icon_view->priv->vadjustment,
+ icon_view->priv->vadjustment->value + voffset);
+
if (hoffset != 0)
- {
- 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);
- }
+ gtk_adjustment_set_value (icon_view->priv->hadjustment,
+ icon_view->priv->hadjustment->value + hoffset);
}
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 6d94219..42dfa1c 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1207,9 +1207,6 @@ 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);
}
@@ -1234,9 +1231,6 @@ 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 bf3cda9..11adb7a 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1220,8 +1220,6 @@ 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;
@@ -1513,13 +1511,11 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
if (range && gtk_widget_get_visible (range))
{
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
- gdouble delta, new_value;
+ gdouble delta;
delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event->direction);
- new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size);
-
- gtk_adjustment_set_value (adj, new_value);
+ gtk_adjustment_set_value (adj, adj->value + delta);
return TRUE;
}
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index cebdd55..32934bc 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -1702,13 +1702,6 @@ gtk_spin_button_new_with_range (gdouble min,
return GTK_WIDGET (spin);
}
-static void
-warn_nonzero_page_size (GtkAdjustment *adjustment)
-{
- if (gtk_adjustment_get_page_size (adjustment) != 0.0)
- g_warning ("GtkSpinButton: setting an adjustment with non-zero page size is deprecated");
-}
-
/* Callback used when the spin button's adjustment changes. We need to redraw
* the arrows when the adjustment's range changes, and reevaluate our size request.
*/
@@ -1720,7 +1713,6 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data)
spin_button = GTK_SPIN_BUTTON (data);
spin_button->timer_step = spin_button->adjustment->step_increment;
- warn_nonzero_page_size (adjustment);
gtk_widget_queue_resize (GTK_WIDGET (spin_button));
}
@@ -1760,7 +1752,6 @@ gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
G_CALLBACK (adjustment_changed_cb),
spin_button);
spin_button->timer_step = spin_button->adjustment->step_increment;
- warn_nonzero_page_size (adjustment);
}
gtk_widget_queue_resize (GTK_WIDGET (spin_button));
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 09f2067..6192e84 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -3675,7 +3675,6 @@ 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;
@@ -3691,9 +3690,8 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view)
return;
}
- 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);
+ gtk_adjustment_set_value (tree_view->priv->vadjustment,
+ MAX (tree_view->priv->vadjustment->value + offset, 0.0));
}
static gboolean
@@ -3702,7 +3700,6 @@ 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);
@@ -3718,9 +3715,8 @@ gtk_tree_view_horizontal_autoscroll (GtkTreeView *tree_view)
}
offset = offset/3;
- 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);
+ gtk_adjustment_set_value (tree_view->priv->hadjustment,
+ MAX (tree_view->priv->hadjustment->value + offset, 0.0));
return TRUE;
@@ -8938,11 +8934,7 @@ gtk_tree_view_clamp_column_visible (GtkTreeView *tree_view,
}
}
- 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));
+ gtk_adjustment_set_value (tree_view->priv->hadjustment, x);
}
else
{
@@ -11596,9 +11588,9 @@ gtk_tree_view_scroll_to_point (GtkTreeView *tree_view,
vadj = tree_view->priv->vadjustment;
if (tree_x != -1)
- gtk_adjustment_set_value (hadj, CLAMP (tree_x, hadj->lower, hadj->upper - hadj->page_size));
+ gtk_adjustment_set_value (hadj, tree_x);
if (tree_y != -1)
- gtk_adjustment_set_value (vadj, CLAMP (tree_y, vadj->lower, vadj->upper - vadj->page_size));
+ gtk_adjustment_set_value (vadj, tree_y);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]