GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-tree-view.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-tree-view.h -- new GtkTreeView with extra features used by *
3  * all the tree views in gnucash *
4  * Copyright (C) 2003 David Hampton <[email protected]> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA [email protected] *
22  * *
23 \********************************************************************/
24 
32 #ifndef __GNC_TREE_VIEW_H
33 #define __GNC_TREE_VIEW_H
34 
35 #include <gtk/gtk.h>
36 #include "gnc-cell-renderer-date.h"
37 
38 G_BEGIN_DECLS
39 
40 /* type macros */
41 #define GNC_TYPE_TREE_VIEW (gnc_tree_view_get_type ())
42 #define GNC_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW, GncTreeView))
43 #define GNC_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
44 #define GNC_IS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW))
45 #define GNC_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW))
46 #define GNC_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
47 #define GNC_TREE_VIEW_NAME "GncTreeView"
48 
49 
50 /* typedefs & structures */
51 typedef struct
52 {
53  GtkTreeView gtk_tree_view;
54 } GncTreeView;
55 
56 typedef struct
57 {
58  GtkTreeViewClass gtk_tree_view;
60 
61 /* Standard g_object type */
62 GType gnc_tree_view_get_type (void);
63 
64 
65 /* The columns managed by gnc-tree-view can use the following column
66  attributes. Set them with:
67 
68  g_object_set_data(col, ATTRIBUTE_NAME, value);
69 */
70 
71 /* The column id refers to a specific column in the tree model. It is
72  * also attached to the side of the tree column to allow lookup of a
73  * GtkTreeViewColumn when passed a column id from the underlying
74  * model. By convention, negative column numbers are used when the
75  * visible column has no association with the underlying model.*/
76 #define MODEL_COLUMN "model_column"
77 
78 /* For checkbox columns, this contains the real title for the column. */
79 #define REAL_TITLE "real_title"
80 
81 /* The name of this column to use when saving the view's state. It is
82  * used internally to map this colum's properties to the saved state. */
83 #define PREF_NAME "pref-name"
84 
85 /* A column with this attribute set cannot be hidden from view. Valid
86  values: GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
87 #define ALWAYS_VISIBLE "always-visible"
88 
89 /* This attribute controls visibility of a column if not state was saved
90  for this column (yet). Valid values:
91  GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
92 #define DEFAULT_VISIBLE "default-visible"
93 
94 #define GNC_TREE_VIEW_COLUMN_DATA_NONE -1
95 #define GNC_TREE_VIEW_COLUMN_COLOR_NONE -1
96 #define GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS -1
97 
98 
99 typedef void (* renderer_toggled) (GtkCellRendererToggle *cell_renderer_toggle,
100  const gchar *path,
101  gpointer user_data);
102 
103 
145 GtkTreeViewColumn *
147  const gchar *column_title,
148  const gchar *column_short_title,
149  const gchar *pref_name,
150  gint model_data_column,
151  gint model_visibility_column,
152  GtkTreeIterCompareFunc column_sort_fn,
153  renderer_toggled toggle_edited_cb);
154 
192 GtkTreeViewColumn *
194  const gchar *column_title,
195  const gchar *pref_name,
196  const gchar *stock_icon_name,
197  const gchar *sizing_text,
198  gint model_data_column,
199  gint model_visibility_column,
200  GtkTreeIterCompareFunc column_sort_fn);
201 
209 GtkTreeViewColumn *
211  const gchar *column_title,
212  const gchar *pref_name,
213  const gchar *sizing_text,
214  gint model_data_column,
215  gint model_visibility_column,
216  GtkTreeModel *combo_tree_model,
217  gint combo_model_text_column,
218  GtkTreeIterCompareFunc column_sort_fn);
219 
220 
225 GtkTreeViewColumn *
227  const gchar *column_title,
228  const gchar *pref_name,
229  const gchar *stock_icon_name,
230  const gchar *sizing_text,
231  gint model_data_column,
232  gint model_visibility_column,
233  GtkTreeIterCompareFunc column_sort_fn);
234 
235 
275 GtkTreeViewColumn *
277  const gchar *column_title,
278  const gchar *pref_name,
279  const gchar *sizing_text,
280  gint model_data_column,
281  gint model_color_column,
282  gint model_visibility_column,
283  GtkTreeIterCompareFunc column_sort_fn);
284 
298  GtkTreeViewColumn *column);
299 
313 
324 GtkTreeViewColumn *
326  const gchar *wanted);
327 
344  const gchar *section);
345 
354 const gchar *gnc_tree_view_get_state_section (GncTreeView *view);
355 
356 
365 
366 
374 
375 
384  gchar *first_column_name,
385  ...);
386 
397 void
399  GtkTreeCellDataFunc func);
400 
407 void
408 gnc_tree_view_set_sort_user_data (GncTreeView *view, GtkTreeModel *s_model);
409 
418 void
420  gboolean visible);
421 
430 gboolean
432 
440 GtkCellRenderer *
441 gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column);
442 
443 
444 /* Takes a GdkEventKey and the current path and column for the
445  * treeview. Interprets the event as something that might move the
446  * cursor. Returns the new column and the possibly changed (if
447  * navigation wrapped a row) path. */
448 void
449 gnc_tree_view_keynav(GncTreeView *view, GtkTreeViewColumn **col,
450  GtkTreePath *path, GdkEventKey *event);
451 
452 /* Returns TRUE if path is a vaid path for the treeview */
453 gboolean
454 gnc_tree_view_path_is_valid(GncTreeView *view, GtkTreePath *path);
455 
460 G_END_DECLS
461 
462 #endif /* __GNC_TREE_VIEW_H */
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
void gnc_tree_view_expand_columns(GncTreeView *view, gchar *first_column_name,...)
void gnc_tree_view_set_state_section(GncTreeView *view, const gchar *section)
GtkTreeViewColumn * gnc_tree_view_add_date_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
void gnc_tree_view_set_control_column_background(GncTreeView *view, gint column, GtkTreeCellDataFunc func)
GtkTreeViewColumn * gnc_tree_view_add_numeric_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_color_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
GtkTreeViewColumn * gnc_tree_view_add_combo_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeModel *combo_tree_model, gint combo_model_text_column, GtkTreeIterCompareFunc column_sort_fn)
GtkTreeViewColumn * gnc_tree_view_add_toggle_column(GncTreeView *view, const gchar *column_title, const gchar *column_short_title, const gchar *pref_name, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn, renderer_toggled toggle_edited_cb)
const gchar * gnc_tree_view_get_state_section(GncTreeView *view)
GType gnc_tree_view_get_type(void)
void gnc_tree_view_remove_state_information(GncTreeView *view)
void gnc_tree_view_configure_columns(GncTreeView *view)
void gnc_tree_view_set_sort_user_data(GncTreeView *view, GtkTreeModel *s_model)
gboolean gnc_tree_view_get_show_column_menu(GncTreeView *view)
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
void gnc_tree_view_set_show_column_menu(GncTreeView *view, gboolean visible)
void gnc_tree_view_save_state(GncTreeView *view)
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)