File: | tests/testtreeview.c |
Warning: | line 1014, column 29 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* testtreeview.c | |||
2 | * Copyright (C) 2001 Red Hat, Inc | |||
3 | * Author: Jonathan Blandford | |||
4 | * | |||
5 | * This library is free software; you can redistribute it and/or | |||
6 | * modify it under the terms of the GNU Library General Public | |||
7 | * License as published by the Free Software Foundation; either | |||
8 | * version 2 of the License, or (at your option) any later version. | |||
9 | * | |||
10 | * This library is distributed in the hope that it will be useful, | |||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
13 | * Library General Public License for more details. | |||
14 | * | |||
15 | * You should have received a copy of the GNU Library General Public | |||
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
17 | */ | |||
18 | ||||
19 | #include <string.h> | |||
20 | #include <ctk/ctk.h> | |||
21 | #include <stdlib.h> | |||
22 | ||||
23 | /* Don't copy this bad example; inline RGB data is always a better | |||
24 | * idea than inline XPMs. | |||
25 | */ | |||
26 | static char *book_closed_xpm[] = { | |||
27 | "16 16 6 1", | |||
28 | " c None s None", | |||
29 | ". c black", | |||
30 | "X c red", | |||
31 | "o c yellow", | |||
32 | "O c #808080", | |||
33 | "# c white", | |||
34 | " ", | |||
35 | " .. ", | |||
36 | " ..XX. ", | |||
37 | " ..XXXXX. ", | |||
38 | " ..XXXXXXXX. ", | |||
39 | ".ooXXXXXXXXX. ", | |||
40 | "..ooXXXXXXXXX. ", | |||
41 | ".X.ooXXXXXXXXX. ", | |||
42 | ".XX.ooXXXXXX.. ", | |||
43 | " .XX.ooXXX..#O ", | |||
44 | " .XX.oo..##OO. ", | |||
45 | " .XX..##OO.. ", | |||
46 | " .X.#OO.. ", | |||
47 | " ..O.. ", | |||
48 | " .. ", | |||
49 | " " | |||
50 | }; | |||
51 | ||||
52 | static void run_automated_tests (void); | |||
53 | ||||
54 | /* This custom model is to test custom model use. */ | |||
55 | ||||
56 | #define CTK_TYPE_MODEL_TYPES(ctk_tree_model_types_get_type ()) (ctk_tree_model_types_get_type ()) | |||
57 | #define CTK_TREE_MODEL_TYPES(obj)((((CtkTreeModelTypes*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((obj)), ((ctk_tree_model_types_get_type ()) ))))) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_MODEL_TYPES, CtkTreeModelTypes)(((CtkTreeModelTypes*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((obj)), ((ctk_tree_model_types_get_type ())) )))) | |||
58 | #define CTK_TREE_MODEL_TYPES_CLASS(klass)((((CtkTreeModelTypesClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ctk_tree_model_types_get_type () )))))) (G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_MODEL_TYPES, CtkTreeModelTypesClass)(((CtkTreeModelTypesClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((klass)), ((ctk_tree_model_types_get_type ())) )))) | |||
59 | #define CTK_IS_TREE_MODEL_TYPES(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (obj)); GType __t = ((ctk_tree_model_types_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_MODEL_TYPES)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (obj)); GType __t = ((ctk_tree_model_types_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) | |||
60 | #define CTK_IS_TREE_MODEL_TYPES_GET_CLASS(klass)(G_TYPE_INSTANCE_GET_CLASS) (G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_MODEL_TYPES)) | |||
61 | ||||
62 | typedef struct _CtkTreeModelTypes CtkTreeModelTypes; | |||
63 | typedef struct _CtkTreeModelTypesClass CtkTreeModelTypesClass; | |||
64 | ||||
65 | struct _CtkTreeModelTypes | |||
66 | { | |||
67 | GObject parent; | |||
68 | ||||
69 | gint stamp; | |||
70 | }; | |||
71 | ||||
72 | struct _CtkTreeModelTypesClass | |||
73 | { | |||
74 | GObjectClass parent_class; | |||
75 | ||||
76 | guint (* get_flags) (CtkTreeModel *tree_model); | |||
77 | gint (* get_n_columns) (CtkTreeModel *tree_model); | |||
78 | GType (* get_column_type) (CtkTreeModel *tree_model, | |||
79 | gint index); | |||
80 | gboolean (* get_iter) (CtkTreeModel *tree_model, | |||
81 | CtkTreeIter *iter, | |||
82 | CtkTreePath *path); | |||
83 | CtkTreePath *(* get_path) (CtkTreeModel *tree_model, | |||
84 | CtkTreeIter *iter); | |||
85 | void (* get_value) (CtkTreeModel *tree_model, | |||
86 | CtkTreeIter *iter, | |||
87 | gint column, | |||
88 | GValue *value); | |||
89 | gboolean (* iter_next) (CtkTreeModel *tree_model, | |||
90 | CtkTreeIter *iter); | |||
91 | gboolean (* iter_children) (CtkTreeModel *tree_model, | |||
92 | CtkTreeIter *iter, | |||
93 | CtkTreeIter *parent); | |||
94 | gboolean (* iter_has_child) (CtkTreeModel *tree_model, | |||
95 | CtkTreeIter *iter); | |||
96 | gint (* iter_n_children) (CtkTreeModel *tree_model, | |||
97 | CtkTreeIter *iter); | |||
98 | gboolean (* iter_nth_child) (CtkTreeModel *tree_model, | |||
99 | CtkTreeIter *iter, | |||
100 | CtkTreeIter *parent, | |||
101 | gint n); | |||
102 | gboolean (* iter_parent) (CtkTreeModel *tree_model, | |||
103 | CtkTreeIter *iter, | |||
104 | CtkTreeIter *child); | |||
105 | void (* ref_iter) (CtkTreeModel *tree_model, | |||
106 | CtkTreeIter *iter); | |||
107 | void (* unref_iter) (CtkTreeModel *tree_model, | |||
108 | CtkTreeIter *iter); | |||
109 | ||||
110 | /* These will be moved into the CtkTreeModelIface eventually */ | |||
111 | void (* changed) (CtkTreeModel *tree_model, | |||
112 | CtkTreePath *path, | |||
113 | CtkTreeIter *iter); | |||
114 | void (* inserted) (CtkTreeModel *tree_model, | |||
115 | CtkTreePath *path, | |||
116 | CtkTreeIter *iter); | |||
117 | void (* child_toggled) (CtkTreeModel *tree_model, | |||
118 | CtkTreePath *path, | |||
119 | CtkTreeIter *iter); | |||
120 | void (* deleted) (CtkTreeModel *tree_model, | |||
121 | CtkTreePath *path); | |||
122 | }; | |||
123 | ||||
124 | GType ctk_tree_model_types_get_type (void) G_GNUC_CONST__attribute__ ((__const__)); | |||
125 | CtkTreeModelTypes *ctk_tree_model_types_new (void); | |||
126 | ||||
127 | typedef enum | |||
128 | { | |||
129 | COLUMNS_NONE, | |||
130 | COLUMNS_ONE, | |||
131 | COLUMNS_LOTS, | |||
132 | COLUMNS_LAST | |||
133 | } ColumnsType; | |||
134 | ||||
135 | static gchar *column_type_names[] = { | |||
136 | "No columns", | |||
137 | "One column", | |||
138 | "Many columns" | |||
139 | }; | |||
140 | ||||
141 | #define N_COLUMNS9 9 | |||
142 | ||||
143 | static GType* | |||
144 | get_model_types (void) | |||
145 | { | |||
146 | static GType column_types[N_COLUMNS9] = { 0 }; | |||
147 | ||||
148 | if (column_types[0] == 0) | |||
149 | { | |||
150 | column_types[0] = G_TYPE_STRING((GType) ((16) << (2))); | |||
151 | column_types[1] = G_TYPE_STRING((GType) ((16) << (2))); | |||
152 | column_types[2] = GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()); | |||
153 | column_types[3] = G_TYPE_FLOAT((GType) ((14) << (2))); | |||
154 | column_types[4] = G_TYPE_UINT((GType) ((7) << (2))); | |||
155 | column_types[5] = G_TYPE_UCHAR((GType) ((4) << (2))); | |||
156 | column_types[6] = G_TYPE_CHAR((GType) ((3) << (2))); | |||
157 | #define BOOL_COLUMN7 7 | |||
158 | column_types[BOOL_COLUMN7] = G_TYPE_BOOLEAN((GType) ((5) << (2))); | |||
159 | column_types[8] = G_TYPE_INT((GType) ((6) << (2))); | |||
160 | } | |||
161 | ||||
162 | return column_types; | |||
163 | } | |||
164 | ||||
165 | static void | |||
166 | toggled_callback (CtkCellRendererToggle *celltoggle G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
167 | gchar *path_string, | |||
168 | CtkTreeView *tree_view) | |||
169 | { | |||
170 | CtkTreeModel *model = NULL((void*)0); | |||
171 | CtkTreeModelSort *sort_model = NULL((void*)0); | |||
172 | CtkTreePath *path; | |||
173 | CtkTreeIter iter; | |||
174 | gboolean active = FALSE(0); | |||
175 | ||||
176 | g_return_if_fail (CTK_IS_TREE_VIEW (tree_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tree_view)); GType __t = ((ctk_tree_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_TREE_VIEW (tree_view)"); return; } } while (0); | |||
177 | ||||
178 | model = ctk_tree_view_get_model (tree_view); | |||
179 | ||||
180 | if (CTK_IS_TREE_MODEL_SORT (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_model_sort_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
181 | { | |||
182 | sort_model = CTK_TREE_MODEL_SORT (model)((((CtkTreeModelSort*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((model)), ((ctk_tree_model_sort_get_type ()) ))))); | |||
183 | model = ctk_tree_model_sort_get_model (sort_model); | |||
184 | } | |||
185 | ||||
186 | if (model == NULL((void*)0)) | |||
187 | return; | |||
188 | ||||
189 | if (sort_model) | |||
190 | { | |||
191 | g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter"); | |||
192 | return; | |||
193 | } | |||
194 | ||||
195 | path = ctk_tree_path_new_from_string (path_string); | |||
196 | if (!ctk_tree_model_get_iter (model, | |||
197 | &iter, path)) | |||
198 | { | |||
199 | g_warning ("%s: bad path?", G_STRLOC"testtreeview.c" ":" "199"); | |||
200 | return; | |||
201 | } | |||
202 | ctk_tree_path_free (path); | |||
203 | ||||
204 | if (CTK_IS_LIST_STORE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
205 | { | |||
206 | ctk_tree_model_get (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_model_get_type ())))))), | |||
207 | &iter, | |||
208 | BOOL_COLUMN7, | |||
209 | &active, | |||
210 | -1); | |||
211 | ||||
212 | ctk_list_store_set (CTK_LIST_STORE (model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), | |||
213 | &iter, | |||
214 | BOOL_COLUMN7, | |||
215 | !active, | |||
216 | -1); | |||
217 | } | |||
218 | else if (CTK_IS_TREE_STORE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
219 | { | |||
220 | ctk_tree_model_get (CTK_TREE_MODEL (model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_model_get_type ())))))), | |||
221 | &iter, | |||
222 | BOOL_COLUMN7, | |||
223 | &active, | |||
224 | -1); | |||
225 | ||||
226 | ctk_tree_store_set (CTK_TREE_STORE (model)((((CtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_store_get_type ())))))), | |||
227 | &iter, | |||
228 | BOOL_COLUMN7, | |||
229 | !active, | |||
230 | -1); | |||
231 | } | |||
232 | else | |||
233 | g_warning ("don't know how to actually toggle value for model type %s", | |||
234 | g_type_name (G_TYPE_FROM_INSTANCE (model)((((GTypeClass*) (((GTypeInstance*) (model))->g_class))-> g_type)))); | |||
235 | } | |||
236 | ||||
237 | static void | |||
238 | edited_callback (CtkCellRendererText *renderer G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
239 | const gchar *path_string, | |||
240 | const gchar *new_text, | |||
241 | CtkTreeView *tree_view) | |||
242 | { | |||
243 | CtkTreeModel *model = NULL((void*)0); | |||
244 | CtkTreeModelSort *sort_model = NULL((void*)0); | |||
245 | CtkTreePath *path; | |||
246 | CtkTreeIter iter; | |||
247 | guint value = atoi (new_text); | |||
248 | ||||
249 | g_return_if_fail (CTK_IS_TREE_VIEW (tree_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tree_view)); GType __t = ((ctk_tree_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_TREE_VIEW (tree_view)"); return; } } while (0); | |||
250 | ||||
251 | model = ctk_tree_view_get_model (tree_view); | |||
252 | ||||
253 | if (CTK_IS_TREE_MODEL_SORT (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_model_sort_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
254 | { | |||
255 | sort_model = CTK_TREE_MODEL_SORT (model)((((CtkTreeModelSort*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((model)), ((ctk_tree_model_sort_get_type ()) ))))); | |||
256 | model = ctk_tree_model_sort_get_model (sort_model); | |||
257 | } | |||
258 | ||||
259 | if (model == NULL((void*)0)) | |||
260 | return; | |||
261 | ||||
262 | if (sort_model) | |||
263 | { | |||
264 | g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter"); | |||
265 | return; | |||
266 | } | |||
267 | ||||
268 | path = ctk_tree_path_new_from_string (path_string); | |||
269 | if (!ctk_tree_model_get_iter (model, | |||
270 | &iter, path)) | |||
271 | { | |||
272 | g_warning ("%s: bad path?", G_STRLOC"testtreeview.c" ":" "272"); | |||
273 | return; | |||
274 | } | |||
275 | ctk_tree_path_free (path); | |||
276 | ||||
277 | if (CTK_IS_LIST_STORE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
278 | { | |||
279 | ctk_list_store_set (CTK_LIST_STORE (model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), | |||
280 | &iter, | |||
281 | 4, | |||
282 | value, | |||
283 | -1); | |||
284 | } | |||
285 | else if (CTK_IS_TREE_STORE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
286 | { | |||
287 | ctk_tree_store_set (CTK_TREE_STORE (model)((((CtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_store_get_type ())))))), | |||
288 | &iter, | |||
289 | 4, | |||
290 | value, | |||
291 | -1); | |||
292 | } | |||
293 | else | |||
294 | g_warning ("don't know how to actually toggle value for model type %s", | |||
295 | g_type_name (G_TYPE_FROM_INSTANCE (model)((((GTypeClass*) (((GTypeInstance*) (model))->g_class))-> g_type)))); | |||
296 | } | |||
297 | ||||
298 | static ColumnsType current_column_type = COLUMNS_LOTS; | |||
299 | ||||
300 | static void | |||
301 | set_columns_type (CtkTreeView *tree_view, ColumnsType type) | |||
302 | { | |||
303 | CtkTreeViewColumn *col; | |||
304 | CtkCellRenderer *rend; | |||
305 | GdkPixbuf *pixbuf; | |||
306 | CtkWidget *image; | |||
307 | CtkAdjustment *adjustment; | |||
308 | ||||
309 | current_column_type = type; | |||
310 | ||||
311 | col = ctk_tree_view_get_column (tree_view, 0); | |||
312 | while (col) | |||
313 | { | |||
314 | ctk_tree_view_remove_column (tree_view, col); | |||
315 | ||||
316 | col = ctk_tree_view_get_column (tree_view, 0); | |||
317 | } | |||
318 | ||||
319 | switch (type) | |||
320 | { | |||
321 | case COLUMNS_NONE: | |||
322 | break; | |||
323 | ||||
324 | case COLUMNS_LOTS: | |||
325 | rend = ctk_cell_renderer_text_new (); | |||
326 | ||||
327 | col = ctk_tree_view_column_new_with_attributes ("Column 1", | |||
328 | rend, | |||
329 | "text", 1, | |||
330 | NULL((void*)0)); | |||
331 | ||||
332 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
333 | ||||
334 | col = ctk_tree_view_column_new(); | |||
335 | ctk_tree_view_column_set_title (col, "Column 2"); | |||
336 | ||||
337 | rend = ctk_cell_renderer_pixbuf_new (); | |||
338 | ctk_tree_view_column_pack_start (col, rend, FALSE(0)); | |||
339 | ctk_tree_view_column_add_attribute (col, rend, "pixbuf", 2); | |||
340 | rend = ctk_cell_renderer_text_new (); | |||
341 | ctk_tree_view_column_pack_start (col, rend, TRUE(!(0))); | |||
342 | ctk_tree_view_column_add_attribute (col, rend, "text", 0); | |||
343 | ||||
344 | ||||
345 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
346 | ctk_tree_view_set_expander_column (tree_view, col); | |||
347 | ||||
348 | rend = ctk_cell_renderer_toggle_new (); | |||
349 | ||||
350 | g_signal_connect (rend, "toggled",g_signal_connect_data ((rend), ("toggled"), (((GCallback) (toggled_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0) | |||
351 | G_CALLBACK (toggled_callback), tree_view)g_signal_connect_data ((rend), ("toggled"), (((GCallback) (toggled_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0); | |||
352 | ||||
353 | col = ctk_tree_view_column_new_with_attributes ("Column 3", | |||
354 | rend, | |||
355 | "active", BOOL_COLUMN7, | |||
356 | NULL((void*)0)); | |||
357 | ||||
358 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
359 | ||||
360 | pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)book_closed_xpm); | |||
361 | ||||
362 | image = ctk_image_new_from_pixbuf (pixbuf); | |||
363 | ||||
364 | g_object_unref (pixbuf); | |||
365 | ||||
366 | ctk_widget_show (image); | |||
367 | ||||
368 | ctk_tree_view_column_set_widget (col, image); | |||
369 | ||||
370 | rend = ctk_cell_renderer_toggle_new (); | |||
371 | ||||
372 | /* you could also set this per-row by tying it to a column | |||
373 | * in the model of course. | |||
374 | */ | |||
375 | g_object_set (rend, "radio", TRUE(!(0)), NULL((void*)0)); | |||
376 | ||||
377 | g_signal_connect (rend, "toggled",g_signal_connect_data ((rend), ("toggled"), (((GCallback) (toggled_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0) | |||
378 | G_CALLBACK (toggled_callback), tree_view)g_signal_connect_data ((rend), ("toggled"), (((GCallback) (toggled_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0); | |||
379 | ||||
380 | col = ctk_tree_view_column_new_with_attributes ("Column 4", | |||
381 | rend, | |||
382 | "active", BOOL_COLUMN7, | |||
383 | NULL((void*)0)); | |||
384 | ||||
385 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
386 | ||||
387 | rend = ctk_cell_renderer_spin_new (); | |||
388 | ||||
389 | adjustment = ctk_adjustment_new (0, 0, 10000, 100, 100, 100); | |||
390 | g_object_set (rend, "editable", TRUE(!(0)), NULL((void*)0)); | |||
391 | g_object_set (rend, "adjustment", adjustment, NULL((void*)0)); | |||
392 | ||||
393 | g_signal_connect (rend, "edited",g_signal_connect_data ((rend), ("edited"), (((GCallback) (edited_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0) | |||
394 | G_CALLBACK (edited_callback), tree_view)g_signal_connect_data ((rend), ("edited"), (((GCallback) (edited_callback ))), (tree_view), ((void*)0), (GConnectFlags) 0); | |||
395 | ||||
396 | col = ctk_tree_view_column_new_with_attributes ("Column 5", | |||
397 | rend, | |||
398 | "text", 4, | |||
399 | NULL((void*)0)); | |||
400 | ||||
401 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
402 | #if 0 | |||
403 | ||||
404 | rend = ctk_cell_renderer_text_new (); | |||
405 | ||||
406 | col = ctk_tree_view_column_new_with_attributes ("Column 6", | |||
407 | rend, | |||
408 | "text", 4, | |||
409 | NULL((void*)0)); | |||
410 | ||||
411 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
412 | ||||
413 | rend = ctk_cell_renderer_text_new (); | |||
414 | ||||
415 | col = ctk_tree_view_column_new_with_attributes ("Column 7", | |||
416 | rend, | |||
417 | "text", 5, | |||
418 | NULL((void*)0)); | |||
419 | ||||
420 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
421 | ||||
422 | rend = ctk_cell_renderer_text_new (); | |||
423 | ||||
424 | col = ctk_tree_view_column_new_with_attributes ("Column 8", | |||
425 | rend, | |||
426 | "text", 6, | |||
427 | NULL((void*)0)); | |||
428 | ||||
429 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
430 | ||||
431 | rend = ctk_cell_renderer_text_new (); | |||
432 | ||||
433 | col = ctk_tree_view_column_new_with_attributes ("Column 9", | |||
434 | rend, | |||
435 | "text", 7, | |||
436 | NULL((void*)0)); | |||
437 | ||||
438 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
439 | ||||
440 | rend = ctk_cell_renderer_text_new (); | |||
441 | ||||
442 | col = ctk_tree_view_column_new_with_attributes ("Column 10", | |||
443 | rend, | |||
444 | "text", 8, | |||
445 | NULL((void*)0)); | |||
446 | ||||
447 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col); | |||
448 | ||||
449 | #endif | |||
450 | ||||
451 | /* FALL THRU */ | |||
452 | ||||
453 | case COLUMNS_ONE: | |||
454 | rend = ctk_cell_renderer_text_new (); | |||
455 | ||||
456 | col = ctk_tree_view_column_new_with_attributes ("Column 0", | |||
457 | rend, | |||
458 | "text", 0, | |||
459 | NULL((void*)0)); | |||
460 | ||||
461 | ctk_tree_view_insert_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), col, 0); | |||
462 | default: | |||
463 | break; | |||
464 | } | |||
465 | } | |||
466 | ||||
467 | static ColumnsType | |||
468 | get_columns_type (void) | |||
469 | { | |||
470 | return current_column_type; | |||
471 | } | |||
472 | ||||
473 | static GdkPixbuf *our_pixbuf; | |||
474 | ||||
475 | typedef enum | |||
476 | { | |||
477 | /* MODEL_TYPES, */ | |||
478 | MODEL_TREE, | |||
479 | MODEL_LIST, | |||
480 | MODEL_SORTED_TREE, | |||
481 | MODEL_SORTED_LIST, | |||
482 | MODEL_EMPTY_LIST, | |||
483 | MODEL_EMPTY_TREE, | |||
484 | MODEL_NULL, | |||
485 | MODEL_LAST | |||
486 | } ModelType; | |||
487 | ||||
488 | /* FIXME add a custom model to test */ | |||
489 | static CtkTreeModel *models[MODEL_LAST]; | |||
490 | static const char *model_names[MODEL_LAST] = { | |||
491 | "CtkTreeStore", | |||
492 | "CtkListStore", | |||
493 | "CtkTreeModelSort wrapping CtkTreeStore", | |||
494 | "CtkTreeModelSort wrapping CtkListStore", | |||
495 | "Empty CtkListStore", | |||
496 | "Empty CtkTreeStore", | |||
497 | "NULL (no model)" | |||
498 | }; | |||
499 | ||||
500 | static CtkTreeModel* | |||
501 | create_list_model (void) | |||
502 | { | |||
503 | CtkListStore *store; | |||
504 | CtkTreeIter iter; | |||
505 | gint i; | |||
506 | GType *t; | |||
507 | ||||
508 | t = get_model_types (); | |||
509 | ||||
510 | store = ctk_list_store_new (N_COLUMNS9, | |||
511 | t[0], t[1], t[2], | |||
512 | t[3], t[4], t[5], | |||
513 | t[6], t[7], t[8]); | |||
514 | ||||
515 | i = 0; | |||
516 | while (i < 200) | |||
517 | { | |||
518 | char *msg; | |||
519 | ||||
520 | ctk_list_store_append (store, &iter); | |||
521 | ||||
522 | msg = g_strdup_printf ("%d", i); | |||
523 | ||||
524 | ctk_list_store_set (store, &iter, 0, msg, 1, "Foo! Foo! Foo!", | |||
525 | 2, our_pixbuf, | |||
526 | 3, 7.0, 4, (guint) 9000, | |||
527 | 5, 'f', 6, 'g', | |||
528 | 7, TRUE(!(0)), 8, 23245454, | |||
529 | -1); | |||
530 | ||||
531 | g_free (msg); | |||
532 | ||||
533 | ++i; | |||
534 | } | |||
535 | ||||
536 | return CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))); | |||
537 | } | |||
538 | ||||
539 | static void | |||
540 | typesystem_recurse (GType type, | |||
541 | CtkTreeIter *parent_iter, | |||
542 | CtkTreeStore *store) | |||
543 | { | |||
544 | GType* children; | |||
545 | guint n_children = 0; | |||
546 | gint i; | |||
547 | CtkTreeIter iter; | |||
548 | gchar *str; | |||
549 | ||||
550 | ctk_tree_store_append (store, &iter, parent_iter); | |||
551 | ||||
552 | str = g_strdup_printf ("%ld", (glong)type); | |||
553 | ctk_tree_store_set (store, &iter, 0, str, 1, g_type_name (type), | |||
554 | 2, our_pixbuf, | |||
555 | 3, 7.0, 4, (guint) 9000, | |||
556 | 5, 'f', 6, 'g', | |||
557 | 7, TRUE(!(0)), 8, 23245454, | |||
558 | -1); | |||
559 | g_free (str); | |||
560 | ||||
561 | children = g_type_children (type, &n_children); | |||
562 | ||||
563 | i = 0; | |||
564 | while (i < n_children) | |||
565 | { | |||
566 | typesystem_recurse (children[i], &iter, store); | |||
567 | ||||
568 | ++i; | |||
569 | } | |||
570 | ||||
571 | g_free (children); | |||
572 | } | |||
573 | ||||
574 | static CtkTreeModel* | |||
575 | create_tree_model (void) | |||
576 | { | |||
577 | CtkTreeStore *store; | |||
578 | gint i; | |||
579 | GType *t; | |||
580 | ||||
581 | /* Make the tree more interesting */ | |||
582 | /* - we need this magic here so we are sure the type ends up being | |||
583 | * registered and gcc doesn't optimize away the code */ | |||
584 | g_type_class_unref (g_type_class_ref (ctk_scrolled_window_get_type ())); | |||
585 | g_type_class_unref (g_type_class_ref (ctk_label_get_type ())); | |||
586 | g_type_class_unref (g_type_class_ref (ctk_scrollbar_get_type ())); | |||
587 | g_type_class_unref (g_type_class_ref (pango_layout_get_type ())); | |||
588 | ||||
589 | t = get_model_types (); | |||
590 | ||||
591 | store = ctk_tree_store_new (N_COLUMNS9, | |||
592 | t[0], t[1], t[2], | |||
593 | t[3], t[4], t[5], | |||
594 | t[6], t[7], t[8]); | |||
595 | ||||
596 | i = 0; | |||
597 | while (i < G_TYPE_FUNDAMENTAL_MAX(255 << (2))) | |||
598 | { | |||
599 | typesystem_recurse (i, NULL((void*)0), store); | |||
600 | ||||
601 | ++i; | |||
602 | } | |||
603 | ||||
604 | return CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))); | |||
605 | } | |||
606 | ||||
607 | static void | |||
608 | model_selected (CtkComboBox *combo_box, gpointer data) | |||
609 | { | |||
610 | CtkTreeView *tree_view = CTK_TREE_VIEW (data)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_tree_view_get_type ())))))); | |||
611 | gint hist; | |||
612 | ||||
613 | hist = ctk_combo_box_get_active (combo_box); | |||
614 | ||||
615 | if (models[hist] != ctk_tree_view_get_model (tree_view)) | |||
616 | { | |||
617 | ctk_tree_view_set_model (tree_view, models[hist]); | |||
618 | } | |||
619 | } | |||
620 | ||||
621 | static void | |||
622 | columns_selected (CtkComboBox *combo_box, gpointer data) | |||
623 | { | |||
624 | CtkTreeView *tree_view = CTK_TREE_VIEW (data)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_tree_view_get_type ())))))); | |||
625 | gint hist; | |||
626 | ||||
627 | hist = ctk_combo_box_get_active (combo_box); | |||
628 | ||||
629 | if (hist != get_columns_type ()) | |||
630 | { | |||
631 | set_columns_type (tree_view, hist); | |||
632 | } | |||
633 | } | |||
634 | ||||
635 | void | |||
636 | on_row_activated (CtkTreeView *tree_view G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
637 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
638 | CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
639 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
640 | { | |||
641 | g_print ("Row activated\n"); | |||
642 | } | |||
643 | ||||
644 | enum | |||
645 | { | |||
646 | TARGET_CTK_TREE_MODEL_ROW | |||
647 | }; | |||
648 | ||||
649 | static CtkTargetEntry row_targets[] = { | |||
650 | { "CTK_TREE_MODEL_ROW", CTK_TARGET_SAME_APP, | |||
651 | TARGET_CTK_TREE_MODEL_ROW } | |||
652 | }; | |||
653 | ||||
654 | int | |||
655 | main (int argc, | |||
656 | char **argv) | |||
657 | { | |||
658 | CtkWidget *window; | |||
659 | CtkWidget *sw; | |||
660 | CtkWidget *tv; | |||
661 | CtkWidget *box; | |||
662 | CtkWidget *combo_box; | |||
663 | CtkTreeModel *model; | |||
664 | gint i; | |||
665 | ||||
666 | ctk_init (&argc, &argv); | |||
667 | ||||
668 | if (g_getenv ("RTL")) | |||
669 | ctk_widget_set_default_direction (CTK_TEXT_DIR_RTL); | |||
670 | ||||
671 | our_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm); | |||
672 | ||||
673 | #if 0 | |||
674 | models[MODEL_TYPES] = CTK_TREE_MODEL (ctk_tree_model_types_new ())((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_tree_model_types_new ())), ((ctk_tree_model_get_type ())))))); | |||
675 | #endif | |||
676 | models[MODEL_LIST] = create_list_model (); | |||
677 | models[MODEL_TREE] = create_tree_model (); | |||
678 | ||||
679 | model = create_list_model (); | |||
680 | models[MODEL_SORTED_LIST] = ctk_tree_model_sort_new_with_model (model); | |||
681 | g_object_unref (model); | |||
682 | ||||
683 | model = create_tree_model (); | |||
684 | models[MODEL_SORTED_TREE] = ctk_tree_model_sort_new_with_model (model); | |||
685 | g_object_unref (model); | |||
686 | ||||
687 | models[MODEL_EMPTY_LIST] = CTK_TREE_MODEL (ctk_list_store_new (1, G_TYPE_INT))((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_store_new (1, ((GType) ((6) << (2)))))), ( (ctk_tree_model_get_type ())))))); | |||
688 | models[MODEL_EMPTY_TREE] = CTK_TREE_MODEL (ctk_tree_store_new (1, G_TYPE_INT))((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_tree_store_new (1, ((GType) ((6) << (2)))))), ( (ctk_tree_model_get_type ())))))); | |||
689 | ||||
690 | models[MODEL_NULL] = NULL((void*)0); | |||
691 | ||||
692 | run_automated_tests (); | |||
693 | ||||
694 | window = ctk_window_new (CTK_WINDOW_TOPLEVEL); | |||
695 | g_signal_connect (window, "destroy", G_CALLBACK (ctk_main_quit), NULL)g_signal_connect_data ((window), ("destroy"), (((GCallback) ( ctk_main_quit))), (((void*)0)), ((void*)0), (GConnectFlags) 0 ); | |||
696 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), 430, 400); | |||
697 | ||||
698 | box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
699 | ||||
700 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), box); | |||
701 | ||||
702 | tv = ctk_tree_view_new_with_model (models[0]); | |||
703 | g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL)g_signal_connect_data ((tv), ("row-activated"), (((GCallback) (on_row_activated))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
704 | ||||
705 | ctk_tree_view_enable_model_drag_source (CTK_TREE_VIEW (tv)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv)), ((ctk_tree_view_get_type ())))))), | |||
706 | CDK_BUTTON1_MASK, | |||
707 | row_targets, | |||
708 | G_N_ELEMENTS (row_targets)(sizeof (row_targets) / sizeof ((row_targets)[0])), | |||
709 | CDK_ACTION_MOVE | CDK_ACTION_COPY); | |||
710 | ||||
711 | ctk_tree_view_enable_model_drag_dest (CTK_TREE_VIEW (tv)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv)), ((ctk_tree_view_get_type ())))))), | |||
712 | row_targets, | |||
713 | G_N_ELEMENTS (row_targets)(sizeof (row_targets) / sizeof ((row_targets)[0])), | |||
714 | CDK_ACTION_MOVE | CDK_ACTION_COPY); | |||
715 | ||||
716 | /* Model menu */ | |||
717 | combo_box = ctk_combo_box_text_new (); | |||
718 | ctk_widget_set_halign (combo_box, CTK_ALIGN_CENTER); | |||
719 | for (i = 0; i < MODEL_LAST; i++) | |||
720 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (combo_box)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_box)), ((ctk_combo_box_text_get_type ())))))), model_names[i]); | |||
721 | ||||
722 | ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_container_get_type ())))))), combo_box); | |||
723 | g_signal_connect (combo_box,g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (model_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
724 | "changed",g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (model_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
725 | G_CALLBACK (model_selected),g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (model_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
726 | tv)g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (model_selected))), (tv), ((void*)0), (GConnectFlags) 0); | |||
727 | ||||
728 | /* Columns menu */ | |||
729 | combo_box = ctk_combo_box_text_new (); | |||
730 | ctk_widget_set_halign (combo_box, CTK_ALIGN_CENTER); | |||
731 | for (i = 0; i < COLUMNS_LAST; i++) | |||
732 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (combo_box)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_box)), ((ctk_combo_box_text_get_type ())))))), column_type_names[i]); | |||
733 | ||||
734 | ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_container_get_type ())))))), combo_box); | |||
735 | ||||
736 | set_columns_type (CTK_TREE_VIEW (tv)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv)), ((ctk_tree_view_get_type ())))))), COLUMNS_LOTS); | |||
737 | ctk_combo_box_set_active (CTK_COMBO_BOX (combo_box)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_box)), ((ctk_combo_box_get_type ())))))), COLUMNS_LOTS); | |||
738 | ||||
739 | g_signal_connect (combo_box,g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (columns_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
740 | "changed",g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (columns_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
741 | G_CALLBACK (columns_selected),g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (columns_selected))), (tv), ((void*)0), (GConnectFlags) 0) | |||
742 | tv)g_signal_connect_data ((combo_box), ("changed"), (((GCallback ) (columns_selected))), (tv), ((void*)0), (GConnectFlags) 0); | |||
743 | ||||
744 | sw = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | |||
745 | ctk_widget_set_hexpand (sw, TRUE(!(0))); | |||
746 | ctk_widget_set_vexpand (sw, TRUE(!(0))); | |||
747 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (sw)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((sw)), ((ctk_scrolled_window_get_type ()))) ))), | |||
748 | CTK_POLICY_AUTOMATIC, | |||
749 | CTK_POLICY_AUTOMATIC); | |||
750 | ||||
751 | ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_container_get_type ())))))), sw); | |||
752 | ||||
753 | ctk_container_add (CTK_CONTAINER (sw)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sw)), ((ctk_container_get_type ())))))), tv); | |||
754 | ||||
755 | ctk_widget_show_all (window); | |||
756 | ||||
757 | ctk_main (); | |||
758 | ||||
759 | return 0; | |||
760 | } | |||
761 | ||||
762 | /* | |||
763 | * CtkTreeModelTypes | |||
764 | */ | |||
765 | ||||
766 | static void ctk_tree_model_types_init (CtkTreeModelTypes *model_types); | |||
767 | static void ctk_tree_model_types_tree_model_init (CtkTreeModelIface *iface); | |||
768 | static gint ctk_real_model_types_get_n_columns (CtkTreeModel *tree_model); | |||
769 | static GType ctk_real_model_types_get_column_type (CtkTreeModel *tree_model, | |||
770 | gint index); | |||
771 | static CtkTreePath *ctk_real_model_types_get_path (CtkTreeModel *tree_model, | |||
772 | CtkTreeIter *iter); | |||
773 | static void ctk_real_model_types_get_value (CtkTreeModel *tree_model, | |||
774 | CtkTreeIter *iter, | |||
775 | gint column, | |||
776 | GValue *value); | |||
777 | static gboolean ctk_real_model_types_iter_next (CtkTreeModel *tree_model, | |||
778 | CtkTreeIter *iter); | |||
779 | static gboolean ctk_real_model_types_iter_children (CtkTreeModel *tree_model, | |||
780 | CtkTreeIter *iter, | |||
781 | CtkTreeIter *parent); | |||
782 | static gboolean ctk_real_model_types_iter_has_child (CtkTreeModel *tree_model, | |||
783 | CtkTreeIter *iter); | |||
784 | static gint ctk_real_model_types_iter_n_children (CtkTreeModel *tree_model, | |||
785 | CtkTreeIter *iter); | |||
786 | static gboolean ctk_real_model_types_iter_nth_child (CtkTreeModel *tree_model, | |||
787 | CtkTreeIter *iter, | |||
788 | CtkTreeIter *parent, | |||
789 | gint n); | |||
790 | static gboolean ctk_real_model_types_iter_parent (CtkTreeModel *tree_model, | |||
791 | CtkTreeIter *iter, | |||
792 | CtkTreeIter *child); | |||
793 | ||||
794 | ||||
795 | GType | |||
796 | ctk_tree_model_types_get_type (void) | |||
797 | { | |||
798 | static GType model_types_type = 0; | |||
799 | ||||
800 | if (!model_types_type) | |||
801 | { | |||
802 | const GTypeInfo model_types_info = | |||
803 | { | |||
804 | .class_size = sizeof (CtkTreeModelTypesClass), | |||
805 | .instance_size = sizeof (CtkTreeModelTypes), | |||
806 | .n_preallocs = 0, | |||
807 | .instance_init = (GInstanceInitFunc) ctk_tree_model_types_init | |||
808 | }; | |||
809 | ||||
810 | const GInterfaceInfo tree_model_info = | |||
811 | { | |||
812 | (GInterfaceInitFunc) ctk_tree_model_types_tree_model_init, | |||
813 | NULL((void*)0), | |||
814 | NULL((void*)0) | |||
815 | }; | |||
816 | ||||
817 | model_types_type = g_type_register_static (G_TYPE_OBJECT((GType) ((20) << (2))), | |||
818 | "CtkTreeModelTypes", | |||
819 | &model_types_info, 0); | |||
820 | g_type_add_interface_static (model_types_type, | |||
821 | CTK_TYPE_TREE_MODEL(ctk_tree_model_get_type ()), | |||
822 | &tree_model_info); | |||
823 | } | |||
824 | ||||
825 | return model_types_type; | |||
826 | } | |||
827 | ||||
828 | CtkTreeModelTypes * | |||
829 | ctk_tree_model_types_new (void) | |||
830 | { | |||
831 | CtkTreeModelTypes *retval; | |||
832 | ||||
833 | retval = g_object_new (CTK_TYPE_MODEL_TYPES(ctk_tree_model_types_get_type ()), NULL((void*)0)); | |||
834 | ||||
835 | return retval; | |||
836 | } | |||
837 | ||||
838 | static void | |||
839 | ctk_tree_model_types_tree_model_init (CtkTreeModelIface *iface) | |||
840 | { | |||
841 | iface->get_n_columns = ctk_real_model_types_get_n_columns; | |||
842 | iface->get_column_type = ctk_real_model_types_get_column_type; | |||
843 | iface->get_path = ctk_real_model_types_get_path; | |||
844 | iface->get_value = ctk_real_model_types_get_value; | |||
845 | iface->iter_next = ctk_real_model_types_iter_next; | |||
846 | iface->iter_children = ctk_real_model_types_iter_children; | |||
847 | iface->iter_has_child = ctk_real_model_types_iter_has_child; | |||
848 | iface->iter_n_children = ctk_real_model_types_iter_n_children; | |||
849 | iface->iter_nth_child = ctk_real_model_types_iter_nth_child; | |||
850 | iface->iter_parent = ctk_real_model_types_iter_parent; | |||
851 | } | |||
852 | ||||
853 | static void | |||
854 | ctk_tree_model_types_init (CtkTreeModelTypes *model_types) | |||
855 | { | |||
856 | model_types->stamp = g_random_int (); | |||
857 | } | |||
858 | ||||
859 | static GType column_types[] = { | |||
860 | G_TYPE_STRING((GType) ((16) << (2))), /* GType */ | |||
861 | G_TYPE_STRING((GType) ((16) << (2))) /* type name */ | |||
862 | }; | |||
863 | ||||
864 | static gint | |||
865 | ctk_real_model_types_get_n_columns (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
866 | { | |||
867 | return G_N_ELEMENTS (column_types)(sizeof (column_types) / sizeof ((column_types)[0])); | |||
868 | } | |||
869 | ||||
870 | static GType | |||
871 | ctk_real_model_types_get_column_type (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
872 | gint index) | |||
873 | { | |||
874 | g_return_val_if_fail (index < G_N_ELEMENTS (column_types), G_TYPE_INVALID)do { if ((index < (sizeof (column_types) / sizeof ((column_types )[0])))) { } else { g_return_if_fail_warning (((gchar*) 0), ( (const char*) (__func__)), "index < G_N_ELEMENTS (column_types)" ); return (((GType) ((0) << (2)))); } } while (0); | |||
875 | ||||
876 | return column_types[index]; | |||
877 | } | |||
878 | ||||
879 | #if 0 | |||
880 | /* Use default implementation of this */ | |||
881 | static gboolean | |||
882 | ctk_real_model_types_get_iter (CtkTreeModel *tree_model, | |||
883 | CtkTreeIter *iter, | |||
884 | CtkTreePath *path) | |||
885 | { | |||
886 | ||||
887 | } | |||
888 | #endif | |||
889 | ||||
890 | /* The toplevel nodes of the tree are the reserved types, G_TYPE_NONE through | |||
891 | * G_TYPE_RESERVED_FUNDAMENTAL. | |||
892 | */ | |||
893 | ||||
894 | static CtkTreePath * | |||
895 | ctk_real_model_types_get_path (CtkTreeModel *tree_model, | |||
896 | CtkTreeIter *iter) | |||
897 | { | |||
898 | CtkTreePath *retval; | |||
899 | GType type; | |||
900 | GType parent; | |||
901 | ||||
902 | g_return_val_if_fail (CTK_IS_TREE_MODEL_TYPES (tree_model), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tree_model)); GType __t = ((ctk_tree_model_types_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_TREE_MODEL_TYPES (tree_model)" ); return (((void*)0)); } } while (0); | |||
903 | g_return_val_if_fail (iter != NULL, NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "iter != NULL"); return (((void*)0)); } } while (0); | |||
904 | ||||
905 | type = GPOINTER_TO_INT (iter->user_data)((gint) (glong) (iter->user_data)); | |||
906 | ||||
907 | retval = ctk_tree_path_new (); | |||
908 | ||||
909 | parent = g_type_parent (type); | |||
910 | while (parent != G_TYPE_INVALID((GType) ((0) << (2)))) | |||
911 | { | |||
912 | GType* children = g_type_children (parent, NULL((void*)0)); | |||
913 | gint i = 0; | |||
914 | ||||
915 | if (!children || children[0] == G_TYPE_INVALID((GType) ((0) << (2)))) | |||
916 | { | |||
917 | g_warning ("bad iterator?"); | |||
918 | return NULL((void*)0); | |||
919 | } | |||
920 | ||||
921 | while (children[i] != type) | |||
922 | ++i; | |||
923 | ||||
924 | ctk_tree_path_prepend_index (retval, i); | |||
925 | ||||
926 | g_free (children); | |||
927 | ||||
928 | type = parent; | |||
929 | parent = g_type_parent (parent); | |||
930 | } | |||
931 | ||||
932 | /* The fundamental type itself is the index on the toplevel */ | |||
933 | ctk_tree_path_prepend_index (retval, type); | |||
934 | ||||
935 | return retval; | |||
936 | } | |||
937 | ||||
938 | static void | |||
939 | ctk_real_model_types_get_value (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
940 | CtkTreeIter *iter, | |||
941 | gint column, | |||
942 | GValue *value) | |||
943 | { | |||
944 | GType type; | |||
945 | ||||
946 | type = GPOINTER_TO_INT (iter->user_data)((gint) (glong) (iter->user_data)); | |||
947 | ||||
948 | switch (column) | |||
949 | { | |||
950 | case 0: | |||
951 | { | |||
952 | gchar *str; | |||
953 | ||||
954 | g_value_init (value, G_TYPE_STRING((GType) ((16) << (2)))); | |||
955 | ||||
956 | str = g_strdup_printf ("%ld", (long int) type); | |||
957 | g_value_set_string (value, str); | |||
958 | g_free (str); | |||
959 | } | |||
960 | break; | |||
961 | ||||
962 | case 1: | |||
963 | g_value_init (value, G_TYPE_STRING((GType) ((16) << (2)))); | |||
964 | g_value_set_string (value, g_type_name (type)); | |||
965 | break; | |||
966 | ||||
967 | default: | |||
968 | g_warning ("Bad column %d requested", column); | |||
969 | } | |||
970 | } | |||
971 | ||||
972 | static gboolean | |||
973 | ctk_real_model_types_iter_next (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
974 | CtkTreeIter *iter) | |||
975 | { | |||
976 | ||||
977 | GType parent; | |||
978 | GType type; | |||
979 | ||||
980 | type = GPOINTER_TO_INT (iter->user_data)((gint) (glong) (iter->user_data)); | |||
981 | ||||
982 | parent = g_type_parent (type); | |||
983 | ||||
984 | if (parent == G_TYPE_INVALID((GType) ((0) << (2)))) | |||
| ||||
985 | { | |||
986 | /* find next _valid_ fundamental type */ | |||
987 | do | |||
988 | type++; | |||
989 | while (!g_type_name (type) && type <= G_TYPE_FUNDAMENTAL_MAX(255 << (2))); | |||
990 | if (type <= G_TYPE_FUNDAMENTAL_MAX(255 << (2))) | |||
991 | { | |||
992 | /* found one */ | |||
993 | iter->user_data = GINT_TO_POINTER (type)((gpointer) (glong) (type)); | |||
994 | return TRUE(!(0)); | |||
995 | } | |||
996 | else | |||
997 | return FALSE(0); | |||
998 | } | |||
999 | else | |||
1000 | { | |||
1001 | GType* children = g_type_children (parent, NULL((void*)0)); | |||
1002 | gint i = 0; | |||
1003 | ||||
1004 | g_assert (children != NULL)do { if (children != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "testtreeview.c", 1004, ((const char*) (__func__ )), "children != NULL"); } while (0); | |||
1005 | ||||
1006 | while (children[i] != type) | |||
1007 | ++i; | |||
1008 | ||||
1009 | ++i; | |||
1010 | ||||
1011 | if (children[i] != G_TYPE_INVALID((GType) ((0) << (2)))) | |||
1012 | { | |||
1013 | g_free (children); | |||
1014 | iter->user_data = GINT_TO_POINTER (children[i])((gpointer) (glong) (children[i])); | |||
| ||||
1015 | return TRUE(!(0)); | |||
1016 | } | |||
1017 | else | |||
1018 | { | |||
1019 | g_free (children); | |||
1020 | return FALSE(0); | |||
1021 | } | |||
1022 | } | |||
1023 | } | |||
1024 | ||||
1025 | static gboolean | |||
1026 | ctk_real_model_types_iter_children (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1027 | CtkTreeIter *iter, | |||
1028 | CtkTreeIter *parent) | |||
1029 | { | |||
1030 | GType type; | |||
1031 | GType* children; | |||
1032 | ||||
1033 | type = GPOINTER_TO_INT (parent->user_data)((gint) (glong) (parent->user_data)); | |||
1034 | ||||
1035 | children = g_type_children (type, NULL((void*)0)); | |||
1036 | ||||
1037 | if (!children || children[0] == G_TYPE_INVALID((GType) ((0) << (2)))) | |||
1038 | { | |||
1039 | g_free (children); | |||
1040 | return FALSE(0); | |||
1041 | } | |||
1042 | else | |||
1043 | { | |||
1044 | iter->user_data = GINT_TO_POINTER (children[0])((gpointer) (glong) (children[0])); | |||
1045 | g_free (children); | |||
1046 | return TRUE(!(0)); | |||
1047 | } | |||
1048 | } | |||
1049 | ||||
1050 | static gboolean | |||
1051 | ctk_real_model_types_iter_has_child (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1052 | CtkTreeIter *iter) | |||
1053 | { | |||
1054 | GType type; | |||
1055 | GType* children; | |||
1056 | ||||
1057 | type = GPOINTER_TO_INT (iter->user_data)((gint) (glong) (iter->user_data)); | |||
1058 | ||||
1059 | children = g_type_children (type, NULL((void*)0)); | |||
1060 | ||||
1061 | if (!children || children[0] == G_TYPE_INVALID((GType) ((0) << (2)))) | |||
1062 | { | |||
1063 | g_free (children); | |||
1064 | return FALSE(0); | |||
1065 | } | |||
1066 | else | |||
1067 | { | |||
1068 | g_free (children); | |||
1069 | return TRUE(!(0)); | |||
1070 | } | |||
1071 | } | |||
1072 | ||||
1073 | static gint | |||
1074 | ctk_real_model_types_iter_n_children (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1075 | CtkTreeIter *iter) | |||
1076 | { | |||
1077 | if (iter == NULL((void*)0)) | |||
1078 | { | |||
1079 | return G_TYPE_FUNDAMENTAL_MAX(255 << (2)); | |||
1080 | } | |||
1081 | else | |||
1082 | { | |||
1083 | GType type; | |||
1084 | GType* children; | |||
1085 | guint n_children = 0; | |||
1086 | ||||
1087 | type = GPOINTER_TO_INT (iter->user_data)((gint) (glong) (iter->user_data)); | |||
1088 | ||||
1089 | children = g_type_children (type, &n_children); | |||
1090 | ||||
1091 | g_free (children); | |||
1092 | ||||
1093 | return n_children; | |||
1094 | } | |||
1095 | } | |||
1096 | ||||
1097 | static gboolean | |||
1098 | ctk_real_model_types_iter_nth_child (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1099 | CtkTreeIter *iter, | |||
1100 | CtkTreeIter *parent, | |||
1101 | gint n) | |||
1102 | { | |||
1103 | if (parent == NULL((void*)0)) | |||
1104 | { | |||
1105 | /* fundamental type */ | |||
1106 | if (n < G_TYPE_FUNDAMENTAL_MAX(255 << (2))) | |||
1107 | { | |||
1108 | iter->user_data = GINT_TO_POINTER (n)((gpointer) (glong) (n)); | |||
1109 | return TRUE(!(0)); | |||
1110 | } | |||
1111 | else | |||
1112 | return FALSE(0); | |||
1113 | } | |||
1114 | else | |||
1115 | { | |||
1116 | GType type = GPOINTER_TO_INT (parent->user_data)((gint) (glong) (parent->user_data)); | |||
1117 | guint n_children = 0; | |||
1118 | GType* children = g_type_children (type, &n_children); | |||
1119 | ||||
1120 | if (n_children == 0) | |||
1121 | { | |||
1122 | g_free (children); | |||
1123 | return FALSE(0); | |||
1124 | } | |||
1125 | else if (n >= n_children) | |||
1126 | { | |||
1127 | g_free (children); | |||
1128 | return FALSE(0); | |||
1129 | } | |||
1130 | else | |||
1131 | { | |||
1132 | iter->user_data = GINT_TO_POINTER (children[n])((gpointer) (glong) (children[n])); | |||
1133 | g_free (children); | |||
1134 | ||||
1135 | return TRUE(!(0)); | |||
1136 | } | |||
1137 | } | |||
1138 | } | |||
1139 | ||||
1140 | static gboolean | |||
1141 | ctk_real_model_types_iter_parent (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1142 | CtkTreeIter *iter, | |||
1143 | CtkTreeIter *child) | |||
1144 | { | |||
1145 | GType type; | |||
1146 | GType parent; | |||
1147 | ||||
1148 | type = GPOINTER_TO_INT (child->user_data)((gint) (glong) (child->user_data)); | |||
1149 | ||||
1150 | parent = g_type_parent (type); | |||
1151 | ||||
1152 | if (parent == G_TYPE_INVALID((GType) ((0) << (2)))) | |||
1153 | { | |||
1154 | if (type > G_TYPE_FUNDAMENTAL_MAX(255 << (2))) | |||
1155 | g_warning ("no parent for %ld %s\n", | |||
1156 | (long int) type, | |||
1157 | g_type_name (type)); | |||
1158 | return FALSE(0); | |||
1159 | } | |||
1160 | else | |||
1161 | { | |||
1162 | iter->user_data = GINT_TO_POINTER (parent)((gpointer) (glong) (parent)); | |||
1163 | ||||
1164 | return TRUE(!(0)); | |||
1165 | } | |||
1166 | } | |||
1167 | ||||
1168 | /* | |||
1169 | * Automated testing | |||
1170 | */ | |||
1171 | ||||
1172 | #if 0 | |||
1173 | ||||
1174 | static void | |||
1175 | treestore_torture_recurse (CtkTreeStore *store, | |||
1176 | CtkTreeIter *root, | |||
1177 | gint depth) | |||
1178 | { | |||
1179 | CtkTreeModel *model; | |||
1180 | gint i; | |||
1181 | CtkTreeIter iter; | |||
1182 | ||||
1183 | model = CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))); | |||
1184 | ||||
1185 | if (depth > 2) | |||
1186 | return; | |||
1187 | ||||
1188 | ++depth; | |||
1189 | ||||
1190 | ctk_tree_store_append (store, &iter, root); | |||
1191 | ||||
1192 | ctk_tree_model_iter_children (model, &iter, root); | |||
1193 | ||||
1194 | i = 0; | |||
1195 | while (i < 100) | |||
1196 | { | |||
1197 | ctk_tree_store_append (store, &iter, root); | |||
1198 | ++i; | |||
1199 | } | |||
1200 | ||||
1201 | while (ctk_tree_model_iter_children (model, &iter, root)) | |||
1202 | ctk_tree_store_remove (store, &iter); | |||
1203 | ||||
1204 | ctk_tree_store_append (store, &iter, root); | |||
1205 | ||||
1206 | /* inserts before last node in tree */ | |||
1207 | i = 0; | |||
1208 | while (i < 100) | |||
1209 | { | |||
1210 | ctk_tree_store_insert_before (store, &iter, root, &iter); | |||
1211 | ++i; | |||
1212 | } | |||
1213 | ||||
1214 | /* inserts after the node before the last node */ | |||
1215 | i = 0; | |||
1216 | while (i < 100) | |||
1217 | { | |||
1218 | ctk_tree_store_insert_after (store, &iter, root, &iter); | |||
1219 | ++i; | |||
1220 | } | |||
1221 | ||||
1222 | /* inserts after the last node */ | |||
1223 | ctk_tree_store_append (store, &iter, root); | |||
1224 | ||||
1225 | i = 0; | |||
1226 | while (i < 100) | |||
1227 | { | |||
1228 | ctk_tree_store_insert_after (store, &iter, root, &iter); | |||
1229 | ++i; | |||
1230 | } | |||
1231 | ||||
1232 | /* remove everything again */ | |||
1233 | while (ctk_tree_model_iter_children (model, &iter, root)) | |||
1234 | ctk_tree_store_remove (store, &iter); | |||
1235 | ||||
1236 | ||||
1237 | /* Prepends */ | |||
1238 | ctk_tree_store_prepend (store, &iter, root); | |||
1239 | ||||
1240 | i = 0; | |||
1241 | while (i < 100) | |||
1242 | { | |||
1243 | ctk_tree_store_prepend (store, &iter, root); | |||
1244 | ++i; | |||
1245 | } | |||
1246 | ||||
1247 | /* remove everything again */ | |||
1248 | while (ctk_tree_model_iter_children (model, &iter, root)) | |||
1249 | ctk_tree_store_remove (store, &iter); | |||
1250 | ||||
1251 | ctk_tree_store_append (store, &iter, root); | |||
1252 | ctk_tree_store_append (store, &iter, root); | |||
1253 | ctk_tree_store_append (store, &iter, root); | |||
1254 | ctk_tree_store_append (store, &iter, root); | |||
1255 | ||||
1256 | while (ctk_tree_model_iter_children (model, &iter, root)) | |||
1257 | { | |||
1258 | treestore_torture_recurse (store, &iter, depth); | |||
1259 | ctk_tree_store_remove (store, &iter); | |||
1260 | } | |||
1261 | } | |||
1262 | ||||
1263 | #endif | |||
1264 | ||||
1265 | static void | |||
1266 | run_automated_tests (void) | |||
1267 | { | |||
1268 | g_print ("Running automated tests...\n"); | |||
1269 | ||||
1270 | /* FIXME TreePath basic verification */ | |||
1271 | ||||
1272 | /* FIXME generic consistency checks on the models */ | |||
1273 | ||||
1274 | { | |||
1275 | /* Make sure list store mutations don't crash anything */ | |||
1276 | CtkListStore *store; | |||
1277 | CtkTreeModel *model; | |||
1278 | gint i; | |||
1279 | CtkTreeIter iter; | |||
1280 | ||||
1281 | store = ctk_list_store_new (1, G_TYPE_INT((GType) ((6) << (2)))); | |||
1282 | ||||
1283 | model = CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))); | |||
1284 | ||||
1285 | i = 0; | |||
1286 | while (i < 100) | |||
1287 | { | |||
1288 | ctk_list_store_append (store, &iter); | |||
1289 | ++i; | |||
1290 | } | |||
1291 | ||||
1292 | while (ctk_tree_model_get_iter_first (model, &iter)) | |||
1293 | ctk_list_store_remove (store, &iter); | |||
1294 | ||||
1295 | ctk_list_store_append (store, &iter); | |||
1296 | ||||
1297 | /* inserts before last node in list */ | |||
1298 | i = 0; | |||
1299 | while (i < 100) | |||
1300 | { | |||
1301 | ctk_list_store_insert_before (store, &iter, &iter); | |||
1302 | ++i; | |||
1303 | } | |||
1304 | ||||
1305 | /* inserts after the node before the last node */ | |||
1306 | i = 0; | |||
1307 | while (i < 100) | |||
1308 | { | |||
1309 | ctk_list_store_insert_after (store, &iter, &iter); | |||
1310 | ++i; | |||
1311 | } | |||
1312 | ||||
1313 | /* inserts after the last node */ | |||
1314 | ctk_list_store_append (store, &iter); | |||
1315 | ||||
1316 | i = 0; | |||
1317 | while (i < 100) | |||
1318 | { | |||
1319 | ctk_list_store_insert_after (store, &iter, &iter); | |||
1320 | ++i; | |||
1321 | } | |||
1322 | ||||
1323 | /* remove everything again */ | |||
1324 | while (ctk_tree_model_get_iter_first (model, &iter)) | |||
1325 | ctk_list_store_remove (store, &iter); | |||
1326 | ||||
1327 | ||||
1328 | /* Prepends */ | |||
1329 | ctk_list_store_prepend (store, &iter); | |||
1330 | ||||
1331 | i = 0; | |||
1332 | while (i < 100) | |||
1333 | { | |||
1334 | ctk_list_store_prepend (store, &iter); | |||
1335 | ++i; | |||
1336 | } | |||
1337 | ||||
1338 | /* remove everything again */ | |||
1339 | while (ctk_tree_model_get_iter_first (model, &iter)) | |||
1340 | ctk_list_store_remove (store, &iter); | |||
1341 | ||||
1342 | g_object_unref (store); | |||
1343 | } | |||
1344 | ||||
1345 | { | |||
1346 | /* Make sure tree store mutations don't crash anything */ | |||
1347 | CtkTreeStore *store; | |||
1348 | CtkTreeIter root; | |||
1349 | ||||
1350 | store = ctk_tree_store_new (1, G_TYPE_INT((GType) ((6) << (2)))); | |||
1351 | ctk_tree_store_append (CTK_TREE_STORE (store)((((CtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_store_get_type ())))))), &root, NULL((void*)0)); | |||
1352 | /* Remove test until it is rewritten to work */ | |||
1353 | /* treestore_torture_recurse (store, &root, 0);*/ | |||
1354 | ||||
1355 | g_object_unref (store); | |||
1356 | } | |||
1357 | ||||
1358 | g_print ("Passed.\n"); | |||
1359 | } |