comparison finch/libgnt/gnttree.h @ 15817:0e3a8505ebbe

renamed gaim-text to finch
author Sean Egan <seanegan@gmail.com>
date Sun, 18 Mar 2007 19:38:15 +0000
parents
children f00f2e283ffb
comparison
equal deleted inserted replaced
15816:317e7613e581 15817:0e3a8505ebbe
1 #ifndef GNT_TREE_H
2 #define GNT_TREE_H
3
4 #include "gntwidget.h"
5 #include "gnt.h"
6 #include "gntcolors.h"
7 #include "gntkeys.h"
8 #include "gnttextview.h"
9
10 #define GNT_TYPE_TREE (gnt_tree_get_gtype())
11 #define GNT_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_TREE, GntTree))
12 #define GNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_TREE, GntTreeClass))
13 #define GNT_IS_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_TREE))
14 #define GNT_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_TREE))
15 #define GNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_TREE, GntTreeClass))
16
17 #define GNT_TREE_FLAGS(obj) (GNT_TREE(obj)->priv.flags)
18 #define GNT_TREE_SET_FLAGS(obj, flags) (GNT_TREE_FLAGS(obj) |= flags)
19 #define GNT_TREE_UNSET_FLAGS(obj, flags) (GNT_TREE_FLAGS(obj) &= ~(flags))
20
21 typedef struct _GnTree GntTree;
22 typedef struct _GnTreePriv GntTreePriv;
23 typedef struct _GnTreeClass GntTreeClass;
24
25 typedef struct _GnTreeRow GntTreeRow;
26 typedef struct _GnTreeCol GntTreeCol;
27
28 struct _GnTree
29 {
30 GntWidget parent;
31
32 GntTreeRow *current; /* current selection */
33
34 GntTreeRow *top; /* The topmost visible item */
35 GntTreeRow *bottom; /* The bottommost visible item */
36
37 GntTreeRow *root; /* The root of all evil */
38
39 GList *list; /* List of GntTreeRow s */
40 GHashTable *hash; /* We need this for quickly referencing the rows */
41 guint (*hash_func)(gconstpointer);
42 gboolean (*hash_eq_func)(gconstpointer, gconstpointer);
43 GDestroyNotify key_destroy;
44 GDestroyNotify value_destroy;
45
46 int ncol; /* No. of columns */
47 struct _GntTreeColInfo
48 {
49 int width;
50 char *title;
51 } *columns; /* Would a GList be better? */
52 gboolean show_title;
53 gboolean show_separator; /* Whether to show column separators */
54
55 GString *search;
56 int search_timeout;
57
58 GCompareFunc compare;
59 };
60
61 struct _GnTreeClass
62 {
63 GntWidgetClass parent;
64
65 void (*selection_changed)(GntTreeRow *old, GntTreeRow * current);
66 void (*toggled)(GntTree *tree, gpointer key);
67
68 void (*gnt_reserved1)(void);
69 void (*gnt_reserved2)(void);
70 void (*gnt_reserved3)(void);
71 void (*gnt_reserved4)(void);
72 };
73
74 G_BEGIN_DECLS
75
76 GType gnt_tree_get_gtype(void);
77
78 GntWidget *gnt_tree_new(void); /* A tree with just one column */
79
80 GntWidget *gnt_tree_new_with_columns(int columns);
81
82 void gnt_tree_set_visible_rows(GntTree *tree, int rows);
83
84 int gnt_tree_get_visible_rows(GntTree *tree);
85
86 void gnt_tree_scroll(GntTree *tree, int count);
87
88 GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
89
90 GntTreeRow *gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent);
91
92 gpointer gnt_tree_get_selection_data(GntTree *tree);
93
94 /* Returned string needs to be freed */
95 char *gnt_tree_get_selection_text(GntTree *tree);
96
97 GList *gnt_tree_get_selection_text_list(GntTree *tree);
98
99 const GList *gnt_tree_get_rows(GntTree *tree);
100
101 void gnt_tree_remove(GntTree *tree, gpointer key);
102
103 void gnt_tree_remove_all(GntTree *tree);
104
105 /* Returns the visible line number of the selected row */
106 int gnt_tree_get_selection_visible_line(GntTree *tree);
107
108 void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text);
109
110 GntTreeRow *gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
111
112 void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set);
113
114 gboolean gnt_tree_get_choice(GntTree *tree, void *key);
115
116 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags);
117
118 void gnt_tree_set_selected(GntTree *tree , void *key);
119
120 GntTreeRow *gnt_tree_create_row(GntTree *tree, ...);
121
122 GntTreeRow *gnt_tree_create_row_from_list(GntTree *tree, GList *list);
123
124 void gnt_tree_set_col_width(GntTree *tree, int col, int width);
125
126 void gnt_tree_set_column_titles(GntTree *tree, ...);
127
128 void gnt_tree_set_show_title(GntTree *tree, gboolean set);
129
130 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func);
131
132 void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded);
133
134 void gnt_tree_set_show_separator(GntTree *tree, gboolean set);
135
136 void gnt_tree_sort_row(GntTree *tree, void *row);
137
138 /* This will try to automatically adjust the width of the columns in the tree */
139 void gnt_tree_adjust_columns(GntTree *tree);
140
141 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd);
142
143 G_END_DECLS
144
145 /* The following functions should NOT be used by applications. */
146
147 /* This should be called by the subclasses of GntTree's in their _new function */
148 void _gnt_tree_init_internals(GntTree *tree, int col);
149
150 #endif /* GNT_TREE_H */