1 | /* testtreefocus.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 "config.h" |
20 | #include <gtk/gtk.h> |
21 | |
22 | typedef struct _TreeStruct TreeStruct; |
23 | struct _TreeStruct |
24 | { |
25 | const char *label; |
26 | gboolean alex; |
27 | gboolean havoc; |
28 | gboolean tim; |
29 | gboolean owen; |
30 | gboolean dave; |
31 | gboolean world_holiday; /* shared by the european hackers */ |
32 | TreeStruct *children; |
33 | }; |
34 | |
35 | |
36 | static TreeStruct january[] = |
37 | { |
38 | {"New Years Day" , TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL }, |
39 | {"Presidential Inauguration" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
40 | {"Martin Luther King Jr. day" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
41 | { NULL } |
42 | }; |
43 | |
44 | static TreeStruct february[] = |
45 | { |
46 | { "Presidents' Day" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
47 | { "Groundhog Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
48 | { "Valentine's Day" , FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, NULL }, |
49 | { NULL } |
50 | }; |
51 | |
52 | static TreeStruct march[] = |
53 | { |
54 | { "National Tree Planting Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
55 | { "St Patrick's Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
56 | { NULL } |
57 | }; |
58 | |
59 | static TreeStruct april[] = |
60 | { |
61 | { "April Fools' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
62 | { "Army Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
63 | { "Earth Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
64 | { "Administrative Professionals' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
65 | { NULL } |
66 | }; |
67 | |
68 | static TreeStruct may[] = |
69 | { |
70 | { "Nurses' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
71 | { "National Day of Prayer" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
72 | { "Mothers' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
73 | { "Armed Forces Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
74 | { "Memorial Day" , TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL }, |
75 | { NULL } |
76 | }; |
77 | |
78 | static TreeStruct june[] = |
79 | { |
80 | { "June Fathers' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
81 | { "Juneteenth (Liberation Day)" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
82 | { "Flag Day" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
83 | { NULL } |
84 | }; |
85 | |
86 | static TreeStruct july[] = |
87 | { |
88 | { "Parents' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
89 | { "Independence Day" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
90 | { NULL } |
91 | }; |
92 | |
93 | static TreeStruct august[] = |
94 | { |
95 | { "Air Force Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
96 | { "Coast Guard Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
97 | { "Friendship Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
98 | { NULL } |
99 | }; |
100 | |
101 | static TreeStruct september[] = |
102 | { |
103 | { "Grandparents' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
104 | { "Citizenship Day or Constitution Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
105 | { "Labor Day" , TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL }, |
106 | { NULL } |
107 | }; |
108 | |
109 | static TreeStruct october[] = |
110 | { |
111 | { "National Children's Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
112 | { "Bosses' Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
113 | { "Sweetest Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
114 | { "Mother-in-Law's Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
115 | { "Navy Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
116 | { "Columbus Day" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
117 | { "Halloween" , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL }, |
118 | { NULL } |
119 | }; |
120 | |
121 | static TreeStruct november[] = |
122 | { |
123 | { "Marine Corps Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
124 | { "Veterans' Day" , TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL }, |
125 | { "Thanksgiving" , FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL }, |
126 | { NULL } |
127 | }; |
128 | |
129 | static TreeStruct december[] = |
130 | { |
131 | { "Pearl Harbor Remembrance Day" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
132 | { "Christmas" , TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL }, |
133 | { "Kwanzaa" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }, |
134 | { NULL } |
135 | }; |
136 | |
137 | |
138 | static TreeStruct toplevel[] = |
139 | { |
140 | {"January" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, january}, |
141 | {"February" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, february}, |
142 | {"March" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, march}, |
143 | {"April" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, april}, |
144 | {"May" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, may}, |
145 | {"June" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, june}, |
146 | {"July" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, july}, |
147 | {"August" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, august}, |
148 | {"September" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, september}, |
149 | {"October" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, october}, |
150 | {"November" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, november}, |
151 | {"December" , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, december}, |
152 | {NULL} |
153 | }; |
154 | |
155 | |
156 | enum |
157 | { |
158 | HOLIDAY_COLUMN = 0, |
159 | ALEX_COLUMN, |
160 | HAVOC_COLUMN, |
161 | TIM_COLUMN, |
162 | OWEN_COLUMN, |
163 | DAVE_COLUMN, |
164 | VISIBLE_COLUMN, |
165 | WORLD_COLUMN, |
166 | NUM_COLUMNS |
167 | }; |
168 | |
169 | static GtkTreeModel * |
170 | make_model (void) |
171 | { |
172 | GtkTreeStore *model; |
173 | TreeStruct *month = toplevel; |
174 | GtkTreeIter iter; |
175 | |
176 | model = gtk_tree_store_new (n_columns: NUM_COLUMNS, |
177 | G_TYPE_STRING, |
178 | G_TYPE_BOOLEAN, |
179 | G_TYPE_BOOLEAN, |
180 | G_TYPE_BOOLEAN, |
181 | G_TYPE_BOOLEAN, |
182 | G_TYPE_BOOLEAN, |
183 | G_TYPE_BOOLEAN, |
184 | G_TYPE_BOOLEAN); |
185 | |
186 | while (month->label) |
187 | { |
188 | TreeStruct *holiday = month->children; |
189 | |
190 | gtk_tree_store_append (tree_store: model, iter: &iter, NULL); |
191 | gtk_tree_store_set (tree_store: model, iter: &iter, |
192 | HOLIDAY_COLUMN, month->label, |
193 | ALEX_COLUMN, FALSE, |
194 | HAVOC_COLUMN, FALSE, |
195 | TIM_COLUMN, FALSE, |
196 | OWEN_COLUMN, FALSE, |
197 | DAVE_COLUMN, FALSE, |
198 | VISIBLE_COLUMN, FALSE, |
199 | WORLD_COLUMN, FALSE, |
200 | -1); |
201 | while (holiday->label) |
202 | { |
203 | GtkTreeIter child_iter; |
204 | |
205 | gtk_tree_store_append (tree_store: model, iter: &child_iter, parent: &iter); |
206 | gtk_tree_store_set (tree_store: model, iter: &child_iter, |
207 | HOLIDAY_COLUMN, holiday->label, |
208 | ALEX_COLUMN, holiday->alex, |
209 | HAVOC_COLUMN, holiday->havoc, |
210 | TIM_COLUMN, holiday->tim, |
211 | OWEN_COLUMN, holiday->owen, |
212 | DAVE_COLUMN, holiday->dave, |
213 | VISIBLE_COLUMN, TRUE, |
214 | WORLD_COLUMN, holiday->world_holiday, |
215 | -1); |
216 | |
217 | holiday ++; |
218 | } |
219 | month ++; |
220 | } |
221 | |
222 | return GTK_TREE_MODEL (model); |
223 | } |
224 | |
225 | static void |
226 | alex_toggled (GtkCellRendererToggle *cell, |
227 | char *path_str, |
228 | gpointer data) |
229 | { |
230 | GtkTreeModel *model = (GtkTreeModel *) data; |
231 | GtkTreeIter iter; |
232 | GtkTreePath *path = gtk_tree_path_new_from_string (path: path_str); |
233 | gboolean alex; |
234 | |
235 | gtk_tree_model_get_iter (tree_model: model, iter: &iter, path); |
236 | gtk_tree_model_get (tree_model: model, iter: &iter, ALEX_COLUMN, &alex, -1); |
237 | |
238 | alex = !alex; |
239 | gtk_tree_store_set (GTK_TREE_STORE (model), iter: &iter, ALEX_COLUMN, alex, -1); |
240 | |
241 | gtk_tree_path_free (path); |
242 | } |
243 | |
244 | static void |
245 | havoc_toggled (GtkCellRendererToggle *cell, |
246 | char *path_str, |
247 | gpointer data) |
248 | { |
249 | GtkTreeModel *model = (GtkTreeModel *) data; |
250 | GtkTreeIter iter; |
251 | GtkTreePath *path = gtk_tree_path_new_from_string (path: path_str); |
252 | gboolean havoc; |
253 | |
254 | gtk_tree_model_get_iter (tree_model: model, iter: &iter, path); |
255 | gtk_tree_model_get (tree_model: model, iter: &iter, HAVOC_COLUMN, &havoc, -1); |
256 | |
257 | havoc = !havoc; |
258 | gtk_tree_store_set (GTK_TREE_STORE (model), iter: &iter, HAVOC_COLUMN, havoc, -1); |
259 | |
260 | gtk_tree_path_free (path); |
261 | } |
262 | |
263 | static void |
264 | owen_toggled (GtkCellRendererToggle *cell, |
265 | char *path_str, |
266 | gpointer data) |
267 | { |
268 | GtkTreeModel *model = (GtkTreeModel *) data; |
269 | GtkTreeIter iter; |
270 | GtkTreePath *path = gtk_tree_path_new_from_string (path: path_str); |
271 | gboolean owen; |
272 | |
273 | gtk_tree_model_get_iter (tree_model: model, iter: &iter, path); |
274 | gtk_tree_model_get (tree_model: model, iter: &iter, OWEN_COLUMN, &owen, -1); |
275 | |
276 | owen = !owen; |
277 | gtk_tree_store_set (GTK_TREE_STORE (model), iter: &iter, OWEN_COLUMN, owen, -1); |
278 | |
279 | gtk_tree_path_free (path); |
280 | } |
281 | |
282 | static void |
283 | tim_toggled (GtkCellRendererToggle *cell, |
284 | char *path_str, |
285 | gpointer data) |
286 | { |
287 | GtkTreeModel *model = (GtkTreeModel *) data; |
288 | GtkTreeIter iter; |
289 | GtkTreePath *path = gtk_tree_path_new_from_string (path: path_str); |
290 | gboolean tim; |
291 | |
292 | gtk_tree_model_get_iter (tree_model: model, iter: &iter, path); |
293 | gtk_tree_model_get (tree_model: model, iter: &iter, TIM_COLUMN, &tim, -1); |
294 | |
295 | tim = !tim; |
296 | gtk_tree_store_set (GTK_TREE_STORE (model), iter: &iter, TIM_COLUMN, tim, -1); |
297 | |
298 | gtk_tree_path_free (path); |
299 | } |
300 | |
301 | static void |
302 | dave_toggled (GtkCellRendererToggle *cell, |
303 | char *path_str, |
304 | gpointer data) |
305 | { |
306 | GtkTreeModel *model = (GtkTreeModel *) data; |
307 | GtkTreeIter iter; |
308 | GtkTreePath *path = gtk_tree_path_new_from_string (path: path_str); |
309 | gboolean dave; |
310 | |
311 | gtk_tree_model_get_iter (tree_model: model, iter: &iter, path); |
312 | gtk_tree_model_get (tree_model: model, iter: &iter, DAVE_COLUMN, &dave, -1); |
313 | |
314 | dave = !dave; |
315 | gtk_tree_store_set (GTK_TREE_STORE (model), iter: &iter, DAVE_COLUMN, dave, -1); |
316 | |
317 | gtk_tree_path_free (path); |
318 | } |
319 | |
320 | static void |
321 | set_indicator_size (GtkTreeViewColumn *column, |
322 | GtkCellRenderer *cell, |
323 | GtkTreeModel *model, |
324 | GtkTreeIter *iter, |
325 | gpointer data) |
326 | { |
327 | int size; |
328 | GtkTreePath *path; |
329 | |
330 | path = gtk_tree_model_get_path (tree_model: model, iter); |
331 | size = gtk_tree_path_get_indices (path)[0] * 2 + 10; |
332 | gtk_tree_path_free (path); |
333 | |
334 | g_object_set (object: cell, first_property_name: "indicator_size" , size, NULL); |
335 | } |
336 | |
337 | static void |
338 | quit_cb (GtkWidget *widget, |
339 | gpointer data) |
340 | { |
341 | gboolean *done = data; |
342 | |
343 | *done = TRUE; |
344 | |
345 | g_main_context_wakeup (NULL); |
346 | } |
347 | |
348 | int |
349 | main (int argc, char *argv[]) |
350 | { |
351 | GtkWidget *window; |
352 | GtkWidget *vbox; |
353 | GtkWidget *scrolled_window; |
354 | GtkWidget *tree_view; |
355 | GtkTreeModel *model; |
356 | GtkCellRenderer *renderer; |
357 | int col_offset; |
358 | GtkTreeViewColumn *column; |
359 | gboolean done = FALSE; |
360 | |
361 | gtk_init (); |
362 | |
363 | window = gtk_window_new (); |
364 | gtk_window_set_title (GTK_WINDOW (window), title: "Card planning sheet" ); |
365 | g_signal_connect (window, "destroy" , G_CALLBACK (quit_cb), &done); |
366 | vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 8); |
367 | gtk_box_append (GTK_BOX (vbox), child: gtk_label_new (str: "Jonathan's Holiday Card Planning Sheet" )); |
368 | gtk_window_set_child (GTK_WINDOW (window), child: vbox); |
369 | |
370 | scrolled_window = gtk_scrolled_window_new (); |
371 | gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (scrolled_window), TRUE); |
372 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), hscrollbar_policy: GTK_POLICY_AUTOMATIC, vscrollbar_policy: GTK_POLICY_AUTOMATIC); |
373 | gtk_widget_set_vexpand (widget: scrolled_window, TRUE); |
374 | gtk_box_append (GTK_BOX (vbox), child: scrolled_window); |
375 | |
376 | model = make_model (); |
377 | tree_view = gtk_tree_view_new_with_model (model); |
378 | gtk_tree_selection_set_mode (selection: gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), |
379 | type: GTK_SELECTION_MULTIPLE); |
380 | renderer = gtk_cell_renderer_text_new (); |
381 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
382 | position: -1, title: "Holiday" , |
383 | cell: renderer, |
384 | "text" , HOLIDAY_COLUMN, NULL); |
385 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
386 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
387 | |
388 | /* Alex Column */ |
389 | renderer = gtk_cell_renderer_toggle_new (); |
390 | g_signal_connect (renderer, "toggled" , G_CALLBACK (alex_toggled), model); |
391 | |
392 | g_object_set (object: renderer, first_property_name: "xalign" , 0.0, NULL); |
393 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
394 | position: -1, title: "Alex" , |
395 | cell: renderer, |
396 | "active" , ALEX_COLUMN, |
397 | "visible" , VISIBLE_COLUMN, |
398 | "activatable" , WORLD_COLUMN, |
399 | NULL); |
400 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
401 | gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), type: GTK_TREE_VIEW_COLUMN_FIXED); |
402 | gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), fixed_width: 50); |
403 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
404 | |
405 | /* Havoc Column */ |
406 | renderer = gtk_cell_renderer_toggle_new (); |
407 | g_signal_connect (renderer, "toggled" , G_CALLBACK (havoc_toggled), model); |
408 | |
409 | g_object_set (object: renderer, first_property_name: "xalign" , 0.0, NULL); |
410 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
411 | position: -1, title: "Havoc" , |
412 | cell: renderer, |
413 | "active" , HAVOC_COLUMN, |
414 | "visible" , VISIBLE_COLUMN, |
415 | NULL); |
416 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
417 | gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), type: GTK_TREE_VIEW_COLUMN_FIXED); |
418 | gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), fixed_width: 50); |
419 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
420 | |
421 | /* Tim Column */ |
422 | renderer = gtk_cell_renderer_toggle_new (); |
423 | g_signal_connect (renderer, "toggled" , G_CALLBACK (tim_toggled), model); |
424 | |
425 | g_object_set (object: renderer, first_property_name: "xalign" , 0.0, NULL); |
426 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
427 | position: -1, title: "Tim" , |
428 | cell: renderer, |
429 | "active" , TIM_COLUMN, |
430 | "visible" , VISIBLE_COLUMN, |
431 | "activatable" , WORLD_COLUMN, |
432 | NULL); |
433 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
434 | gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), type: GTK_TREE_VIEW_COLUMN_FIXED); |
435 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
436 | gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), fixed_width: 50); |
437 | |
438 | /* Owen Column */ |
439 | renderer = gtk_cell_renderer_toggle_new (); |
440 | g_signal_connect (renderer, "toggled" , G_CALLBACK (owen_toggled), model); |
441 | g_object_set (object: renderer, first_property_name: "xalign" , 0.0, NULL); |
442 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
443 | position: -1, title: "Owen" , |
444 | cell: renderer, |
445 | "active" , OWEN_COLUMN, |
446 | "visible" , VISIBLE_COLUMN, |
447 | NULL); |
448 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
449 | gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), type: GTK_TREE_VIEW_COLUMN_FIXED); |
450 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
451 | gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), fixed_width: 50); |
452 | |
453 | /* Owen Column */ |
454 | renderer = gtk_cell_renderer_toggle_new (); |
455 | g_signal_connect (renderer, "toggled" , G_CALLBACK (dave_toggled), model); |
456 | g_object_set (object: renderer, first_property_name: "xalign" , 0.0, NULL); |
457 | col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
458 | position: -1, title: "Dave" , |
459 | cell: renderer, |
460 | "active" , DAVE_COLUMN, |
461 | "visible" , VISIBLE_COLUMN, |
462 | NULL); |
463 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), n: col_offset - 1); |
464 | gtk_tree_view_column_set_cell_data_func (tree_column: column, cell_renderer: renderer, func: set_indicator_size, NULL, NULL); |
465 | gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), type: GTK_TREE_VIEW_COLUMN_FIXED); |
466 | gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), fixed_width: 50); |
467 | gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); |
468 | |
469 | gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window), child: tree_view); |
470 | |
471 | g_signal_connect (tree_view, "realize" , |
472 | G_CALLBACK (gtk_tree_view_expand_all), |
473 | NULL); |
474 | gtk_window_set_default_size (GTK_WINDOW (window), |
475 | width: 650, height: 400); |
476 | gtk_widget_show (widget: window); |
477 | |
478 | window = gtk_window_new (); |
479 | gtk_window_set_title (GTK_WINDOW (window), title: "Model" ); |
480 | g_signal_connect (window, "destroy" , G_CALLBACK (quit_cb), &done); |
481 | vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 8); |
482 | gtk_box_append (GTK_BOX (vbox), child: gtk_label_new (str: "The model revealed" )); |
483 | gtk_window_set_child (GTK_WINDOW (window), child: vbox); |
484 | |
485 | scrolled_window = gtk_scrolled_window_new (); |
486 | gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (scrolled_window), TRUE); |
487 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), hscrollbar_policy: GTK_POLICY_AUTOMATIC, vscrollbar_policy: GTK_POLICY_AUTOMATIC); |
488 | gtk_widget_set_vexpand (widget: scrolled_window, TRUE); |
489 | gtk_box_append (GTK_BOX (vbox), child: scrolled_window); |
490 | |
491 | |
492 | tree_view = gtk_tree_view_new_with_model (model); |
493 | g_object_unref (object: model); |
494 | |
495 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
496 | position: -1, title: "Holiday Column" , |
497 | cell: gtk_cell_renderer_text_new (), |
498 | "text" , 0, NULL); |
499 | |
500 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
501 | position: -1, title: "Alex Column" , |
502 | cell: gtk_cell_renderer_text_new (), |
503 | "text" , 1, NULL); |
504 | |
505 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
506 | position: -1, title: "Havoc Column" , |
507 | cell: gtk_cell_renderer_text_new (), |
508 | "text" , 2, NULL); |
509 | |
510 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
511 | position: -1, title: "Tim Column" , |
512 | cell: gtk_cell_renderer_text_new (), |
513 | "text" , 3, NULL); |
514 | |
515 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
516 | position: -1, title: "Owen Column" , |
517 | cell: gtk_cell_renderer_text_new (), |
518 | "text" , 4, NULL); |
519 | |
520 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
521 | position: -1, title: "Dave Column" , |
522 | cell: gtk_cell_renderer_text_new (), |
523 | "text" , 5, NULL); |
524 | |
525 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
526 | position: -1, title: "Visible Column" , |
527 | cell: gtk_cell_renderer_text_new (), |
528 | "text" , 6, NULL); |
529 | |
530 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), |
531 | position: -1, title: "World Holiday" , |
532 | cell: gtk_cell_renderer_text_new (), |
533 | "text" , 7, NULL); |
534 | |
535 | g_signal_connect (tree_view, "realize" , |
536 | G_CALLBACK (gtk_tree_view_expand_all), |
537 | NULL); |
538 | |
539 | gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window), child: tree_view); |
540 | |
541 | gtk_window_set_default_size (GTK_WINDOW (window), |
542 | width: 650, height: 400); |
543 | |
544 | gtk_widget_show (widget: window); |
545 | while (!done) |
546 | g_main_context_iteration (NULL, TRUE); |
547 | |
548 | return 0; |
549 | } |
550 | |
551 | |