-
Notifications
You must be signed in to change notification settings - Fork 118
/
dyntree_model.h
177 lines (126 loc) · 4.63 KB
/
dyntree_model.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#ifndef dyntree_model_h
#define dyntree_model_h
#include <gtk/gtk.h>
#define DYNTREE_MODEL_TYPE (dyntree_model_get_type())
#define DYNTREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),DYNTREE_MODEL_TYPE, DyntreeModel))
#define DYNTREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DYNTREE_MODEL, DyntreeModelClass))
#define DYNTREE_IS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DYNTREE_MODEL_TYPE))
#define DYNTREE_IS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DYNTREE_MODEL_TYPE))
#define DYNTREE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DYNTREE_MODEL_TYPE, CustomListClass))
enum {
CC_CLASSNAME = 0, /* 0 */
CC_LABEL,
CC_ID,
CC_SIZE,
CC_VAL,
CC_ALT, /* 5 */
CC_MIME_TYPE, /* 6 */
CC_INITIAL_COUNT /* 7 */
};
typedef struct {
char *name;
} DyntreeModelAttributeDescriptor;
typedef struct {
char *value;
} DyntreeModelAttributeValue;
typedef struct _DyntreeModelNode {
struct _DyntreeModelNode *parent;
struct _DyntreeModelNode *prev;
struct _DyntreeModelNode *next;
struct _DyntreeModelNode *children;
DyntreeModelAttributeValue *attributes;
int max_attributes;
int sibling_index;
int n_children;
} DyntreeModelNode;
typedef struct {
GObject parent;
DyntreeModelNode *root;
/* extras */
GHashTable *columns_by_name;
DyntreeModelAttributeDescriptor *columns_by_index;
gint n_columns;
gint max_columns;
gint stamp;
} DyntreeModel;
typedef struct {
GObjectClass parent_class;
} DyntreeModelClass;
typedef gboolean (* DyntreeModelFunc)(DyntreeModel *, GtkTreeIter *, gpointer);
GType dyntree_model_get_type(void);
/***** USER FUNCS *****/
extern DyntreeModel *CARD_DATA_STORE;
/* Creating our model */
DyntreeModel *dyntree_model_new (void);
/* Adding columns to our model */
int dyntree_model_column_register(DyntreeModel *ctm,
const char *column_name);
int dyntree_model_column_name_to_index(DyntreeModel *ctm,
const char *column_name);
const char *dyntree_model_column_index_to_name(DyntreeModel *ctm,
int index);
gint dyntree_model_get_n_columns (GtkTreeModel *tree_model);
/* Setting attributes */
gboolean dyntree_model_iter_attribute_set(DyntreeModel *m,
GtkTreeIter *iter,
int index,
const char *str);
gboolean dyntree_model_iter_attribute_set_by_name(DyntreeModel *m,
GtkTreeIter *iter,
const char *attr_name,
const char *str);
gboolean dyntree_model_iter_attributes_setvalist(DyntreeModel *ctm,
GtkTreeIter *iter,
va_list al);
gboolean dyntree_model_iter_attributes_set(DyntreeModel *ctm,
GtkTreeIter *iter,
...);
/* Reading attributes */
gboolean dyntree_model_iter_attribute_get(DyntreeModel *m,
GtkTreeIter *iter,
int index,
const char **str);
gboolean dyntree_model_iter_attribute_get_by_name(DyntreeModel *m,
GtkTreeIter *iter,
const char *attr_name,
const char **ptr);
gboolean dyntree_model_iter_attributes_getvalist(DyntreeModel *ctm,
GtkTreeIter *iter,
va_list al);
gboolean dyntree_model_iter_attributes_get(DyntreeModel *ctm,
GtkTreeIter *iter,
...);
/* Removing a node */
gboolean dyntree_model_iter_remove(DyntreeModel *ctm,
GtkTreeIter *iter);
void dyntree_model_iter_clear(DyntreeModel *ctm);
/* Adding a node */
void dyntree_model_iter_append (DyntreeModel *ctm,
GtkTreeIter *child,
GtkTreeIter *parent);
/* Testing if empty */
#define dyntree_model_is_empty(ctm) (ctm->root==NULL)
/* exporting/importing XML */
char* dyntree_model_iter_to_xml(DyntreeModel *ctm, GtkTreeIter *root, gboolean full_xml);
/* result (char*) must be freed with g_free() */
gboolean dyntree_model_iter_to_xml_file(DyntreeModel* ct, GtkTreeIter *root, const char *fname);
gboolean dyntree_model_iter_from_xml(DyntreeModel *ct, GtkTreeIter *parent, gboolean full_xml, const char *source_val, int source_len);
gboolean dyntree_model_iter_from_xml_file(DyntreeModel *ct, GtkTreeIter *parent, const char *fname);
/* exporting to other formats */
char* dyntree_model_iter_to_text(DyntreeModel *ctm, GtkTreeIter *root);
/* searching */
gboolean dyntree_model_iter_find_first(DyntreeModel *ctm,
GtkTreeIter *result,
GtkTreeIter *root,
int *indices,
char **str,
int n_values);
gboolean dyntree_model_iter_find_next(DyntreeModel *ctm,
GtkTreeIter *result,
GtkTreeIter *root,
int *indices,
char **str,
int n_values);
/* iterating */
gboolean dyntree_model_foreach(DyntreeModel *ctm, GtkTreeIter *root, DyntreeModelFunc func, gpointer user_data);
#endif