aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-tree-model.h
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-10-16 07:17:56 +0800
committerChris Toshok <toshok@src.gnome.org>2000-10-16 07:17:56 +0800
commitec300909290ef9ae3397ab7111c7777d7eda28b1 (patch)
treecc0762eaae2e969286e416dfbf4c99f91811afa2 /widgets/table/e-tree-model.h
parentbe894a163a038fc60e50c435462571923f600f01 (diff)
downloadgsoc2013-evolution-ec300909290ef9ae3397ab7111c7777d7eda28b1.tar.gz
gsoc2013-evolution-ec300909290ef9ae3397ab7111c7777d7eda28b1.tar.zst
gsoc2013-evolution-ec300909290ef9ae3397ab7111c7777d7eda28b1.zip
get rid of ENode type, as everything in it is now in ETreePath, and add
2000-10-15 Chris Toshok <toshok@helixcode.com> * e-tree-model.c: get rid of ENode type, as everything in it is now in ETreePath, and add parent/sibling/child pointers to ETreePath. everywhere where GNode/ENode were used, we just use ETreePath now. (e_tree_path_depth): new function. (e_tree_path_insert): new function. (e_tree_path_unlink): new function. (e_tree_model_node_traverse): new function. (etree_get_first_child): new virtual function impl. (etree_get_last_child): same. (e_tree_model_class_init): fill in function pointers for get_first_child/get_last_child. (e_tree_model_node_get_first_child): new function. (e_tree_model_node_get_last_child): new function. (e_tree_model_node_depth): g_node_depth -> e_tree_path_depth. (e_tree_model_node_insert): modify to use ETreePath and new e_tree_path functions. Prepends and appends are now both constant time. (child_remove): modify for e_tree_model_node_traverse. (e_tree_model_node_remove): same, and use e_tree_path functions. (e_tree_model_node_insert_before): add a loop here to figure out the position, since it's the only place we care about the child position. (e_tree_model_node_sort): rework to accomodate new e_tree_path functions, and put the e_tree_model_node_set_expanded calls in a separate loop after all the children have been added. * e-tree-model.h: add prototypes and virtual functions for more tree traversal operations (get_first_child, get_last_child), as well as a new function to traverse depth first the descendents of a node (e_tree_model_node_traverse), much like g_node_traverse (G_IN_ORDER). Also, ETreePath is an opaque type now, and is not a GNode. svn path=/trunk/; revision=5932
Diffstat (limited to 'widgets/table/e-tree-model.h')
-rw-r--r--widgets/table/e-tree-model.h36
1 files changed, 22 insertions, 14 deletions
diff --git a/widgets/table/e-tree-model.h b/widgets/table/e-tree-model.h
index 8a8e4c177d..13857e6707 100644
--- a/widgets/table/e-tree-model.h
+++ b/widgets/table/e-tree-model.h
@@ -11,18 +11,19 @@
#define E_IS_TREE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TREE_MODEL_TYPE))
#define E_IS_TREE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TREE_MODEL_TYPE))
-typedef GNode ETreePath;
+typedef struct ETreePath ETreePath;
typedef struct ETreeModel ETreeModel;
typedef struct ETreeModelClass ETreeModelClass;
-typedef gint (*ETreePathCompareFunc)(ETreeModel *, ETreePath *path1, ETreePath *path2);
+typedef gint (*ETreePathCompareFunc)(ETreeModel *model, ETreePath *path1, ETreePath *path2);
+typedef gboolean (*ETreePathFunc)(ETreeModel *model, ETreePath *path, gpointer data);
struct ETreeModel {
ETableModel base;
- GNode *root;
- gboolean root_visible;
+ ETreePath *root;
+ gboolean root_visible;
GArray *row_array; /* used in the mapping between ETable and our tree */
- guint32 num_expanded_to_save;
- guint32 num_collapsed_to_save;
+ guint32 num_expanded_to_save;
+ guint32 num_collapsed_to_save;
GHashTable *expanded_state; /* used for loading/saving expanded state */
GString *sort_group; /* for caching the last sort group info */
};
@@ -35,10 +36,12 @@ struct ETreeModelClass {
*/
ETreePath *(*get_root) (ETreeModel *etm);
- ETreePath *(*get_parent) (ETreeModel *etm, ETreePath* node);
- ETreePath *(*get_next) (ETreeModel *etm, ETreePath* node);
- ETreePath *(*get_prev) (ETreeModel *etm, ETreePath* node);
- guint (*get_children) (ETreeModel *etm, ETreePath* node, ETreePath ***paths);
+ ETreePath *(*get_parent) (ETreeModel *etm, ETreePath* node);
+ ETreePath *(*get_first_child) (ETreeModel *etm, ETreePath* node);
+ ETreePath *(*get_last_child) (ETreeModel *etm, ETreePath* node);
+ ETreePath *(*get_next) (ETreeModel *etm, ETreePath* node);
+ ETreePath *(*get_prev) (ETreeModel *etm, ETreePath* node);
+ guint (*get_children) (ETreeModel *etm, ETreePath* node, ETreePath ***paths);
gboolean (*is_expanded) (ETreeModel *etm, ETreePath* node);
gboolean (*is_visible) (ETreeModel *etm, ETreePath* node);
@@ -73,10 +76,12 @@ void e_tree_model_construct (ETreeModel *etree);
ETreeModel *e_tree_model_new (void);
/* tree traversal operations */
-ETreePath *e_tree_model_get_root (ETreeModel *etree);
-ETreePath *e_tree_model_node_get_parent (ETreeModel *etree, ETreePath *path);
-ETreePath *e_tree_model_node_get_next (ETreeModel *etree, ETreePath *path);
-ETreePath *e_tree_model_node_get_prev (ETreeModel *etree, ETreePath *path);
+ETreePath *e_tree_model_get_root (ETreeModel *etree);
+ETreePath *e_tree_model_node_get_parent (ETreeModel *etree, ETreePath *path);
+ETreePath *e_tree_model_node_get_first_child (ETreeModel *etree, ETreePath *path);
+ETreePath *e_tree_model_node_get_last_child (ETreeModel *etree, ETreePath *path);
+ETreePath *e_tree_model_node_get_next (ETreeModel *etree, ETreePath *path);
+ETreePath *e_tree_model_node_get_prev (ETreeModel *etree, ETreePath *path);
/* node operations */
ETreePath *e_tree_model_node_insert (ETreeModel *etree, ETreePath *parent, int position, gpointer node_data);
@@ -123,4 +128,7 @@ void e_tree_model_node_set_save_id (ETreeModel *etm, ETreePath *node, c
ETreePath* e_tree_model_node_insert_id (ETreeModel *tree_model, ETreePath *parent_path,
int position, gpointer node_data, const char *save_id);
+/* depth first traversal of path's descendents, calling func on each one */
+void e_tree_model_node_traverse (ETreeModel *model, ETreePath *path, ETreePathFunc func, gpointer data);
+
#endif /* _E_TREE_MODEL_H */