GnuCash  4.11-137-g155922540d+
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 #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 column'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 *icon_name,
197  const gchar *sizing_text,
198  gint model_data_column,
199  gint model_visibility_column,
200  GtkTreeIterCompareFunc column_sort_fn);
201 
239 GtkTreeViewColumn *
241  const gchar *column_title,
242  const gchar *pref_name,
243  const gchar *icon_name,
244  const gchar *sizing_text,
245  gint model_data_column,
246  gint model_visibility_column,
247  GtkTreeIterCompareFunc column_sort_fn);
248 
256 GtkTreeViewColumn *
258  const gchar *column_title,
259  const gchar *pref_name,
260  const gchar *sizing_text,
261  gint model_data_column,
262  gint model_visibility_column,
263  GtkTreeModel *combo_tree_model,
264  gint combo_model_text_column,
265  GtkTreeIterCompareFunc column_sort_fn);
266 
267 
272 GtkTreeViewColumn *
274  const gchar *column_title,
275  const gchar *pref_name,
276  const gchar *icon_name,
277  const gchar *sizing_text,
278  gint model_data_column,
279  gint model_visibility_column,
280  GtkTreeIterCompareFunc column_sort_fn);
281 
282 
322 GtkTreeViewColumn *
324  const gchar *column_title,
325  const gchar *pref_name,
326  const gchar *sizing_text,
327  gint model_data_column,
328  gint model_color_column,
329  gint model_visibility_column,
330  GtkTreeIterCompareFunc column_sort_fn);
331 
345  GtkTreeViewColumn *column);
346 
360 
371 GtkTreeViewColumn *
373  const gchar *wanted);
374 
391  const gchar *section);
392 
401 const gchar *gnc_tree_view_get_state_section (GncTreeView *view);
402 
403 
412 
413 
421 
422 
431  gchar *first_column_name,
432  ...);
433 
444 void
446  GtkTreeCellDataFunc func);
447 
454 void
455 gnc_tree_view_set_sort_user_data (GncTreeView *view, GtkTreeModel *s_model);
456 
465 void
467  gboolean visible);
468 
477 gboolean
479 
487 GtkCellRenderer *
488 gnc_tree_view_column_get_renderer (GtkTreeViewColumn *column);
489 
490 
491 /* Takes a GdkEventKey and the current path and column for the
492  * treeview. Interprets the event as something that might move the
493  * cursor. Returns the new column and the possibly changed (if
494  * navigation wrapped a row) path. */
495 void
496 gnc_tree_view_keynav (GncTreeView *view, GtkTreeViewColumn **col,
497  GtkTreePath *path, GdkEventKey *event);
498 
499 /* Returns TRUE if path is a valid path for the treeview */
500 gboolean
501 gnc_tree_view_path_is_valid (GncTreeView *view, GtkTreePath *path);
502 
506 void
508  GFunc editing_started_cb, gpointer editing_cb_data);
509 
513 void
515  GFunc editing_finished_cb, gpointer editing_cb_data);
516 
521 G_END_DECLS
522 
523 #endif /* __GNC_TREE_VIEW_H */
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.
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.
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...
GtkTreeViewColumn * gnc_tree_view_add_date_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 date 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...
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.
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)
This function adds a new combobox column to a GncTreeView base view.
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.
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_remove_state_information(GncTreeView *view)
This function is called to completely wipe the treeview&#39;s state information (column visibility...
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
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...
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...
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.
void gnc_tree_view_set_sort_user_data(GncTreeView *view, GtkTreeModel *s_model)
This allows the columns to be setup without the model connected.
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.
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name".
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_set_show_column_menu(GncTreeView *view, gboolean visible)
This function is called to set the "show-column-menu" property on this view.
void gnc_tree_view_save_state(GncTreeView *view)
This function is called to write the treeview&#39;s state information (column visibility, width, sorting order,..) to the state file.
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...