Commit 461216d4 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Bug fix to make trees work again when not sorted.

Mon Apr  2 19:36:57 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktreestore.c (gtk_tree_store_init):  Bug fix to make trees
	work again when not sorted.

	* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
	and "expand_row" signal, closing bug 52578.

	* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
	support.

	* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
	support.
parent b52b326d
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
Mon Apr 2 19:36:57 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_init): Bug fix to make trees
work again when not sorted.
* gtk/gtktreeview.c (gtk_tree_view_class_init): Add "collapse_row"
and "expand_row" signal, closing bug 52578.
* gtk/gtktreeview.c (gtk_tree_view_expand_row): Add signal
support.
* gtk/gtktreeview.c (gtk_tree_view_collapse_row): Add signal
support.
Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com> Mon Apr 2 18:18:07 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.h: Add GdkEventSetting event for notification * gdk/gdkevents.h: Add GdkEventSetting event for notification
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
# BOOL deprecated alias for BOOLEAN # BOOL deprecated alias for BOOLEAN
BOOLEAN:BOXED BOOLEAN:BOXED
BOOLEAN:BOXED,BOXED
BOOLEAN:OBJECT,INT,INT,UINT BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED,BOXED BOOLEAN:OBJECT,BOXED,BOXED
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
# BOOL deprecated alias for BOOLEAN # BOOL deprecated alias for BOOLEAN
BOOLEAN:BOXED BOOLEAN:BOXED
BOOLEAN:BOXED,BOXED
BOOLEAN:OBJECT,INT,INT,UINT BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED,BOXED BOOLEAN:OBJECT,BOXED,BOXED
......
...@@ -228,6 +228,7 @@ gtk_tree_store_init (GtkTreeStore *tree_store) ...@@ -228,6 +228,7 @@ gtk_tree_store_init (GtkTreeStore *tree_store)
tree_store->root = g_node_new (NULL); tree_store->root = g_node_new (NULL);
tree_store->stamp = g_random_int (); tree_store->stamp = g_random_int ();
tree_store->sort_list = NULL; tree_store->sort_list = NULL;
tree_store->sort_column_id = -1;
} }
GtkTreeStore * GtkTreeStore *
......
...@@ -62,6 +62,8 @@ struct _GtkTreeViewChild ...@@ -62,6 +62,8 @@ struct _GtkTreeViewChild
enum enum
{ {
ROW_ACTIVATED, ROW_ACTIVATED,
EXPAND_ROW,
COLLAPSE_ROW,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -401,15 +403,35 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) ...@@ -401,15 +403,35 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
GTK_TYPE_NONE, 2, GTK_TYPE_NONE, 2,
GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
tree_view_signals[ROW_ACTIVATED] = gtk_signal_new ("row_activated", tree_view_signals[ROW_ACTIVATED] =
GTK_RUN_LAST | GTK_RUN_ACTION, gtk_signal_new ("row_activated",
GTK_CLASS_TYPE (object_class), GTK_RUN_LAST | GTK_RUN_ACTION,
GTK_SIGNAL_OFFSET (GtkTreeViewClass, row_activated), GTK_CLASS_TYPE (object_class),
gtk_marshal_VOID__BOXED_OBJECT, GTK_SIGNAL_OFFSET (GtkTreeViewClass, row_activated),
GTK_TYPE_NONE, 2, gtk_marshal_VOID__BOXED_OBJECT,
GTK_TYPE_TREE_PATH, GTK_TYPE_NONE, 2,
GTK_TYPE_TREE_VIEW_COLUMN); GTK_TYPE_TREE_PATH,
GTK_TYPE_TREE_VIEW_COLUMN);
tree_view_signals[EXPAND_ROW] =
g_signal_newc ("expand_row",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTreeViewClass, expand_row),
_gtk_boolean_handled_accumulator, NULL,
gtk_marshal_BOOLEAN__BOXED_BOXED,
G_TYPE_BOOLEAN, 2,
GTK_TYPE_TREE_ITER,
GTK_TYPE_TREE_PATH);
tree_view_signals[COLLAPSE_ROW] =
g_signal_newc ("collapse_row",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTreeViewClass, collapse_row),
_gtk_boolean_handled_accumulator, NULL,
gtk_marshal_BOOLEAN__BOXED_BOXED,
G_TYPE_BOOLEAN, 2,
GTK_TYPE_TREE_ITER,
GTK_TYPE_TREE_PATH);
} }
static void static void
...@@ -1992,47 +2014,67 @@ gtk_tree_view_button_release (GtkWidget *widget, ...@@ -1992,47 +2014,67 @@ gtk_tree_view_button_release (GtkWidget *widget,
if (tree_view->priv->button_pressed_node == tree_view->priv->prelight_node && if (tree_view->priv->button_pressed_node == tree_view->priv->prelight_node &&
GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_ARROW_PRELIT)) GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_ARROW_PRELIT))
{ {
GtkTreePath *path; GtkTreePath *path = NULL;
GtkTreeIter iter; GtkTreeIter iter;
/* Actually activate the node */ /* Actually activate the node */
if (tree_view->priv->button_pressed_node->children == NULL) if (tree_view->priv->button_pressed_node->children == NULL)
{ {
GtkTreeIter child; GtkTreeIter child;
path = _gtk_tree_view_find_path (GTK_TREE_VIEW (widget), path = _gtk_tree_view_find_path (tree_view,
tree_view->priv->button_pressed_tree, tree_view->priv->button_pressed_tree,
tree_view->priv->button_pressed_node); tree_view->priv->button_pressed_node);
tree_view->priv->button_pressed_node->children = _gtk_rbtree_new ();
tree_view->priv->button_pressed_node->children->parent_tree = tree_view->priv->button_pressed_tree;
tree_view->priv->button_pressed_node->children->parent_node = tree_view->priv->button_pressed_node;
gtk_tree_model_get_iter (tree_view->priv->model, &iter, path); gtk_tree_model_get_iter (tree_view->priv->model, &iter, path);
if (gtk_tree_model_iter_children (tree_view->priv->model, &child, &iter)) if (gtk_tree_model_iter_children (tree_view->priv->model, &child, &iter))
gtk_tree_view_build_tree (tree_view, {
tree_view->priv->button_pressed_node->children, gboolean expand;
&child, g_signal_emit (G_OBJECT (tree_view), tree_view_signals[EXPAND_ROW], 0, &iter, path, &expand);
gtk_tree_path_get_depth (path) + 1, if (! expand)
FALSE, {
GTK_WIDGET_REALIZED (widget)); tree_view->priv->button_pressed_node->children = _gtk_rbtree_new ();
tree_view->priv->button_pressed_node->children->parent_tree = tree_view->priv->button_pressed_tree;
tree_view->priv->button_pressed_node->children->parent_node = tree_view->priv->button_pressed_node;
gtk_tree_view_build_tree (tree_view,
tree_view->priv->button_pressed_node->children,
&child,
gtk_tree_path_get_depth (path) + 1,
FALSE,
GTK_WIDGET_REALIZED (widget));
}
}
} }
else else
{ {
gboolean collapse;
path = _gtk_tree_view_find_path (GTK_TREE_VIEW (widget), path = _gtk_tree_view_find_path (GTK_TREE_VIEW (widget),
tree_view->priv->button_pressed_node->children, tree_view->priv->button_pressed_tree,
tree_view->priv->button_pressed_node->children->root); tree_view->priv->button_pressed_node);
gtk_tree_model_get_iter (tree_view->priv->model, gtk_tree_model_get_iter (tree_view->priv->model,
&iter, &iter,
path); path);
g_signal_emit (G_OBJECT (tree_view), tree_view_signals[COLLAPSE_ROW], 0, &iter, path, &collapse);
gtk_tree_view_discover_dirty (GTK_TREE_VIEW (widget), if (! collapse)
tree_view->priv->button_pressed_node->children, {
&iter, GtkTreeIter child_iter;
gtk_tree_path_get_depth (path)); gtk_tree_path_append_index (path, 0);
gtk_tree_view_unref_tree (GTK_TREE_VIEW (widget), gtk_tree_model_iter_children (tree_view->priv->model,
tree_view->priv->button_pressed_node->children); &child_iter,
_gtk_rbtree_remove (tree_view->priv->button_pressed_node->children); &iter);
gtk_tree_view_discover_dirty (GTK_TREE_VIEW (widget),
tree_view->priv->button_pressed_node->children,
&child_iter,
gtk_tree_path_get_depth (path));
gtk_tree_view_unref_tree (GTK_TREE_VIEW (widget),
tree_view->priv->button_pressed_node->children);
_gtk_rbtree_remove (tree_view->priv->button_pressed_node->children);
}
} }
gtk_tree_path_free (path); if (path)
gtk_tree_path_free (path);
_gtk_tree_view_update_size (GTK_TREE_VIEW (widget)); _gtk_tree_view_update_size (GTK_TREE_VIEW (widget));
} }
...@@ -5181,6 +5223,7 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view, ...@@ -5181,6 +5223,7 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view,
GtkTreeIter child; GtkTreeIter child;
GtkRBTree *tree; GtkRBTree *tree;
GtkRBNode *node; GtkRBNode *node;
gboolean expand;
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE); g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
g_return_val_if_fail (tree_view->priv->model != NULL, FALSE); g_return_val_if_fail (tree_view->priv->model != NULL, FALSE);
...@@ -5199,6 +5242,11 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view, ...@@ -5199,6 +5242,11 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view,
if (! gtk_tree_model_iter_has_child (tree_view->priv->model, &iter)) if (! gtk_tree_model_iter_has_child (tree_view->priv->model, &iter))
return FALSE; return FALSE;
g_signal_emit (G_OBJECT (tree_view), tree_view_signals[EXPAND_ROW], 0, &iter, path, &expand);
if (expand)
return FALSE;
node->children = _gtk_rbtree_new (); node->children = _gtk_rbtree_new ();
node->children->parent_tree = tree; node->children->parent_tree = tree;
node->children->parent_node = node; node->children->parent_node = node;
...@@ -5222,9 +5270,9 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view, ...@@ -5222,9 +5270,9 @@ gtk_tree_view_expand_row (GtkTreeView *tree_view,
* @tree_view: a #GtkTreeView * @tree_view: a #GtkTreeView
* @path: path to a row in the @tree_view * @path: path to a row in the @tree_view
* *
* Collapses a row (hides its child rows). * Collapses a row (hides its child rows, if they exist.)
* *
* Return value: %TRUE if the row was expanded * Return value: %TRUE if the row was collapsed.
**/ **/
gboolean gboolean
gtk_tree_view_collapse_row (GtkTreeView *tree_view, gtk_tree_view_collapse_row (GtkTreeView *tree_view,
...@@ -5233,6 +5281,7 @@ gtk_tree_view_collapse_row (GtkTreeView *tree_view, ...@@ -5233,6 +5281,7 @@ gtk_tree_view_collapse_row (GtkTreeView *tree_view,
GtkRBTree *tree; GtkRBTree *tree;
GtkRBNode *node; GtkRBNode *node;
GtkTreeIter iter; GtkTreeIter iter;
gboolean collapse;
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE); g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
g_return_val_if_fail (tree_view->priv->tree != NULL, FALSE); g_return_val_if_fail (tree_view->priv->tree != NULL, FALSE);
...@@ -5248,6 +5297,12 @@ gtk_tree_view_collapse_row (GtkTreeView *tree_view, ...@@ -5248,6 +5297,12 @@ gtk_tree_view_collapse_row (GtkTreeView *tree_view,
return FALSE; return FALSE;
gtk_tree_model_get_iter (tree_view->priv->model, &iter, path); gtk_tree_model_get_iter (tree_view->priv->model, &iter, path);
g_signal_emit (G_OBJECT (tree_view), tree_view_signals[COLLAPSE_ROW], 0, &iter, path, &collapse);
if (collapse)
return FALSE;
gtk_tree_view_discover_dirty (tree_view, gtk_tree_view_discover_dirty (tree_view,
node->children, node->children,
&iter, &iter,
...@@ -6133,9 +6188,7 @@ open_row_timeout (gpointer data) ...@@ -6133,9 +6188,7 @@ open_row_timeout (gpointer data)
(pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER || (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER ||
pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)) pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE))
{ {
gtk_tree_view_expand_row (tree_view, gtk_tree_view_expand_row (tree_view, dest_path, FALSE);
dest_path,
FALSE);
tree_view->priv->open_dest_timeout = 0; tree_view->priv->open_dest_timeout = 0;
gtk_tree_path_free (dest_path); gtk_tree_path_free (dest_path);
......
...@@ -65,13 +65,17 @@ struct _GtkTreeViewClass ...@@ -65,13 +65,17 @@ struct _GtkTreeViewClass
{ {
GtkContainerClass parent_class; GtkContainerClass parent_class;
void (* set_scroll_adjustments) (GtkTreeView *tree_view, void (* set_scroll_adjustments) (GtkTreeView *tree_view,
GtkAdjustment *hadjustment, GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment); GtkAdjustment *vadjustment);
void (* row_activated) (GtkTreeView *tree_view, void (* row_activated) (GtkTreeView *tree_view,
GtkTreeViewColumn *column); GtkTreeViewColumn *column);
gint (* expand_row) (GtkTreeView *tree_view, gint (* expand_row) (GtkTreeView *tree_view,
GtkTreeIter *iter); GtkTreeIter *iter,
GtkTreePath *path);
gint (* collapse_row) (GtkTreeView *tree_view,
GtkTreeIter *iter,
GtkTreePath *path);
}; };
......
...@@ -64,7 +64,7 @@ set_visible (GtkCellRendererToggle *cell, ...@@ -64,7 +64,7 @@ set_visible (GtkCellRendererToggle *cell,
if (column) if (column)
{ {
gtk_tree_view_column_set_visible (column, ! gtk_tree_view_column_get_visible (column)); gtk_tree_view_column_set_visible (column, ! gtk_tree_view_column_get_visible (column));
gtk_tree_model_changed (model, path, &iter); gtk_tree_model_range_changed (model, path, &iter, path, &iter);
} }
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment