GnuCash c935c2f+
Loading...
Searching...
No Matches
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 <hampton@employees.org> *
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 gnu@gnu.org *
22 * *
23\********************************************************************/
24
32#ifndef __GNC_TREE_VIEW_H
33#define __GNC_TREE_VIEW_H
34
35#include <gtk/gtk.h>
36
37G_BEGIN_DECLS
38
39/* type macros */
40#define GNC_TYPE_TREE_VIEW (gnc_tree_view_get_type ())
41G_DECLARE_DERIVABLE_TYPE (GncTreeView, gnc_tree_view, GNC, TREE_VIEW, GtkTreeView)
42
43#define GNC_TREE_VIEW_NAME "GncTreeView"
44
45
46/* typedefs & structures */
48{
49 GtkTreeViewClass gtk_tree_view;
50};
51
52/* The columns managed by gnc-tree-view can use the following column
53 attributes. Set them with:
54
55 g_object_set_data(col, ATTRIBUTE_NAME, value);
56*/
57
58/* The column id refers to a specific column in the tree model. It is
59 * also attached to the side of the tree column to allow lookup of a
60 * GtkTreeViewColumn when passed a column id from the underlying
61 * model. By convention, negative column numbers are used when the
62 * visible column has no association with the underlying model.*/
63#define MODEL_COLUMN "model_column"
64
65/* For checkbox columns, this contains the real title for the column. */
66#define REAL_TITLE "real_title"
67
68/* The name of this column to use when saving the view's state. It is
69 * used internally to map this column's properties to the saved state. */
70#define PREF_NAME "pref-name"
71
72/* A column with this attribute set cannot be hidden from view. Valid
73 values: GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
74#define ALWAYS_VISIBLE "always-visible"
75
76/* This attribute controls visibility of a column if not state was saved
77 for this column (yet). Valid values:
78 GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
79#define DEFAULT_VISIBLE "default-visible"
80
81#define GNC_TREE_VIEW_COLUMN_DATA_NONE -1
82#define GNC_TREE_VIEW_COLUMN_COLOR_NONE -1
83#define GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS -1
84
85
86typedef void (* renderer_toggled) (GtkCellRendererToggle *cell_renderer_toggle,
87 const gchar *path,
88 gpointer user_data);
89
90
132GtkTreeViewColumn *
133gnc_tree_view_add_toggle_column (GncTreeView *view,
134 const gchar *column_title,
135 const gchar *column_short_title,
136 const gchar *pref_name,
137 gint model_data_column,
138 gint model_visibility_column,
139 GtkTreeIterCompareFunc column_sort_fn,
140 renderer_toggled toggle_edited_cb);
141
179GtkTreeViewColumn *
180gnc_tree_view_add_text_column (GncTreeView *view,
181 const gchar *column_title,
182 const gchar *pref_name,
183 const gchar *icon_name,
184 const gchar *sizing_text,
185 gint model_data_column,
186 gint model_visibility_column,
187 GtkTreeIterCompareFunc column_sort_fn);
188
226GtkTreeViewColumn *
227gnc_tree_view_add_text_view_column (GncTreeView *view,
228 const gchar *column_title,
229 const gchar *pref_name,
230 const gchar *icon_name,
231 const gchar *sizing_text,
232 gint model_data_column,
233 gint model_visibility_column,
234 GtkTreeIterCompareFunc column_sort_fn);
235
268GtkTreeViewColumn *
269gnc_tree_view_add_pix_column (GncTreeView *view,
270 const gchar *column_title,
271 const gchar *pref_name,
272 const gchar *sizing_text,
273 gint model_data_column,
274 gint model_visibility_column,
275 GtkTreeIterCompareFunc column_sort_fn);
276
316GtkTreeViewColumn *
317gnc_tree_view_add_numeric_column (GncTreeView *view,
318 const gchar *column_title,
319 const gchar *pref_name,
320 const gchar *sizing_text,
321 gint model_data_column,
322 gint model_color_column,
323 gint model_visibility_column,
324 GtkTreeIterCompareFunc column_sort_fn);
325
338gint gnc_tree_view_append_column (GncTreeView *view,
339 GtkTreeViewColumn *column);
340
353void gnc_tree_view_configure_columns (GncTreeView *view);
354
365GtkTreeViewColumn *
366gnc_tree_view_find_column_by_name (GncTreeView *view,
367 const gchar *wanted);
368
384void gnc_tree_view_set_state_section (GncTreeView *view,
385 const gchar *section);
386
395const gchar *gnc_tree_view_get_state_section (GncTreeView *view);
396
397
405void gnc_tree_view_remove_state_information(GncTreeView *view);
406
407
414void gnc_tree_view_save_state (GncTreeView *view);
415
416
424void gnc_tree_view_expand_columns (GncTreeView *view,
425 gchar *first_column_name,
426 ...);
427
438void
439gnc_tree_view_set_control_column_background (GncTreeView *view, gint column,
440 GtkTreeCellDataFunc func);
441
448void
449gnc_tree_view_set_sort_user_data (GncTreeView *view, GtkTreeModel *s_model);
450
459void
460gnc_tree_view_set_show_column_menu (GncTreeView *view,
461 gboolean visible);
462
471gboolean
472gnc_tree_view_get_show_column_menu (GncTreeView *view);
473
481GtkCellRenderer *
482gnc_tree_view_column_get_renderer (GtkTreeViewColumn *column);
483
484
485/* Takes a GdkEventKey and the current path and column for the
486 * treeview. Interprets the event as something that might move the
487 * cursor. Returns the new column and the possibly changed (if
488 * navigation wrapped a row) path. */
489void
490gnc_tree_view_keynav (GncTreeView *view, GtkTreeViewColumn **col,
491 GtkTreePath *path, GdkEventKey *event);
492
493/* Returns TRUE if path is a valid path for the treeview */
494gboolean
495gnc_tree_view_path_is_valid (GncTreeView *view, GtkTreePath *path);
496
500void
501gnc_tree_view_set_editing_started_cb (GncTreeView *view,
502 GFunc editing_started_cb, gpointer editing_cb_data);
503
507void
509 GFunc editing_finished_cb, gpointer editing_cb_data);
510
515G_END_DECLS
516
517#endif /* __GNC_TREE_VIEW_H */
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting,...
void gnc_tree_view_set_editing_finished_cb(GncTreeView *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup a callback for when the user finishes editing so appropriate actions can be taken like enable t...
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
Return the "main" cell renderer from a GtkTreeViewColumn added to a GncTreeView my one of the conveni...
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text column to a GncTreeView base view.
void gnc_tree_view_remove_state_information(GncTreeView *view)
This function is called to completely wipe the treeview's state information (column visibility,...
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)
This function adds a new toggle column to a GncTreeView base view.
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)
This function adds a new numeric column to a GncTreeView base view.
void gnc_tree_view_set_control_column_background(GncTreeView *view, gint column, GtkTreeCellDataFunc func)
This function links the cell backgrounds of the two control columns to a column in the model that has...
void gnc_tree_view_set_editing_started_cb(GncTreeView *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup a callback for when the user starts editing so appropriate actions can be taken like disable th...
void gnc_tree_view_save_state(GncTreeView *view)
This function is called to write the treeview's state information (column visibility,...
void gnc_tree_view_set_show_column_menu(GncTreeView *view, gboolean visible)
This function is called to set the "show-column-menu" property on this view.
GtkTreeViewColumn * gnc_tree_view_add_text_view_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text view column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_add_pix_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a pixbuf view column to a GncTreeView base view.
const gchar * gnc_tree_view_get_state_section(GncTreeView *view)
This function is called to get the current association between a saved state section and the display ...
void gnc_tree_view_set_state_section(GncTreeView *view, const gchar *section)
This function is called to set up or remove an association between a saved state section and the disp...
void gnc_tree_view_expand_columns(GncTreeView *view, gchar *first_column_name,...)
This function set the columns that will be allocated the free space in the view.
gboolean gnc_tree_view_get_show_column_menu(GncTreeView *view)
This function is called to get the current value of the "show-column-menu" property.
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.
void gnc_tree_view_set_sort_user_data(GncTreeView *view, GtkTreeModel *s_model)
This allows the columns to be setup without the model connected.
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name".