]> Pileus Git - ~andy/gtk/commitdiff
clear scroll_to_path if the model changes.
authorJonathan Blandford <jrb@redhat.com>
Sat, 20 Aug 2005 20:16:34 +0000 (20:16 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Sat, 20 Aug 2005 20:16:34 +0000 (20:16 +0000)
Sat Aug 20 16:12:14 2005  Jonathan Blandford  <jrb@redhat.com>

        * gtk/gtktreeview.c (gtk_tree_view_set_model): clear
        scroll_to_path if the model changes.

        * gtk/gtkiconview.c: (gtk_icon_view_destroy),
        (gtk_icon_view_size_allocate), (gtk_icon_view_set_cursor),
        (gtk_icon_view_scroll_to_path): Handle scrolling to a path before
        we're realized, #312798
        (gtk_icon_view_set_model): clear scroll_to_path if the model
        changes.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkiconview.c
gtk/gtktreeview.c

index f93e4b7c7d5cc614d4b574865eea4ce687ba3313..a0c88cc9fc7b410aa3d6a5404f956138ea0e5569 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Sat Aug 20 16:12:14 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeview.c (gtk_tree_view_set_model): clear
+       scroll_to_path if the model changes.
+
+       * gtk/gtkiconview.c: (gtk_icon_view_destroy),
+       (gtk_icon_view_size_allocate), (gtk_icon_view_set_cursor),
+       (gtk_icon_view_scroll_to_path): Handle scrolling to a path before
+       we're realized, #312798
+       (gtk_icon_view_set_model): clear scroll_to_path if the model
+       changes.
+
 2005-08-20  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkrange.c (gtk_range_adjustment_changed) 
index f93e4b7c7d5cc614d4b574865eea4ce687ba3313..a0c88cc9fc7b410aa3d6a5404f956138ea0e5569 100644 (file)
@@ -1,3 +1,15 @@
+Sat Aug 20 16:12:14 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeview.c (gtk_tree_view_set_model): clear
+       scroll_to_path if the model changes.
+
+       * gtk/gtkiconview.c: (gtk_icon_view_destroy),
+       (gtk_icon_view_size_allocate), (gtk_icon_view_set_cursor),
+       (gtk_icon_view_scroll_to_path): Handle scrolling to a path before
+       we're realized, #312798
+       (gtk_icon_view_set_model): clear scroll_to_path if the model
+       changes.
+
 2005-08-20  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkrange.c (gtk_range_adjustment_changed) 
index f93e4b7c7d5cc614d4b574865eea4ce687ba3313..a0c88cc9fc7b410aa3d6a5404f956138ea0e5569 100644 (file)
@@ -1,3 +1,15 @@
+Sat Aug 20 16:12:14 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeview.c (gtk_tree_view_set_model): clear
+       scroll_to_path if the model changes.
+
+       * gtk/gtkiconview.c: (gtk_icon_view_destroy),
+       (gtk_icon_view_size_allocate), (gtk_icon_view_set_cursor),
+       (gtk_icon_view_scroll_to_path): Handle scrolling to a path before
+       we're realized, #312798
+       (gtk_icon_view_set_model): clear scroll_to_path if the model
+       changes.
+
 2005-08-20  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkrange.c (gtk_range_adjustment_changed) 
index f589fe51537d33e2f81a70521b1c4a94c04581a8..215461af87d4c3840686e6d04ae09baa153ac822 100644 (file)
@@ -74,6 +74,7 @@ struct _GtkIconViewItem
 
   guint selected : 1;
   guint selected_before_rubberbanding : 1;
+
 };
 
 typedef struct _GtkIconViewCellInfo GtkIconViewCellInfo;
@@ -172,6 +173,12 @@ struct _GtkIconViewPrivate
   GtkTreeRowReference *dest_item;
   GtkIconViewDropPosition dest_pos;
 
+  /* scroll to */
+  GtkTreeRowReference *scroll_to_path;
+  gfloat scroll_to_row_align;
+  gfloat scroll_to_col_align;
+  guint scroll_to_use_align : 1;
+
   guint source_set : 1;
   guint dest_set : 1;
   guint reorderable : 1;
@@ -923,7 +930,16 @@ gtk_icon_view_destroy (GtkObject *object)
   gtk_icon_view_set_model (icon_view, NULL);
   
   if (icon_view->priv->layout_idle_id != 0)
-    g_source_remove (icon_view->priv->layout_idle_id);
+    {
+      g_source_remove (icon_view->priv->layout_idle_id);
+      icon_view->priv->layout_idle_id = 0;
+    }
+
+  if (icon_view->priv->scroll_to_path != NULL)
+    {
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+    }
 
   remove_scroll_timeout (icon_view);
   
@@ -1229,8 +1245,25 @@ gtk_icon_view_size_allocate (GtkWidget      *widget,
   if (vadjustment->value > vadjustment->upper - vadjustment->page_size)
     gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size));
 
-  gtk_adjustment_changed (hadjustment);
-  gtk_adjustment_changed (vadjustment);
+  if (GTK_WIDGET_REALIZED (widget) &&
+      icon_view->priv->scroll_to_path)
+    {
+      GtkTreePath *path;
+      path = gtk_tree_row_reference_get_path (icon_view->priv->scroll_to_path);
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+
+      gtk_icon_view_scroll_to_path (icon_view, path,
+                                   icon_view->priv->scroll_to_use_align,
+                                   icon_view->priv->scroll_to_row_align,
+                                   icon_view->priv->scroll_to_col_align);
+      gtk_tree_path_free (path);
+    }
+  else
+    {
+      gtk_adjustment_changed (hadjustment);
+      gtk_adjustment_changed (vadjustment);
+    }
 }
 
 static gboolean
@@ -1711,9 +1744,10 @@ gtk_icon_view_set_cursor (GtkIconView     *icon_view,
   g_return_if_fail (cell == NULL || GTK_IS_CELL_RENDERER (cell));
 
   gtk_icon_view_stop_editing (icon_view, TRUE);
-  
-  item = g_list_nth (icon_view->priv->items,
-                    gtk_tree_path_get_indices(path)[0])->data;
+
+  if (gtk_tree_path_get_depth (path) == 1)
+    item = g_list_nth (icon_view->priv->items,
+                      gtk_tree_path_get_indices(path)[0])->data;
   
   if (!item)
     return;
@@ -1733,7 +1767,11 @@ gtk_icon_view_set_cursor (GtkIconView     *icon_view,
     }
 
   gtk_icon_view_set_cursor_item (icon_view, item, cell_pos);
-  gtk_icon_view_scroll_to_item (icon_view, item);
+  if (FALSE && GTK_WIDGET_REALIZED (icon_view))
+    gtk_icon_view_scroll_to_item (icon_view, item);
+  else
+    gtk_icon_view_scroll_to_path (icon_view, path,
+                                 FALSE, 0.0, 0.0);
 
   if (start_editing)
     gtk_icon_view_start_editing (icon_view, item, info, NULL);
@@ -3905,7 +3943,7 @@ gtk_icon_view_move_cursor_start_end (GtkIconView *icon_view,
  * position.  If the item is currently visible on the screen, nothing is done.
  *
  * This function only works if the model is set, and @path is a valid row on the
- * model.  If the model changes before the @tree_view is realized, the centered
+ * model.  If the model changes before the @icon_view is realized, the centered
  * path will be modified to reflect this change.
  *
  * Since: 2.8
@@ -3923,14 +3961,31 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
   g_return_if_fail (path != NULL);
   g_return_if_fail (row_align >= 0.0 && row_align <= 1.0);
   g_return_if_fail (col_align >= 0.0 && col_align <= 1.0);
-  
+
+  if (! GTK_WIDGET_REALIZED (icon_view))
+    {
+      if (icon_view->priv->scroll_to_path)
+       gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+
+      icon_view->priv->scroll_to_path = NULL;
+
+      if (path)
+       icon_view->priv->scroll_to_path = gtk_tree_row_reference_new_proxy (G_OBJECT (icon_view), icon_view->priv->model, path);
+
+      icon_view->priv->scroll_to_use_align = use_align;
+      icon_view->priv->scroll_to_row_align = row_align;
+      icon_view->priv->scroll_to_col_align = col_align;
+
+      return;
+    }
+
   if (gtk_tree_path_get_depth (path) > 0)
     item = g_list_nth_data (icon_view->priv->items,
                            gtk_tree_path_get_indices(path)[0]);
   
   if (!item)
     return;
-  
+
   if (use_align)
     {
       gint x, y, width, height;
@@ -3961,7 +4016,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
       gtk_adjustment_changed (icon_view->priv->vadjustment);
     }
   else
-    gtk_icon_view_scroll_to_item (icon_view, item);    
+    gtk_icon_view_scroll_to_item (icon_view, item);
 }
 
 
@@ -4534,6 +4589,12 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
   if (icon_view->priv->model == model)
     return;
 
+  if (icon_view->priv->scroll_to_path)
+    {
+      gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+      icon_view->priv->scroll_to_path = NULL;
+    }
+
   gtk_icon_view_stop_editing (icon_view, TRUE);
 
   if (model)
index 2cd3d3f057c1696d494240a23079475a51618191..d7fc33c383d249c3a160c2305978fa0cd9088706 100644 (file)
@@ -9444,6 +9444,12 @@ gtk_tree_view_set_model (GtkTreeView  *tree_view,
   if (model == tree_view->priv->model)
     return;
 
+  if (tree_view->priv->scroll_to_path)
+    {
+      gtk_tree_row_reference_free (tree_view->priv->scroll_to_path);
+      tree_view->priv->scroll_to_path = NULL;
+    }
+
   if (tree_view->priv->model)
     {
       GList *tmplist = tree_view->priv->columns;