GnuCash  4.14+
gnc-tree-view-account.h
Go to the documentation of this file.
1 /**********************************************************************\
2  * gnc-tree-view-account.h -- GtkTreeView implementation to display *
3  * accounts in a GtkTreeView. *
4  * Copyright (C) 2003,2005,2006 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 
34 #ifndef __GNC_TREE_VIEW_ACCOUNT_H
35 #define __GNC_TREE_VIEW_ACCOUNT_H
36 
37 #include <gtk/gtk.h>
38 #include "gnc-tree-view.h"
39 
40 #include "gnc-ui-util.h"
41 #include "gnc-plugin-page.h"
42 
43 G_BEGIN_DECLS
44 
45 /* type macros */
46 #define GNC_TYPE_TREE_VIEW_ACCOUNT (gnc_tree_view_account_get_type ())
47 #define GNC_TREE_VIEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccount))
48 #define GNC_TREE_VIEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
49 #define GNC_IS_TREE_VIEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT))
50 #define GNC_IS_TREE_VIEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT))
51 #define GNC_TREE_VIEW_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
52 #define GNC_TREE_VIEW_ACCOUNT_NAME "GncTreeViewAccount"
53 
54 /* typedefs & structures */
55 typedef struct AccountViewInfo_s AccountViewInfo;
56 
57 
59 {
60  gboolean include_type[NUM_ACCOUNT_TYPES];
61  gboolean show_hidden;
62 };
63 
64 
65 typedef struct
66 {
67  GncTreeView gnc_tree_view;
68  int stamp;
70 
71 typedef struct
72 {
73  GncTreeViewClass gnc_tree_view;
75 
76 typedef struct
77 {
78  GtkWidget *dialog;
79  GtkTreeModel *model;
80  GncTreeViewAccount *tree_view;
81  GHashTable *filter_override;
82  guint32 visible_types;
83  guint32 original_visible_types;
84  gboolean show_hidden;
85  gboolean original_show_hidden;
86  gboolean show_zero_total;
87  gboolean original_show_zero_total;
88  gboolean show_unused;
89  gboolean original_show_unused;
91 
92 void account_filter_dialog_create(AccountFilterDialog *fd,
93  GncPluginPage *page);
94 
96  gpointer user_data);
97 
98 /* "Filter By" dialog callbacks */
99 void gppat_filter_show_hidden_toggled_cb (GtkToggleButton *togglebutton,
100  AccountFilterDialog *fd);
101 void gppat_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton,
102  AccountFilterDialog *fd);
103 void gppat_filter_show_unused_toggled_cb (GtkToggleButton *togglebutton,
104  AccountFilterDialog *fd);
105 void gppat_filter_clear_all_cb (GtkWidget *button, AccountFilterDialog *fd);
106 void gppat_filter_select_all_cb (GtkWidget *button, AccountFilterDialog *fd);
107 void gppat_filter_select_default_cb (GtkWidget *button,
108  AccountFilterDialog *fd);
109 void gppat_filter_response_cb (GtkWidget *dialog, gint response,
110  AccountFilterDialog *fd);
111 
112 /* Saving/Restoring */
113 void gnc_tree_view_account_save(GncTreeViewAccount *tree_view,
115  GKeyFile *key_file, const gchar *group_name);
116 void gnc_tree_view_account_restore(GncTreeViewAccount *view,
118  GKeyFile *key_file,
119  const gchar *group_name);
120 
121 void gnc_tree_view_account_save_filter (GncTreeViewAccount *tree_view,
123  GKeyFile *key_file,
124  const gchar *group_name);
125 void gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
127  GKeyFile *key_file,
128  const gchar *group_name);
129 
130 
131 /* Get the GType for an GncTreeViewAccount object. */
132 GType gnc_tree_view_account_get_type (void);
133 
134 
150 GtkTreeView *gnc_tree_view_account_new_with_root (Account *root,
151  gboolean show_root);
152 
164 GtkTreeView *gnc_tree_view_account_new (gboolean show_root);
165 
172 typedef gchar * (*GncTreeViewAccountColumnSource) (Account *account,
173  GtkTreeViewColumn *col,
174  GtkCellRenderer *cell);
175 
176 typedef void (*GncTreeViewAccountColumnTextEdited) (Account *account,
177  GtkTreeViewColumn *col,
178  const gchar *new_text);
179 
180 
197 GtkTreeViewColumn * gnc_tree_view_account_add_custom_column(
198  GncTreeViewAccount *view, const gchar *column_title,
199  GncTreeViewAccountColumnSource source_cb,
200  GncTreeViewAccountColumnTextEdited edited_cb);
201 GtkTreeViewColumn *gnc_tree_view_account_add_custom_column_renderer(
202  GncTreeViewAccount *account_view, const gchar *column_title,
203  GncTreeViewAccountColumnSource col_source_cb,
204  GncTreeViewAccountColumnTextEdited col_edited_cb,
205  GtkCellRenderer *renderer);
206 void gnc_tree_view_account_set_name_edited(GncTreeViewAccount *view,
207  GncTreeViewAccountColumnTextEdited edited_cb);
208 void gnc_tree_view_account_name_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_name);
209 
210 void gnc_tree_view_account_set_code_edited(GncTreeViewAccount *view,
211  GncTreeViewAccountColumnTextEdited edited_cb);
212 void gnc_tree_view_account_code_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_code);
213 
214 void gnc_tree_view_account_set_description_edited(GncTreeViewAccount *view,
215  GncTreeViewAccountColumnTextEdited edited_cb);
216 void gnc_tree_view_account_description_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_desc);
217 
218 void gnc_tree_view_account_set_notes_edited(GncTreeViewAccount *view,
219  GncTreeViewAccountColumnTextEdited edited_cb);
220 void gnc_tree_view_account_notes_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_notes);
221 
233 GtkTreeViewColumn *
235  const gchar *column_title,
236  const gchar *propname);
237 
255  AccountViewInfo *avi);
256 
269  AccountViewInfo *avi);
270 
271 
280 typedef gboolean (*gnc_tree_view_account_filter_func)(Account *account, gpointer data);
281 
282 
304  gpointer data,
305  GSourceFunc destroy);
306 
307 /* This is a convenient filter function for use with
308  * gnc_tree_view_account_set_filter() and the functions in
309  * gnc-tree-model-account-types.h. If you have some view that is
310  * backed by the "account types" tree model, you can get a guint32
311  * from that view's tree selection. Then, you can use that account
312  * type selection as a filter for the account tree view. This also
313  * can filter by whether an account is hidden or not.
314  */
315 gboolean gnc_tree_view_account_filter_by_view_info(
316  Account* acct, gpointer data);
317 
318 
347  Account *account);
348 
356 
357 
369  GtkTreePath *path);
370 
371 
383  GtkTreeIter *iter);
384 
385 
395 
396 
409 
410 
427  Account *account);
428 
429 
442 
443 
466  GList *account_list,
467  gboolean show_last);
468 
469 
483  Account *account);
484 
493 
497 void gnc_tree_view_account_column_add_color (GncTreeViewAccount *view, GtkTreeViewColumn *col);
498 
503  (GncTreeViewAccount *view, GFunc editing_started_cb, gpointer editing_cb_data );
504 
509  (GncTreeViewAccount *view, GFunc editing_finished_cb, gpointer editing_cb_data );
510 
511 
517 G_END_DECLS
518 
519 #endif /* __GNC_TREE_VIEW_ACCOUNT_H */
void gnc_tree_view_account_get_view_info(GncTreeViewAccount *account_view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will copy the current con...
GtkTreeViewColumn * gnc_tree_view_account_add_property_column(GncTreeViewAccount *view, const gchar *column_title, const gchar *propname)
Add a new column to the set of columns in an account tree view.
The instance data structure for a content plugin.
GList * gnc_tree_view_account_get_selected_accounts(GncTreeViewAccount *view)
This function returns a list of the accounts associated with the selected items in the account tree v...
Account * gnc_tree_view_account_get_cursor_account(GncTreeViewAccount *view)
This function returns the account in the account tree view at the current location of the cursor...
void gnc_tree_view_account_set_editing_finished_cb(GncTreeViewAccount *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup the callback for when the user finishes editing the account tree so actions can be enabled like...
utility functions for the GnuCash UI
void gppat_filter_response_cb(GtkWidget *dialog, gint response, AccountFilterDialog *fd)
The Filter dialog was closed.
common utilities for manipulating a GtkTreeView within gnucash
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select all account types" button in the Filter dialog was clicked.
stop here; the following types just aren&#39;t ready for prime time
Definition: Account.h:164
void gnc_tree_view_account_expand_to_account(GncTreeViewAccount *view, Account *account)
This function forces the account tree expand whatever levels are necessary to make the specified acco...
void gnc_tree_view_account_column_add_color(GncTreeViewAccount *view, GtkTreeViewColumn *col)
Add the account color background data function to the GncTreeViewAccount column to show or not the co...
void gnc_tree_view_account_set_view_info(GncTreeViewAccount *account_view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will applies the settings...
void gppat_filter_clear_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "clear all account types" button in the Filter dialog was clicked.
void gnc_tree_view_account_set_editing_started_cb(GncTreeViewAccount *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup the callback for when the user starts editing the account tree so actions can be disabled like ...
void gnc_tree_view_account_set_selected_accounts(GncTreeViewAccount *view, GList *account_list, gboolean show_last)
This function selects a set of accounts in the account tree view.
void gppat_filter_show_hidden_toggled_cb(GtkToggleButton *togglebutton, AccountFilterDialog *fd)
The "show hidden" button in the Filter dialog changed state.
void gnc_tree_view_account_set_filter(GncTreeViewAccount *account_view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
This function attaches a filter function to the given account tree.
void gnc_tree_view_account_select_subaccounts(GncTreeViewAccount *view, Account *account)
This function selects all sub-accounts of an account in the account tree view.
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
GtkTreeViewColumn * gnc_tree_view_account_add_custom_column(GncTreeViewAccount *view, const gchar *column_title, GncTreeViewAccountColumnSource source_cb, GncTreeViewAccountColumnTextEdited edited_cb)
Add a new custom column to the set of columns in an account tree view.
GtkTreeView * gnc_tree_view_account_new_with_root(Account *root, gboolean show_root)
Create a new account tree view.
GtkTreeView * gnc_tree_view_account_new(gboolean show_root)
Create a new account tree view.
gboolean gnc_plugin_page_account_tree_filter_accounts(Account *account, gpointer user_data)
This function tells the account tree view whether or not to filter out a particular account...
Functions for adding plugins to a GnuCash window.
void gnc_tree_view_account_clear_model_cache(GncTreeViewAccount *view)
This function clears the tree model account cache so the values will be updated/refreshed.
Account * gnc_tree_view_account_get_account_from_iter(GtkTreeModel *model, GtkTreeIter *iter)
This function returns the account associated with the specified iter.
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *path)
This function returns the account associated with the specified path.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
void gppat_filter_show_unused_toggled_cb(GtkToggleButton *togglebutton, AccountFilterDialog *fd)
The "show unused" button in the Filter dialog changed state.
gint gnc_tree_view_account_count_children(GncTreeViewAccount *view, Account *account)
This function determines if an account in the account tree view has any visible children.
Account * gnc_tree_view_account_get_selected_account(GncTreeViewAccount *view)
This function returns the account associated with the selected item in the account tree view...
gboolean(* gnc_tree_view_account_filter_func)(Account *account, gpointer data)
This is the description of a filter function used by the account tree.
void gppat_filter_select_default_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select default account types" button in the Filter dialog was clicked.
void gppat_filter_show_zero_toggled_cb(GtkToggleButton *togglebutton, AccountFilterDialog *fd)
The "show zero totals" button in the Filter dialog changed state.