GnuCash c935c2f+
Loading...
Searching...
No Matches
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
43G_BEGIN_DECLS
44
45/* type macros */
46#define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES (gnc_tree_model_account_types_get_type ())
47G_DECLARE_FINAL_TYPE (GncTreeModelAccountTypes, gnc_tree_model_account_types, GNC, TREE_MODEL_ACCOUNT_TYPES, GObject)
48
49typedef enum
50{
51 GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE,
52 GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME,
53 GNC_TREE_MODEL_ACCOUNT_TYPES_COL_SELECTED,
54 GNC_TREE_MODEL_ACCOUNT_TYPES_NUM_COLUMNS
55} GncTreeModelAccountTypesColumn;
56
57/* function prototypes */
58
59/* Choose one of two methods to use the GncTreeModelAccountTypes
60 objects defined here, depending on how you want to deal with
61 selection state. Method 1 is simpler and light-weight, but Method
62 2 is more flexible.
63
64 Method 1: If you just want to allow selection of a subset of all
65 account types while showing all account types, use
66 gnc_tree_model_account_types_master() to get the treemodel.
67 Connect it to your tree view and use
68 gnc_tree_model_account_types_{sg}et_selection() to convert between
69 bitmasks and GtkTreeView states. No need to free the treemodel.
70
71 Method 2: If you must store selection state in the model for some
72 reason (maybe you want to use a checkbox column to indicate
73 selection?) then you need your own instance from
74 gnc_tree_model_account_types_new(). Use
75 gnc_tree_model_account_types_{gs}et_selected() to get and set the
76 models "SELECTED" column values. You must free the model when
77 you're done with it.
78
79*/
80
81/*************** Method 1 functions ***************/
82
83/* Returns a GtkTreeModelFilter that wraps the model. Only account
84 types specified by the 'types' bitmask are visible. To force the
85 visibility of deprecated account types, pass
86 (xaccAccountTypesValid() | (1 << xaccAccountGetType(acct))).
87
88 To get the GtkTreeModel that shows all account types, including
89 deprecated account types, pass (-1).
90
91 To get the GtkTreeModel that only shows non-deprecated account types,
92 use gnc_tree_model_account_types_valid().
93
94 Caller is responsible for ref/unref. */
95GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types);
96
97/* Update the set of the visibible account types in 'f_model' to 'types'. */
98void gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model,
99 guint32 types);
100
101/* Return the current set of the visibible account types. */
102guint32 gnc_tree_model_account_types_get_mask (GtkTreeModel *f_model);
103
104/* Return the bitmask of the account type enums reflecting the state
105 of the tree selection. If your view allows the selection of
106 multiple account types, use must use this function to get the
107 selection. */
108guint32 gnc_tree_model_account_types_get_selection(GtkTreeSelection *sel);
109
110/* Gets the selected account type. Use the function if your view
111 allows the selection of only one account type. If no types are
112 selected, returns ACCT_TYPE_NONE. If more than one type is
113 selected, arbitrarily returns one of the selected types. */
115gnc_tree_model_account_types_get_selection_single(GtkTreeSelection *sel);
116
117/* Gets the selected account type. If no types are active, returns
118 ACCT_TYPE_NONE. */
120gnc_tree_model_account_types_get_active_combo (GtkComboBox *combo);
121
122/* Set the selection state of the tree selection to match the bitmask
123 of account-type enums in 'selected'. This will also scroll to a
124 selected row in the TreeView.*/
125void gnc_tree_model_account_types_set_selection(GtkTreeSelection *sel,
126 guint32 selected);
127
128/* Set the active entry to match the bitmask of account-type enums in
129 'selected' */
130void gnc_tree_model_account_types_set_active_combo (GtkComboBox *combo,
131 guint32 selected);
132
133
134/**************** Method 2 functions **************/
135
136GtkTreeModel *gnc_tree_model_account_types_new(guint32 selected);
137
138
139G_END_DECLS
140
141#endif /* __GNC_TREE_MODEL_ACCOUNT_H */
142
Account handling public routines.
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed.
Definition Account.h:103