gnttree.h
Go to the documentation of this file.
1 
5 /*
6  * GNT - The GLib Ncurses Toolkit
7  *
8  * GNT is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This library is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  */
26 
27 #ifndef GNT_TREE_H
28 #define GNT_TREE_H
29 
30 #include "gntwidget.h"
31 #include "gnt.h"
32 #include "gntcolors.h"
33 #include "gntkeys.h"
34 #include "gnttextview.h"
35 
36 #define GNT_TYPE_TREE (gnt_tree_get_gtype())
37 #define GNT_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_TREE, GntTree))
38 #define GNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_TREE, GntTreeClass))
39 #define GNT_IS_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_TREE))
40 #define GNT_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_TREE))
41 #define GNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_TREE, GntTreeClass))
42 
43 typedef struct _GntTree GntTree;
44 typedef struct _GntTreePriv GntTreePriv;
45 typedef struct _GntTreeClass GntTreeClass;
46 
47 typedef struct _GntTreeRow GntTreeRow;
48 typedef struct _GntTreeCol GntTreeCol;
49 
50 typedef enum _GntTreeColumnFlag {
51  GNT_TREE_COLUMN_INVISIBLE = 1 << 0,
52  GNT_TREE_COLUMN_FIXED_SIZE = 1 << 1,
53  GNT_TREE_COLUMN_BINARY_DATA = 1 << 2,
54  GNT_TREE_COLUMN_RIGHT_ALIGNED = 1 << 3,
55 } GntTreeColumnFlag;
56 
57 struct _GntTree
58 {
59  GntWidget parent;
60 
61  GntTreeRow *current; /* current selection */
62 
63  GntTreeRow *top; /* The topmost visible item */
64  GntTreeRow *bottom; /* The bottommost visible item */
65 
66  GntTreeRow *root; /* The root of all evil */
67 
68  GList *list; /* List of GntTreeRow s */
69  GHashTable *hash; /* We need this for quickly referencing the rows */
70  guint (*hash_func)(gconstpointer);
71  gboolean (*hash_eq_func)(gconstpointer, gconstpointer);
72  GDestroyNotify key_destroy;
73  GDestroyNotify value_destroy;
74 
75  int ncol; /* No. of columns */
77  {
78  int width;
79  char *title;
80  int width_ratio;
81  GntTreeColumnFlag flags;
82  } *columns; /* Would a GList be better? */
83  gboolean show_title;
84  gboolean show_separator; /* Whether to show column separators */
85 
86  GntTreePriv *priv;
87 };
88 
90 {
91  GntWidgetClass parent;
92 
93  void (*selection_changed)(GntTreeRow *old, GntTreeRow * current);
94  void (*toggled)(GntTree *tree, gpointer key);
95 
96  void (*gnt_reserved1)(void);
97  void (*gnt_reserved2)(void);
98  void (*gnt_reserved3)(void);
99  void (*gnt_reserved4)(void);
100 };
101 
102 G_BEGIN_DECLS
103 
107 GType gnt_tree_get_gtype(void);
108 
116 GntWidget * gnt_tree_new(void);
117 
127 GntWidget * gnt_tree_new_with_columns(int columns);
128 
135 void gnt_tree_set_visible_rows(GntTree *tree, int rows);
136 
145 
153 void gnt_tree_scroll(GntTree *tree, int count);
154 
170 GntTreeRow * gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
171 
186 GntTreeRow * gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent);
187 
195 gpointer gnt_tree_get_selection_data(GntTree *tree);
196 
207 
222 GList * gnt_tree_get_row_text_list(GntTree *tree, gpointer key);
223 
233 gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row);
234 
244 GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row);
245 
255 GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row);
256 
266 GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row);
267 
277 GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row);
278 
292 
300 GList *gnt_tree_get_rows(GntTree *tree);
301 
308 void gnt_tree_remove(GntTree *tree, gpointer key);
309 
315 void gnt_tree_remove_all(GntTree *tree);
316 
325 
334 void gnt_tree_change_text(GntTree *tree, gpointer key, int colno, const char *text);
335 
352 GntTreeRow * gnt_tree_add_choice(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro);
353 
361 void gnt_tree_set_choice(GntTree *tree, void *key, gboolean set);
362 
371 gboolean gnt_tree_get_choice(GntTree *tree, void *key);
372 
380 void gnt_tree_set_row_flags(GntTree *tree, void *key, GntTextFormatFlags flags);
381 
390 void gnt_tree_set_row_color(GntTree *tree, void *key, int color);
391 
398 void gnt_tree_set_selected(GntTree *tree , void *key);
399 
413 GntTreeRow * gnt_tree_create_row(GntTree *tree, ...);
414 
428 GntTreeRow * gnt_tree_create_row_from_list(GntTree *tree, GList *list);
429 
440 void gnt_tree_set_col_width(GntTree *tree, int col, int width);
441 
454 void gnt_tree_set_column_title(GntTree *tree, int index, const char *title);
455 
465 void gnt_tree_set_column_titles(GntTree *tree, ...);
466 
476 void gnt_tree_set_show_title(GntTree *tree, gboolean set);
477 
487 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func);
488 
496 void gnt_tree_set_expanded(GntTree *tree, void *key, gboolean expanded);
497 
504 void gnt_tree_set_show_separator(GntTree *tree, gboolean set);
505 
514 void gnt_tree_sort_row(GntTree *tree, void *row);
515 
521 void gnt_tree_adjust_columns(GntTree *tree);
522 
532 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd);
533 
543 void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis);
544 
559 void gnt_tree_set_column_resizable(GntTree *tree, int col, gboolean res);
560 
569 void gnt_tree_set_column_is_binary(GntTree *tree, int col, gboolean bin);
570 
580 void gnt_tree_set_column_is_right_aligned(GntTree *tree, int col, gboolean right);
581 
596 void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]);
597 
606 void gnt_tree_set_search_column(GntTree *tree, int col);
607 
616 gboolean gnt_tree_is_searching(GntTree *tree);
617 
631  gboolean (*func)(GntTree *tree, gpointer key, const char *search, const char *current));
632 
642 gpointer gnt_tree_get_parent_key(GntTree *tree, gpointer key);
643 
644 G_END_DECLS
645 
646 #endif /* GNT_TREE_H */