GnuCash  5.6-150-g038405b370+
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 G_DECLARE_FINAL_TYPE (GncTreeViewAccount, gnc_tree_view_account, GNC, TREE_VIEW_ACCOUNT, GncTreeView)
48 
49 #define GNC_TREE_VIEW_ACCOUNT_NAME "GncTreeViewAccount"
50 
51 /* typedefs & structures */
52 typedef struct AccountViewInfo_s AccountViewInfo;
53 
54 
56 {
57  gboolean include_type[NUM_ACCOUNT_TYPES];
58  gboolean show_hidden;
59 };
60 
61 
62 typedef struct
63 {
64  GtkWidget *dialog;
65  GtkTreeModel *model;
66  GncTreeViewAccount *tree_view;
67  GHashTable *filter_override;
68  guint32 visible_types;
69  guint32 original_visible_types;
70  gboolean show_hidden;
71  gboolean original_show_hidden;
72  gboolean show_zero_total;
73  gboolean original_show_zero_total;
74  gboolean show_unused;
75  gboolean original_show_unused;
77 
78 void account_filter_dialog_create(AccountFilterDialog *fd,
79  GncPluginPage *page);
80 
82  gpointer user_data);
83 
84 /* "Filter By" dialog callbacks */
85 void gppat_filter_show_hidden_toggled_cb (GtkToggleButton *togglebutton,
87 void gppat_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton,
89 void gppat_filter_show_unused_toggled_cb (GtkToggleButton *togglebutton,
91 void gppat_filter_clear_all_cb (GtkWidget *button, AccountFilterDialog *fd);
92 void gppat_filter_select_all_cb (GtkWidget *button, AccountFilterDialog *fd);
93 void gppat_filter_select_default_cb (GtkWidget *button,
95 void gppat_filter_response_cb (GtkWidget *dialog, gint response,
97 
98 /* Saving/Restoring */
99 void gnc_tree_view_account_save(GncTreeViewAccount *tree_view,
101  GKeyFile *key_file, const gchar *group_name);
102 void gnc_tree_view_account_restore(GncTreeViewAccount *view,
104  GKeyFile *key_file,
105  const gchar *group_name);
106 
107 void gnc_tree_view_account_save_filter (GncTreeViewAccount *tree_view,
109  GKeyFile *key_file,
110  const gchar *group_name);
111 void gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
113  GKeyFile *key_file,
114  const gchar *group_name);
115 
116 
117 /* Get the GType for an GncTreeViewAccount object. */
118 GType gnc_tree_view_account_get_type (void);
119 
120 
136 GtkTreeView *gnc_tree_view_account_new_with_root (Account *root,
137  gboolean show_root);
138 
150 GtkTreeView *gnc_tree_view_account_new (gboolean show_root);
151 
158 typedef gchar * (*GncTreeViewAccountColumnSource) (Account *account,
159  GtkTreeViewColumn *col,
160  GtkCellRenderer *cell);
161 
162 typedef void (*GncTreeViewAccountColumnTextEdited) (Account *account,
163  GtkTreeViewColumn *col,
164  const gchar *new_text);
165 
166 
183 GtkTreeViewColumn * gnc_tree_view_account_add_custom_column(
184  GncTreeViewAccount *view, const gchar *column_title,
185  GncTreeViewAccountColumnSource source_cb,
186  GncTreeViewAccountColumnTextEdited edited_cb);
187 GtkTreeViewColumn *gnc_tree_view_account_add_custom_column_renderer(
188  GncTreeViewAccount *account_view, const gchar *column_title,
189  GncTreeViewAccountColumnSource col_source_cb,
190  GncTreeViewAccountColumnTextEdited col_edited_cb,
191  GtkCellRenderer *renderer);
192 void gnc_tree_view_account_set_name_edited(GncTreeViewAccount *view,
193  GncTreeViewAccountColumnTextEdited edited_cb);
194 void gnc_tree_view_account_name_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_name);
195 
196 void gnc_tree_view_account_set_code_edited(GncTreeViewAccount *view,
197  GncTreeViewAccountColumnTextEdited edited_cb);
198 void gnc_tree_view_account_code_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_code);
199 
200 void gnc_tree_view_account_set_description_edited(GncTreeViewAccount *view,
201  GncTreeViewAccountColumnTextEdited edited_cb);
202 void gnc_tree_view_account_description_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_desc);
203 
204 void gnc_tree_view_account_set_notes_edited(GncTreeViewAccount *view,
205  GncTreeViewAccountColumnTextEdited edited_cb);
206 void gnc_tree_view_account_notes_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_notes);
207 
219 GtkTreeViewColumn *
220 gnc_tree_view_account_add_property_column (GncTreeViewAccount *view,
221  const gchar *column_title,
222  const gchar *propname);
223 
240 void gnc_tree_view_account_get_view_info (GncTreeViewAccount *account_view,
241  AccountViewInfo *avi);
242 
254 void gnc_tree_view_account_set_view_info (GncTreeViewAccount *account_view,
255  AccountViewInfo *avi);
256 
257 
266 typedef gboolean (*gnc_tree_view_account_filter_func)(Account *account, gpointer data);
267 
268 
288 void gnc_tree_view_account_set_filter (GncTreeViewAccount *account_view,
290  gpointer data,
291  GSourceFunc destroy);
292 
293 /* This is a convenient filter function for use with
294  * gnc_tree_view_account_set_filter() and the functions in
295  * gnc-tree-model-account-types.h. If you have some view that is
296  * backed by the "account types" tree model, you can get a guint32
297  * from that view's tree selection. Then, you can use that account
298  * type selection as a filter for the account tree view. This also
299  * can filter by whether an account is hidden or not.
300  */
301 gboolean gnc_tree_view_account_filter_by_view_info(
302  Account* acct, gpointer data);
303 
304 
315 void gnc_tree_view_account_refilter (GncTreeViewAccount *view);
332 gint gnc_tree_view_account_count_children (GncTreeViewAccount *view,
333  Account *account);
334 
341 void gnc_tree_view_account_clear_model_cache (GncTreeViewAccount *view);
342 
343 
354 Account * gnc_tree_view_account_get_account_from_path (GncTreeViewAccount *view,
355  GtkTreePath *path);
356 
357 
369  GtkTreeIter *iter);
370 
371 
380 Account * gnc_tree_view_account_get_cursor_account (GncTreeViewAccount *view);
381 
382 
394 Account * gnc_tree_view_account_get_selected_account (GncTreeViewAccount *view);
395 
396 
412 void gnc_tree_view_account_set_selected_account (GncTreeViewAccount *view,
413  Account *account);
414 
415 
427 GList * gnc_tree_view_account_get_selected_accounts (GncTreeViewAccount *view);
428 
429 
451 void gnc_tree_view_account_set_selected_accounts (GncTreeViewAccount *view,
452  GList *account_list,
453  gboolean show_last);
454 
455 
468 void gnc_tree_view_account_select_subaccounts (GncTreeViewAccount *view,
469  Account *account);
470 
478 void gnc_tree_view_account_expand_to_account (GncTreeViewAccount *view, Account *account);
479 
483 void gnc_tree_view_account_column_add_color (GncTreeViewAccount *view, GtkTreeViewColumn *col);
484 
489  (GncTreeViewAccount *view, GFunc editing_started_cb, gpointer editing_cb_data );
490 
495  (GncTreeViewAccount *view, GFunc editing_finished_cb, gpointer editing_cb_data );
496 
497 
503 G_END_DECLS
504 
505 #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.
STRUCTS.
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:161
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.