blob: bc751229a464cef9a8d020155dc116706945f736 (
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
|
/*
* E-Table-Group.c: Implements the grouping objects for elements on a table
*
* Author:
* Miguel de Icaza (miguel@gnu.org()
*
* Copyright 1999, Helix Code, Inc.
*/
#include <config.h>
#include "e-table-group.h"
void
e_table_group_destroy (ETableGroup *etg)
{
g_return_if_fail (etg != NULL);
g_free (etg->title);
if (etg->is_leaf == 0){
GSList *l;
for (l = etg->u.children; l; l = l->next){
ETableGroup *child = l->data;
e_table_group_destroy (child);
}
g_slist_free (etg->u.children);
etg->u.children = NULL;
}
g_free (etg);
}
ETableGroup *
e_table_group_new_leaf (const char *title, ETableModel *table)
{
ETableGroup *etg;
g_return_val_if_fail (title != NULL, NULL);
g_return_val_if_fail (table != NULL, NULL);
etg = g_new (ETableGroup, 1);
etg->expanded = 0;
etg->is_leaf = 1;
etg->u.table = table;
etg->title = g_strdup (title);
return etg;
}
ETableGroup *
e_table_group_new (const char *title)
{
ETableGroup *etg;
g_return_val_if_fail (title != NULL, NULL);
etg = g_new (ETableGroup, 1);
etg->expanded = 0;
etg->is_leaf = 0;
etg->u.children = NULL;
etg->title = g_strdup (title);
return etg;
}
void
e_table_group_append_child (ETableGroup *etg, ETableGroup *child)
{
g_return_if_fail (etg != NULL);
g_return_if_fail (child != NULL);
g_return_if_fail (etg->is_leaf != 0);
etg->u.children = g_slist_append (etg->u.children, child);
}
int
e_table_group_size (ETableGroup *etg)
{
g_return_if_fail (etg != NULL);
if (etg->is_leaf)
return e_table_model_height (etg->u.table);
else {
GSList *l;
int size = 0;
for (l = etg->u.children; l; l = l->next){
ETableGroup *child = l->data;
size += e_table_group_size (child);
}
return size;
}
}
|