aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table/e-tree-model.h
blob: 6924f3ea0ecc5d9962eac85eae4391032edfb58d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef _E_TREE_MODEL_H_
#define _E_TREE_MODEL_H_

#include "e-table-model.h"

#define E_TREE_MODEL_TYPE        (e_tree_model_get_type ())
#define E_TREE_MODEL(o)          (GTK_CHECK_CAST ((o), E_TREE_MODEL_TYPE, ETreeModel))
#define E_TREE_MODEL_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), E_TREE_MODEL_TYPE, ETreeModelClass))
#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 gpointer ETreePathItem;
typedef GList ETreePath;

typedef struct {
    ETableModel base;

    ETableModel *source;

    ETreePath *root_node;

    GArray  *array;

} ETreeModel;

typedef struct {
    ETableModelClass parent_class;

    /*
     * Virtual methods
     */
    ETreePath *(*get_root)      (ETreeModel *etm);

    ETreePath *(*get_next)      (ETreeModel *etm, ETreePath* node);
    ETreePath *(*get_prev)      (ETreeModel *etm, ETreePath* node);

    void      *(*value_at)      (ETreeModel *etm, ETreePath* node, int col);
    void       (*set_value_at)  (ETreeModel *etm, ETreePath* node, int col, const void *val);
    gboolean   (*is_editable)   (ETreeModel *etm, ETreePath* node, int col);

    guint      (*get_children)  (ETreeModel *etm, ETreePath* node, ETreePath ***paths);
    void       (*release_paths) (ETreeModel *etm, ETreePath **paths, guint num_paths);
    gboolean   (*is_expanded)   (ETreeModel *etm, ETreePath* node);
    void       (*set_expanded)  (ETreeModel *etm, ETreePath* node, gboolean expanded);

    /*
     * Signals
     */

} ETreeModelClass;

GtkType     e_tree_model_get_type (void);

ETreeModel *e_tree_model_new (void);

/* operations on "nodes" in the tree */
ETreePath * e_tree_model_get_root (ETreeModel *etree);
ETreePath * e_tree_model_node_at_row (ETreeModel *etree, int row);
guint e_tree_model_node_depth (ETreeModel *etree, ETreePath *path);
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);
gboolean e_tree_model_node_is_root (ETreeModel *etree, ETreePath *path);

gboolean e_tree_model_node_is_expandable (ETreeModel *etree, ETreePath *path);
gboolean e_tree_model_node_is_expanded (ETreeModel *etree, ETreePath *path);
guint e_tree_model_node_get_children (ETreeModel *etree, ETreePath *path, ETreePath ***paths);
void e_tree_model_release_paths (ETreeModel *etree, ETreePath **paths, guint num_paths);
guint e_tree_model_node_num_visible_descendents (ETreeModel *etm, ETreePath *node);

#endif /* _E_TREE_MODEL_H */