gtk+ r21499 - in branches/gtk-2-14: . gtk



Author: matthiasc
Date: Tue Sep 23 21:23:49 2008
New Revision: 21499
URL: http://svn.gnome.org/viewvc/gtk+?rev=21499&view=rev

Log:
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.



Modified:
   branches/gtk-2-14/ChangeLog
   branches/gtk-2-14/README.in
   branches/gtk-2-14/gtk/gtkadjustment.c
   branches/gtk-2-14/gtk/gtkcombobox.c
   branches/gtk-2-14/gtk/gtkiconview.c
   branches/gtk-2-14/gtk/gtkrange.c
   branches/gtk-2-14/gtk/gtkscrolledwindow.c
   branches/gtk-2-14/gtk/gtktreeview.c

Modified: branches/gtk-2-14/README.in
==============================================================================
--- branches/gtk-2-14/README.in	(original)
+++ branches/gtk-2-14/README.in	Tue Sep 23 21:23:49 2008
@@ -48,11 +48,15 @@
   to GTK_SENSITIVITY_ON, so that the button is always sensitive or
   GTK_SENSITIVITY_OFF to make it insensitive respectively.
 
-* 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. 
+* 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. 
 
 * 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

Modified: branches/gtk-2-14/gtk/gtkadjustment.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkadjustment.c	(original)
+++ branches/gtk-2-14/gtk/gtkadjustment.c	Tue Sep 23 21:23:49 2008
@@ -359,11 +359,7 @@
 {
   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)
     {

Modified: branches/gtk-2-14/gtk/gtkcombobox.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkcombobox.c	(original)
+++ branches/gtk-2-14/gtk/gtkcombobox.c	Tue Sep 23 21:23:49 2008
@@ -4016,13 +4016,13 @@
 	  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));
 	}
     }
 
@@ -4033,13 +4033,13 @@
 	  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));
 	}
     }
 }

Modified: branches/gtk-2-14/gtk/gtkiconview.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkiconview.c	(original)
+++ branches/gtk-2-14/gtk/gtkiconview.c	Tue Sep 23 21:23:49 2008
@@ -1354,7 +1354,7 @@
   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;
@@ -1363,7 +1363,7 @@
   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)
@@ -1520,11 +1520,17 @@
 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);
   
@@ -4202,7 +4208,7 @@
     {
       gint x, y;
       gint focus_width;
-      gfloat offset;
+      gfloat offset, value;
 
       gtk_widget_style_get (GTK_WIDGET (icon_view),
 			    "focus-line-width", &focus_width,
@@ -4212,15 +4218,17 @@
       
       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);
@@ -6279,6 +6287,7 @@
 {
   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);
@@ -6293,12 +6302,19 @@
     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);
+    }
 }
 
 

Modified: branches/gtk-2-14/gtk/gtkrange.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkrange.c	(original)
+++ branches/gtk-2-14/gtk/gtkrange.c	Tue Sep 23 21:23:49 2008
@@ -961,6 +961,9 @@
     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);
 }
@@ -985,6 +988,9 @@
     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);
 }
 

Modified: branches/gtk-2-14/gtk/gtkscrolledwindow.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkscrolledwindow.c	(original)
+++ branches/gtk-2-14/gtk/gtkscrolledwindow.c	Tue Sep 23 21:23:49 2008
@@ -1124,6 +1124,8 @@
 	  break;
 	}
 
+      value = CLAMP (value, adjustment->lower, adjustment->upper - adjustment->page_size);
+      
       gtk_adjustment_set_value (adjustment, value);
 
       return TRUE;
@@ -1507,11 +1509,13 @@
   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;
     }

Modified: branches/gtk-2-14/gtk/gtktreeview.c
==============================================================================
--- branches/gtk-2-14/gtk/gtktreeview.c	(original)
+++ branches/gtk-2-14/gtk/gtktreeview.c	Tue Sep 23 21:23:49 2008
@@ -3611,6 +3611,7 @@
   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;
@@ -3626,8 +3627,9 @@
 	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
@@ -3636,6 +3638,7 @@
   GdkRectangle visible_rect;
   gint x;
   gint offset;
+  gfloat value;
 
   gdk_window_get_pointer (tree_view->priv->bin_window, &x, NULL, NULL);
 
@@ -3651,8 +3654,9 @@
     }
   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;
 
@@ -8946,7 +8950,11 @@
 	    }
 	}
 
-      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
     {
@@ -11591,9 +11599,9 @@
   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));
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]