diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-09-01 16:57:43 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-09-01 16:57:43 +0800 |
commit | 0a380243b1363ab2477a8fd846d4fae92bb24912 (patch) | |
tree | 3fcff7865dd55c37a41de2ebe9db95b830131ed5 /widgets/table | |
parent | 68b88043e3703a33c3de69309b86285693cea438 (diff) | |
download | gsoc2013-evolution-0a380243b1363ab2477a8fd846d4fae92bb24912.tar.gz gsoc2013-evolution-0a380243b1363ab2477a8fd846d4fae92bb24912.tar.zst gsoc2013-evolution-0a380243b1363ab2477a8fd846d4fae92bb24912.zip |
add signals/prototypes for e_tree_model_node_collapsed and
2000-09-01 Chris Toshok <toshok@helixcode.com>
* e-tree-model.h: add signals/prototypes for
e_tree_model_node_collapsed and e_tree_model_node_expanded.
* e-tree-model.c (etree_set_expanded): emit
node_expanded/node_collapsed signals, with node_expanded happening
before the expansion so it can much with the children, and
collapsed being emitted after.
(e_tree_model_row_of_node): remove stupid check, and g_warning.
(e_tree_model_node_collapsed): new function.
(e_tree_model_node_expanded): new function.
svn path=/trunk/; revision=5162
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-tree-model.c | 64 | ||||
-rw-r--r-- | widgets/table/e-tree-model.h | 10 |
2 files changed, 63 insertions, 11 deletions
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c index f6d8ddddd5..2744bc1cd2 100644 --- a/widgets/table/e-tree-model.c +++ b/widgets/table/e-tree-model.c @@ -31,6 +31,8 @@ enum { NODE_CHANGED, NODE_INSERTED, NODE_REMOVED, + NODE_COLLAPSED, + NODE_EXPANDED, LAST_SIGNAL }; @@ -129,7 +131,7 @@ etree_set_expanded (ETreeModel *etm, ETreePath* node, gboolean expanded) GNode *child; ENode *enode; int row; - + g_return_if_fail (node && node->data); enode = ((ENode*)node->data); @@ -137,12 +139,23 @@ etree_set_expanded (ETreeModel *etm, ETreePath* node, gboolean expanded) if (enode->expanded == expanded) return; + if (expanded) { + gboolean allow_expand = TRUE; + e_tree_model_node_expanded (etm, node, &allow_expand); + if (!allow_expand) + return; + } + enode->expanded = expanded; /* if the node wasn't visible at present */ - if ((row = e_tree_model_row_of_node (etm, node)) == -1) + if ((row = e_tree_model_row_of_node (etm, node)) == -1) { + if (!expanded) { + e_tree_model_node_collapsed (etm, node); + } return; - + } + row++; if (expanded) { @@ -183,6 +196,8 @@ etree_set_expanded (ETreeModel *etm, ETreePath* node, gboolean expanded) } enode->visible_descendents = 0; + + e_tree_model_node_collapsed (etm, node); } } @@ -332,6 +347,22 @@ e_tree_model_class_init (GtkObjectClass *klass) gtk_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); + e_tree_model_signals [NODE_COLLAPSED] = + gtk_signal_new ("node_collapsed", + GTK_RUN_LAST, + klass->type, + GTK_SIGNAL_OFFSET (ETreeModelClass, node_collapsed), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + + e_tree_model_signals [NODE_EXPANDED] = + gtk_signal_new ("node_expanded", + GTK_RUN_LAST, + klass->type, + GTK_SIGNAL_OFFSET (ETreeModelClass, node_expanded), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); + gtk_object_class_add_signals (klass, e_tree_model_signals, LAST_SIGNAL); table_class->row_count = etable_row_count; @@ -404,6 +435,28 @@ e_tree_model_node_removed (ETreeModel *tree_model, ETreePath *parent_node, ETre parent_node, removed_node); } +void +e_tree_model_node_collapsed (ETreeModel *tree_model, ETreePath *node) +{ + g_return_if_fail (tree_model != NULL); + g_return_if_fail (E_IS_TREE_MODEL (tree_model)); + + gtk_signal_emit (GTK_OBJECT (tree_model), + e_tree_model_signals [NODE_COLLAPSED], + node); +} + +void +e_tree_model_node_expanded (ETreeModel *tree_model, ETreePath *node, gboolean *allow_expand) +{ + g_return_if_fail (tree_model != NULL); + g_return_if_fail (E_IS_TREE_MODEL (tree_model)); + + gtk_signal_emit (GTK_OBJECT (tree_model), + e_tree_model_signals [NODE_EXPANDED], + node, allow_expand); +} + void e_tree_model_construct (ETreeModel *etree) @@ -446,15 +499,10 @@ e_tree_model_row_of_node (ETreeModel *etree, ETreePath *node) { int i; - if (etree->root == node) - return -1; - for (i = 0; i < etree->row_array->len; i ++) if (g_array_index (etree->row_array, GNode*, i) == node) return i; - g_warning ("e_tree_model_row_of_node failed for node %p\n", node); - return -1; } diff --git a/widgets/table/e-tree-model.h b/widgets/table/e-tree-model.h index 403aff9a30..70464f094c 100644 --- a/widgets/table/e-tree-model.h +++ b/widgets/table/e-tree-model.h @@ -53,9 +53,11 @@ typedef struct { /* * Signals */ - void (*node_changed) (ETreeModel *etm, ETreePath *node); - void (*node_inserted) (ETreeModel *etm, ETreePath *parent, ETreePath *inserted_node); - void (*node_removed) (ETreeModel *etm, ETreePath *parent, ETreePath *removed_node); + void (*node_changed) (ETreeModel *etm, ETreePath *node); + void (*node_inserted) (ETreeModel *etm, ETreePath *parent, ETreePath *inserted_node); + void (*node_removed) (ETreeModel *etm, ETreePath *parent, ETreePath *removed_node); + void (*node_collapsed) (ETreeModel *etm, ETreePath *node); + void (*node_expanded) (ETreeModel *etm, ETreePath *node, gboolean *allow_expand); } ETreeModelClass; @@ -103,5 +105,7 @@ void e_tree_model_node_sort (ETreeModel *tree_model, ETreePath *node, GCompareFu void e_tree_model_node_changed (ETreeModel *tree_model, ETreePath *node); void e_tree_model_node_inserted (ETreeModel *tree_model, ETreePath *parent_node, ETreePath *inserted_node); void e_tree_model_node_removed (ETreeModel *tree_model, ETreePath *parent_node, ETreePath *removed_node); +void e_tree_model_node_collapsed (ETreeModel *tree_model, ETreePath *node); +void e_tree_model_node_expanded (ETreeModel *tree_model, ETreePath *node, gboolean *allow_expand); #endif /* _E_TREE_MODEL_H */ |