aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-tree-model.c
blob: 24eada7d56ad3485cf7fb68c9cc1441ca661011b (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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * e-tree-model.c: a Tree Model
 *
 * Author:
 *   Chris Toshok (toshok@ximian.com)
 *   Chris Lahey  <clahey@ximian.com>
 *
 * Adapted from the gtree code and ETableModel.
 *
 * (C) 2000, 2001 Ximian, Inc.
 */
#include <config.h>

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>

#include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>

#include <gtk/gtksignal.h>
#include <stdlib.h>
#include "gal/util/e-util.h"
#include "gal/util/e-xml-utils.h"
#include "e-tree-model.h"

#define ETM_CLASS(e) ((ETreeModelClass *)((GtkObject *)e)->klass)

#define PARENT_TYPE (gtk_object_get_type())

static GtkObjectClass *parent_class;

enum {
    PRE_CHANGE,
    NODE_CHANGED,
    NODE_DATA_CHANGED,
    NODE_COL_CHANGED,
    NODE_INSERTED,
    NODE_REMOVED,
    LAST_SIGNAL
};

static guint e_tree_model_signals [LAST_SIGNAL] = {0, };


static void
e_tree_model_class_init (GtkObjectClass *klass)
{
    ETreeModelClass *tree_class = (ETreeModelClass *) klass;

    parent_class = gtk_type_class (PARENT_TYPE);

    e_tree_model_signals [PRE_CHANGE] =
        gtk_signal_new ("pre_change",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, pre_change),
                gtk_marshal_NONE__NONE,
                GTK_TYPE_NONE, 0);

    e_tree_model_signals [NODE_CHANGED] =
        gtk_signal_new ("node_changed",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, node_changed),
                gtk_marshal_NONE__POINTER,
                GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);

    e_tree_model_signals [NODE_DATA_CHANGED] =
        gtk_signal_new ("node_data_changed",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, node_data_changed),
                gtk_marshal_NONE__POINTER,
                GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);

    e_tree_model_signals [NODE_COL_CHANGED] =
        gtk_signal_new ("node_col_changed",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, node_col_changed),
                gtk_marshal_NONE__POINTER_INT,
                GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_INT);

    e_tree_model_signals [NODE_INSERTED] =
        gtk_signal_new ("node_inserted",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, node_inserted),
                gtk_marshal_NONE__POINTER_POINTER,
                GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);

    e_tree_model_signals [NODE_REMOVED] =
        gtk_signal_new ("node_removed",
                GTK_RUN_LAST,
                klass->type,
                GTK_SIGNAL_OFFSET (ETreeModelClass, node_removed),
                e_marshal_NONE__POINTER_POINTER_INT,
                GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_POINTER, GTK_TYPE_INT);

    gtk_object_class_add_signals (klass, e_tree_model_signals, LAST_SIGNAL);

    tree_class->get_root             = NULL;

    tree_class->get_parent           = NULL;
    tree_class->get_first_child      = NULL;
    tree_class->get_last_child       = NULL;
    tree_class->get_next             = NULL;
    tree_class->get_prev             = NULL;

    tree_class->is_root              = NULL;
    tree_class->is_expandable        = NULL;
    tree_class->get_children         = NULL;
    tree_class->depth                = NULL;

    tree_class->icon_at              = NULL;

    tree_class->get_expanded_default = NULL;
    tree_class->column_count         = NULL;

    tree_class->has_save_id          = NULL;
    tree_class->get_save_id          = NULL;

    tree_class->value_at             = NULL;
    tree_class->set_value_at         = NULL;
    tree_class->is_editable          = NULL;

    tree_class->duplicate_value      = NULL;
    tree_class->free_value           = NULL;
    tree_class->initialize_value     = NULL;
    tree_class->value_is_empty       = NULL;
    tree_class->value_to_string      = NULL;

    tree_class->pre_change           = NULL;
    tree_class->node_changed         = NULL;
    tree_class->node_data_changed    = NULL;
    tree_class->node_col_changed     = NULL;
    tree_class->node_inserted        = NULL;
    tree_class->node_removed         = NULL;
}

static void
e_tree_init (GtkObject *object)
{
}

E_MAKE_TYPE(e_tree_model, "ETreeModel", ETreeModel, e_tree_model_class_init, e_tree_init, PARENT_TYPE)


/* signals */

/**
 * e_tree_model_node_changed:
 * @tree_model: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
void
e_tree_model_pre_change  (ETreeModel *tree_model)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));
    
    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [PRE_CHANGE]);
}

/**
 * e_tree_model_node_changed:
 * @tree_model: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
void
e_tree_model_node_changed  (ETreeModel *tree_model, ETreePath node)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));
    
    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [NODE_CHANGED], node);
}

/**
 * e_tree_model_node_data_changed:
 * @tree_model: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
void
e_tree_model_node_data_changed  (ETreeModel *tree_model, ETreePath node)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));
    
    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [NODE_DATA_CHANGED], node);
}

/**
 * e_tree_model_node_col_changed:
 * @tree_model: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
void
e_tree_model_node_col_changed  (ETreeModel *tree_model, ETreePath node, int col)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));
    
    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [NODE_COL_CHANGED], node, col);
}

/**
 * e_tree_model_node_inserted:
 * @tree_model: 
 * @parent_node: 
 * @inserted_node: 
 * 
 * 
 **/
void
e_tree_model_node_inserted (ETreeModel *tree_model,
                ETreePath parent_node,
                ETreePath inserted_node)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));

    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [NODE_INSERTED],
             parent_node, inserted_node);
}

/**
 * e_tree_model_node_removed:
 * @tree_model: 
 * @parent_node: 
 * @removed_node: 
 * 
 * 
 **/
void
e_tree_model_node_removed  (ETreeModel *tree_model, ETreePath parent_node, ETreePath removed_node, int old_position)
{
    g_return_if_fail (tree_model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (tree_model));
    
    gtk_signal_emit (GTK_OBJECT (tree_model),
             e_tree_model_signals [NODE_REMOVED],
             parent_node, removed_node, old_position);
}



/**
 * e_tree_model_new
 *
 * XXX docs here.
 *
 * return values: a newly constructed ETreeModel.
 */
ETreeModel *
e_tree_model_new ()
{
    ETreeModel *et;

    et = gtk_type_new (e_tree_model_get_type ());

    return et;
}

/**
 * e_tree_model_get_root
 * @etree: the ETreeModel of which we want the root node.
 *
 * Accessor for the root node of @etree.
 *
 * return values: the ETreePath corresponding to the root node.
 */
ETreePath 
e_tree_model_get_root (ETreeModel *etree)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_root)
        return ETM_CLASS(etree)->get_root(etree);
    else
        return NULL;
}

/**
 * e_tree_model_node_get_parent:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
ETreePath 
e_tree_model_node_get_parent (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail(etree != NULL, NULL);
    if (ETM_CLASS(etree)->get_parent)
        return ETM_CLASS(etree)->get_parent(etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_node_get_first_child:
 * @etree: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
ETreePath 
e_tree_model_node_get_first_child (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_first_child)
        return ETM_CLASS(etree)->get_first_child(etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_node_get_last_child:
 * @etree: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
ETreePath 
e_tree_model_node_get_last_child (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_last_child)
        return ETM_CLASS(etree)->get_last_child(etree, node);
    else
        return NULL;
}


/**
 * e_tree_model_node_get_next:
 * @etree: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
ETreePath 
e_tree_model_node_get_next (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_next)
        return ETM_CLASS(etree)->get_next(etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_node_get_prev:
 * @etree: 
 * @node: 
 * 
 * 
 * 
 * Return value: 
 **/
ETreePath 
e_tree_model_node_get_prev (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_prev)
        return ETM_CLASS(etree)->get_prev(etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_node_is_root:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
gboolean
e_tree_model_node_is_root (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail(etree != NULL, FALSE);

    if (ETM_CLASS(etree)->is_root)
        return ETM_CLASS(etree)->is_root(etree, node);
    else
        return FALSE;
}

/**
 * e_tree_model_node_is_expandable:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
gboolean
e_tree_model_node_is_expandable (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail(etree != NULL, FALSE);

    if (ETM_CLASS(etree)->is_expandable)
        return ETM_CLASS(etree)->is_expandable(etree, node);
    else
        return FALSE;
}

guint
e_tree_model_node_get_children (ETreeModel *etree, ETreePath node, ETreePath **nodes)
{
    g_return_val_if_fail(etree != NULL, 0);
    if (ETM_CLASS(etree)->get_children)
        return ETM_CLASS(etree)->get_children (etree, node, nodes);
    else
        return 0;
}

/**
 * e_tree_model_node_depth:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
guint
e_tree_model_node_depth (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, 0);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), 0);

    if (ETM_CLASS(etree)->depth)
        return ETM_CLASS(etree)->depth(etree, node);
    else
        return 0;
}

/**
 * e_tree_model_icon_at
 * @etree: The ETreeModel.
 * @path: The ETreePath to the node we're getting the icon of.
 *
 * XXX docs here.
 *
 * return values: the GdkPixbuf associated with this node.
 */
GdkPixbuf *
e_tree_model_icon_at (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->icon_at)
        return ETM_CLASS(etree)->icon_at (etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_get_expanded_default
 * @etree: The ETreeModel.
 *
 * XXX docs here.
 *
 * return values: Whether nodes should be expanded by default.
 */
gboolean
e_tree_model_get_expanded_default (ETreeModel *etree)
{
    g_return_val_if_fail (etree != NULL, FALSE);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), FALSE);

    if (ETM_CLASS(etree)->get_expanded_default)
        return ETM_CLASS(etree)->get_expanded_default (etree);
    else
        return FALSE;
}

/**
 * e_tree_model_column_count
 * @etree: The ETreeModel.
 *
 * XXX docs here.
 *
 * return values: The number of columns
 */
gint
e_tree_model_column_count (ETreeModel *etree)
{
    g_return_val_if_fail (etree != NULL, 0);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), 0);

    if (ETM_CLASS(etree)->column_count)
        return ETM_CLASS(etree)->column_count (etree);
    else
        return 0;
}

/**
 * e_tree_model_has_save_id
 * @etree: The ETreeModel.
 *
 * XXX docs here.
 *
 * return values: Whether this tree has valid save id data.
 */
gboolean
e_tree_model_has_save_id (ETreeModel *etree)
{
    g_return_val_if_fail (etree != NULL, FALSE);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), FALSE);

    if (ETM_CLASS(etree)->has_save_id)
        return ETM_CLASS(etree)->has_save_id (etree);
    else
        return FALSE;
}

/**
 * e_tree_model_get_save_id
 * @etree: The ETreeModel.
 * @node: The ETreePath.
 *
 * XXX docs here.
 *
 * return values: The save id for this path.
 */
gchar *
e_tree_model_get_save_id (ETreeModel *etree, ETreePath node)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->get_save_id)
        return ETM_CLASS(etree)->get_save_id (etree, node);
    else
        return NULL;
}

/**
 * e_tree_model_icon_of_node
 * @etree: The ETreeModel.
 * @path: The ETreePath to the node we're getting the icon of.
 *
 * XXX docs here.
 *
 * return values: the GdkPixbuf associated with this node.
 */
void *
e_tree_model_value_at (ETreeModel *etree, ETreePath node, int col)
{
    g_return_val_if_fail (etree != NULL, NULL);
    g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);

    if (ETM_CLASS(etree)->value_at)
        return ETM_CLASS(etree)->value_at (etree, node, col);
    else
        return NULL;
}

/**
 * e_tree_model_icon_of_node
 * @etree: The ETreeModel.
 * @path: The ETreePath to the node we're getting the icon of.
 *
 * XXX docs here.
 *
 * return values: the GdkPixbuf associated with this node.
 */
void
e_tree_model_set_value_at (ETreeModel *etree, ETreePath node, int col, const void *val)
{
    g_return_if_fail (etree != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (etree));

    if (ETM_CLASS(etree)->set_value_at)
        ETM_CLASS(etree)->set_value_at (etree, node, col, val);
}

/**
 * e_tree_model_node_is_editable:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
gboolean
e_tree_model_node_is_editable (ETreeModel *etree, ETreePath node, int col)
{
    g_return_val_if_fail(etree != NULL, FALSE);

    if (ETM_CLASS(etree)->is_editable)
        return ETM_CLASS(etree)->is_editable(etree, node, col);
    else
        return FALSE;
}

/**
 * e_tree_model_duplicate_value:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
void *
e_tree_model_duplicate_value (ETreeModel *etree, int col, const void *value)
{
    g_return_val_if_fail(etree != NULL, NULL);

    if (ETM_CLASS(etree)->duplicate_value)
        return ETM_CLASS(etree)->duplicate_value(etree, col, value);
    else
        return NULL;
}

/**
 * e_tree_model_free_value:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
void
e_tree_model_free_value (ETreeModel *etree, int col, void *value)
{
    g_return_if_fail(etree != NULL);

    if (ETM_CLASS(etree)->free_value)
        ETM_CLASS(etree)->free_value(etree, col, value);
}

/**
 * e_tree_model_initialize_value:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
void *
e_tree_model_initialize_value (ETreeModel *etree, int col)
{
    g_return_val_if_fail(etree != NULL, NULL);

    if (ETM_CLASS(etree)->initialize_value)
        return ETM_CLASS(etree)->initialize_value(etree, col);
    else
        return NULL;
}

/**
 * e_tree_model_value_is_empty:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
gboolean
e_tree_model_value_is_empty (ETreeModel *etree, int col, const void *value)
{
    g_return_val_if_fail(etree != NULL, TRUE);

    if (ETM_CLASS(etree)->value_is_empty)
        return ETM_CLASS(etree)->value_is_empty(etree, col, value);
    else
        return TRUE;
}

/**
 * e_tree_model_value_to_string:
 * @etree: 
 * @path: 
 * 
 * 
 * 
 * Return value: 
 **/
char *
e_tree_model_value_to_string (ETreeModel *etree, int col, const void *value)
{
    g_return_val_if_fail(etree != NULL, g_strdup(""));

    if (ETM_CLASS(etree)->value_to_string)
        return ETM_CLASS(etree)->value_to_string(etree, col, value);
    else
        return g_strdup("");
}

/**
 * e_tree_model_node_traverse:
 * @model: 
 * @path: 
 * @func: 
 * @data: 
 * 
 * 
 **/
void
e_tree_model_node_traverse (ETreeModel *model, ETreePath path, ETreePathFunc func, gpointer data)
{
    ETreePath child;

    g_return_if_fail (model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (model));
    g_return_if_fail (path != NULL);

    child = e_tree_model_node_get_first_child (model, path);

    while (child) {
        ETreePath next_child;

        next_child = e_tree_model_node_get_next (model, child);
        e_tree_model_node_traverse (model, child, func, data);
        if (func (model, child, data) == TRUE)
            return;

        child = next_child;
    }
}

/**
 * e_tree_model_node_traverse_preorder:
 * @model: 
 * @path: 
 * @func: 
 * @data: 
 * 
 * 
 **/
void
e_tree_model_node_traverse_preorder (ETreeModel *model, ETreePath path, ETreePathFunc func, gpointer data)
{
    ETreePath child;

    g_return_if_fail (model != NULL);
    g_return_if_fail (E_IS_TREE_MODEL (model));
    g_return_if_fail (path != NULL);

    child = e_tree_model_node_get_first_child (model, path);

    while (child) {
        ETreePath next_child;

        if (func (model, child, data) == TRUE)
            return;

        next_child = e_tree_model_node_get_next (model, child);
        e_tree_model_node_traverse_preorder (model, child, func, data);

        child = next_child;
    }
}