GnuCash  4.12-75-g66025ae738+
gnc-tree-model-account-types.h
Go to the documentation of this file.
1 /*
2  * gnc-tree-model-account-types.h -- GtkTreeModel implementation
3  * to display account types in a GtkTreeView.
4  *
5  * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de>
6  * Copyright (C) 2005, 2006 Chris Shoemaker <c.shoemaker@cox.net>
7  * Copyright (C) 2006 Eskil Bylund <eskil.bylund@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, contact:
21  *
22  * Free Software Foundation Voice: +1-617-542-5942
23  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
24  * Boston, MA 02110-1301, USA gnu@gnu.org
25  */
38 #ifndef __GNC_TREE_MODEL_ACCOUNT_TYPES_H
39 #define __GNC_TREE_MODEL_ACCOUNT_TYPES_H
40 
41 #include "Account.h"
42 
43 G_BEGIN_DECLS
44 
45 /* type macros */
46 #define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES (gnc_tree_model_account_types_get_type ())
47 #define GNC_TREE_MODEL_ACCOUNT_TYPES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypes))
48 #define GNC_TREE_MODEL_ACCOUNT_TYPES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
49 #define GNC_IS_TREE_MODEL_ACCOUNT_TYPES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
50 #define GNC_IS_TREE_MODEL_ACCOUNT_TYPES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
51 #define GNC_TREE_MODEL_ACCOUNT_TYPES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
52 
53 typedef enum
54 {
55  GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE,
56  GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME,
57  GNC_TREE_MODEL_ACCOUNT_TYPES_COL_SELECTED,
58  GNC_TREE_MODEL_ACCOUNT_TYPES_NUM_COLUMNS
59 } GncTreeModelAccountTypesColumn;
60 
61 /* typedefs & structures */
62 typedef struct
63 {
64  GObject gobject;
65  int stamp;
67 
68 typedef struct
69 {
70  GObjectClass gobject;
72 
73 /* function prototypes */
74 GType gnc_tree_model_account_types_get_type (void);
75 
76 /* Choose one of two methods to use the GncTreeModelAccountTypes
77  objects defined here, depending on how you want to deal with
78  selection state. Method 1 is simpler and light-weight, but Method
79  2 is more flexible.
80 
81  Method 1: If you just want to allow selection of a subset of all
82  account types while showing all account types, use
83  gnc_tree_model_account_types_master() to get the treemodel.
84  Connect it to your tree view and use
85  gnc_tree_model_account_types_{sg}et_selection() to convert between
86  bitmasks and GtkTreeView states. No need to free the treemodel.
87 
88  Method 2: If you must store selection state in the model for some
89  reason (maybe you want to use a checkbox column to indicate
90  selection?) then you need your own instance from
91  gnc_tree_model_account_types_new(). Use
92  gnc_tree_model_account_types_{gs}et_selected() to get and set the
93  models "SELECTED" column values. You must free the model when
94  you're done with it.
95 
96 */
97 
98 /*************** Method 1 functions ***************/
99 
100 /* Returns a GtkTreeModelFilter that wraps the model. Only account
101  types specified by the 'types' bitmask are visible. To force the
102  visibility of deprecated account types, pass
103  (xaccAccountTypesValid() | (1 << xaccAccountGetType(acct))).
104 
105  To get the GtkTreeModel that shows all account types, including
106  deprecated account types, pass (-1).
107 
108  To get the GtkTreeModel that only shows non-deprecated account types,
109  use gnc_tree_model_account_types_valid().
110 
111  Caller is responsible for ref/unref. */
112 GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types);
113 
114 /* Update the set of the visibible account types in 'f_model' to 'types'. */
115 void gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model,
116  guint32 types);
117 
118 /* Return the current set of the visibible account types. */
119 guint32 gnc_tree_model_account_types_get_mask (GtkTreeModel *f_model);
120 
121 /* Return the bitmask of the account type enums reflecting the state
122  of the tree selection. If your view allows the selection of
123  multiple account types, use must use this function to get the
124  selection. */
125 guint32 gnc_tree_model_account_types_get_selection(GtkTreeSelection *sel);
126 
127 /* Gets the selected account type. Use the function if your view
128  allows the selection of only one account type. If no types are
129  selected, returns ACCT_TYPE_NONE. If more than one type is
130  selected, arbitrarily returns one of the selected types. */
132 gnc_tree_model_account_types_get_selection_single(GtkTreeSelection *sel);
133 
134 /* Set the selection state of the tree selection to match the bitmask
135  of account-type enums in 'selected'. This will also scroll to a
136  selected row in the TreeView.*/
137 void gnc_tree_model_account_types_set_selection(GtkTreeSelection *sel,
138  guint32 selected);
139 
140 
141 /**************** Method 2 functions **************/
142 
143 GtkTreeModel *gnc_tree_model_account_types_new(guint32 selected);
144 
145 
146 G_END_DECLS
147 
148 #endif /* __GNC_TREE_MODEL_ACCOUNT_H */
149 
Account handling public routines.
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:105