finch/libgnt/gnttree.c

changeset 35596
5b4df5b31fb2
parent 35594
f1831b0421b2
child 35690
5ef990c032ad
equal deleted inserted replaced
35595:855c4a88c3c6 35596:5b4df5b31fb2
68 68
69 /* XXX: Make this one into a GObject? 69 /* XXX: Make this one into a GObject?
70 * ... Probably not */ 70 * ... Probably not */
71 struct _GntTreeRow 71 struct _GntTreeRow
72 { 72 {
73 int box_count;
74
73 void *key; 75 void *key;
74 void *data; /* XXX: unused */ 76 void *data; /* XXX: unused */
75 77
76 gboolean collapsed; 78 gboolean collapsed;
77 gboolean choice; /* Is this a choice-box? 79 gboolean choice; /* Is this a choice-box?
1957 1959
1958 /************************************************************************** 1960 /**************************************************************************
1959 * GntTreeRow GBoxed API 1961 * GntTreeRow GBoxed API
1960 **************************************************************************/ 1962 **************************************************************************/
1961 static GntTreeRow * 1963 static GntTreeRow *
1962 copy_tree_row(GntTreeRow *row) 1964 gnt_tree_row_ref(GntTreeRow *row)
1963 { 1965 {
1964 GntTreeRow *row_new;
1965
1966 g_return_val_if_fail(row != NULL, NULL); 1966 g_return_val_if_fail(row != NULL, NULL);
1967 1967
1968 row_new = g_new(GntTreeRow, 1); 1968 row->box_count++;
1969 *row_new = *row; 1969
1970 1970 return row;
1971 return row_new; 1971 }
1972
1973 static void
1974 gnt_tree_row_unref(GntTreeRow *row)
1975 {
1976 g_return_if_fail(row != NULL);
1977 g_return_if_fail(row->box_count >= 0);
1978
1979 if (!row->box_count--)
1980 free_tree_row(row);
1972 } 1981 }
1973 1982
1974 GType 1983 GType
1975 gnt_tree_row_get_type(void) 1984 gnt_tree_row_get_type(void)
1976 { 1985 {
1977 static GType type = 0; 1986 static GType type = 0;
1978 1987
1979 if (type == 0) { 1988 if (type == 0) {
1980 type = g_boxed_type_register_static("GntTreeRow", 1989 type = g_boxed_type_register_static("GntTreeRow",
1981 (GBoxedCopyFunc)copy_tree_row, 1990 (GBoxedCopyFunc)gnt_tree_row_ref,
1982 (GBoxedFreeFunc)free_tree_row); 1991 (GBoxedFreeFunc)gnt_tree_row_unref);
1983 } 1992 }
1984 1993
1985 return type; 1994 return type;
1986 } 1995 }

mercurial