diff --git a/ChangeLog b/ChangeLog index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 03a1be9b1f..8901d288a2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +Tue Jun 26 12:59:28 2001 Jonathan Blandford + + * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_model): fix + stupid missing statement + + * gtk/gtktreeview.c (gtk_tree_view_set_destroy_count_func): New + private function for ATK. It notifies you of how many _visible_ + children are deleted when a node is deleted. Should be used by + atk only. + Tue Jun 26 11:06:34 2001 Owen Taylor * gtk/gtkclist.c gtk/gtkentry.c gtk/gtkspinbutton.c: diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c index d331a9e852..b9fa1eb663 100644 --- a/gtk/gtktreemodelsort.c +++ b/gtk/gtktreemodelsort.c @@ -278,7 +278,7 @@ gtk_tree_model_sort_set_model (GtkTreeModelSort *tree_model_sort, if (tree_model_sort->root) { gtk_tree_model_sort_free_level (tree_model_sort->root); - tree_model_sort->root; + tree_model_sort->root = NULL; } if (tree_model_sort->sort_list) diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h index 4af2b90d22..b27ca1baa9 100644 --- a/gtk/gtktreeprivate.h +++ b/gtk/gtktreeprivate.h @@ -135,6 +135,11 @@ struct _GtkTreeViewPrivate GList *column_drag_info; GtkTreeViewColumnReorder *cur_reorder; + /* ATK Hack */ + GtkTreeDestroyCountFunc destroy_count_func; + gpointer destroy_count_data; + GtkDestroyNotify destroy_count_destroy; + /* Scroll timeout (e.g. during dnd) */ guint scroll_timeout; diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index e7a72268f3..a82650da44 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -836,7 +836,6 @@ gtk_tree_view_init (GtkTreeView *tree_view) gtk_tree_view_set_adjustments (tree_view, NULL, NULL); tree_view->priv->selection = _gtk_tree_selection_new_with_tree_view (tree_view); _gtk_tree_view_update_size (tree_view); - } @@ -995,6 +994,13 @@ gtk_tree_view_destroy (GtkObject *object) tree_view->priv->column_drop_func_data = NULL; } + if (tree_view->priv->destroy_count_destroy && + tree_view->priv->destroy_count_data) + { + (* tree_view->priv->destroy_count_destroy) (tree_view->priv->destroy_count_data); + tree_view->priv->destroy_count_data = NULL; + } + gtk_tree_row_reference_free (tree_view->priv->cursor); tree_view->priv->cursor = NULL; @@ -4414,6 +4420,16 @@ gtk_tree_view_has_child_toggled (GtkTreeModel *model, gtk_tree_path_free (path); } +static void +count_children_helper (GtkRBTree *tree, + GtkRBNode *node, + gpointer data) +{ + if (node->children) + _gtk_rbtree_traverse (node->children, node->children->root, G_POST_ORDER, count_children_helper, data); + ((gint *)data)++; +} + static void gtk_tree_view_deleted (GtkTreeModel *model, GtkTreePath *path, @@ -4446,6 +4462,14 @@ gtk_tree_view_deleted (GtkTreeModel *model, /* Ensure we don't have a dangling pointer to a dead node */ ensure_unprelighted (tree_view); + if (tree_view->priv->destroy_count_func) + { + gint child_count = 0; + if (node->children) + _gtk_rbtree_traverse (node->children, node->children->root, G_POST_ORDER, count_children_helper, &child_count); + (* tree_view->priv->destroy_count_func) (tree_view, path, child_count, tree_view->priv->destroy_count_data); + } + if (tree->root->count == 1) { if (tree_view->priv->tree == tree) @@ -7148,6 +7172,14 @@ gtk_tree_view_real_collapse_row (GtkTreeView *tree_view, /* Ensure we don't have a dangling pointer to a dead node */ ensure_unprelighted (tree_view); + if (tree_view->priv->destroy_count_func) + { + gint child_count = 0; + if (node->children) + _gtk_rbtree_traverse (node->children, node->children->root, G_POST_ORDER, count_children_helper, &child_count); + (* tree_view->priv->destroy_count_func) (tree_view, path, child_count, tree_view->priv->destroy_count_data); + } + if (gtk_tree_view_unref_and_check_selection_tree (tree_view, node->children)) g_signal_emit_by_name (G_OBJECT (tree_view->priv->selection), "changed", 0); _gtk_rbtree_remove (node->children); @@ -8158,3 +8190,30 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view, return drawable; } + +/** + * gtk_tree_view_set_destroy_count_func: + * @tree_view: A #GtkTreeView + * @func: Function to be called when a view row is destroyed, or NULL + * @data: User data to be passed to @func, or NULL + * @destroy: Destroy notifier for @data, or NULL + * + * This function should almost never be used. It is meant for private use by + * ATK for determining the number of visible rows that are removed when the user + * collapses a row, or a row is deleted. + **/ +void +gtk_tree_view_set_destroy_count_func (GtkTreeView *tree_view, + GtkTreeDestroyCountFunc func, + gpointer data, + GtkDestroyNotify destroy) +{ + g_return_if_fail (GTK_IS_TREE_VIEW (tree_view)); + + if (tree_view->priv->destroy_count_destroy) + (* tree_view->priv->destroy_count_destroy) (tree_view->priv->destroy_count_data); + + tree_view->priv->destroy_count_func = func; + tree_view->priv->destroy_count_data = data; + tree_view->priv->destroy_count_destroy = destroy; +} diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h index b459677a91..72faba4085 100644 --- a/gtk/gtktreeview.h +++ b/gtk/gtktreeview.h @@ -275,6 +275,21 @@ gboolean gtk_tree_view_get_dest_row_at_pos (GtkTreeView GdkPixmap *gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view, GtkTreePath *path); + +/* This function should really never be used. It is just for use by ATK. + */ +typedef void (* GtkTreeDestroyCountFunc) (GtkTreeView *tree_view, + GtkTreePath *path, + gint children, + gpointer user_data); +void gtk_tree_view_set_destroy_count_func (GtkTreeView *tree_view, + GtkTreeDestroyCountFunc func, + gpointer data, + GtkDestroyNotify destroy); + + + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/tests/testtreeview.c b/tests/testtreeview.c index a8bfed3dd1..204d4574b2 100644 --- a/tests/testtreeview.c +++ b/tests/testtreeview.c @@ -1446,10 +1446,11 @@ run_automated_tests (void) { /* Make sure tree store mutations don't crash anything */ GtkTreeStore *store; - + GtkTreeIter root; + store = gtk_tree_store_new_with_types (1, G_TYPE_INT); - - treestore_torture_recurse (store, NULL, 0); + gtk_tree_model_get_iter_root (GTK_TREE_MODEL (store), &root); + treestore_torture_recurse (store, &root, 0); g_object_unref (G_OBJECT (store)); }