1 /** 2 * gnc-account-sel.h -- combobox style account selection widget. 3 * 4 * Note that this widget will track changes in the account tree, and update 5 * itself accordingly. If an account with the same name exists in the 6 * freshly-retrieved account list, the widget will re-select that account. 7 * 8 * Copyright (C) 2002 Joshua Sled <jsled@asynchronous.org> 9 * Copyright (c) 2006 David Hampton <hampton@employees.org> 10 * All rights reserved. 11 **/ 12 13 /* GnuCash is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU Library General Public License as 15 * published by the Free Software Foundation; either version 2 of 16 * the License, or (at your option) any later version. 17 * 18 * Gnucash is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Library General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, contact: 25 * 26 * Free Software Foundation Voice: +1-617-542-5942 27 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 28 * Boston, MA 02110-1301, USA gnu@gnu.org 29 */ 30 31 #ifndef GNC_ACCOUNT_SEL_H 32 #define GNC_ACCOUNT_SEL_H 33 34 #include "Account.h" 35 36 #define GNC_TYPE_ACCOUNT_SEL (gnc_account_sel_get_type()) 37 #define GNC_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, GNC_TYPE_ACCOUNT_SEL, GNCAccountSel) 38 #define GNC_ACCOUNT_SEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, GNC_TYPE_ACCOUNT_SEL, GNCAccountSelClass) 39 #define GNC_IS_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GNC_TYPE_ACCOUNT_SEL) 40 41 typedef struct 42 { 43 GtkBox hbox; 44 gboolean initDone; 45 gboolean isModal; 46 GtkListStore *store; 47 GtkComboBox *combo; 48 GList *acctTypeFilters; 49 GList *acctCommodityFilters; 50 gint eventHandlerId; 51 /* The state of this pointer also serves as a flag about what state 52 * the widget is in WRT the new-account-button ability. */ 53 GtkWidget *newAccountButton; 54 gint currentSelection; 55 56 #if 0 /* completion not implemented. */ 57 GCompletion *completion; 58 #endif /* 0 - completion not implemented */ 59 } GNCAccountSel; 60 61 typedef struct 62 { 63 GtkBoxClass parent_class; 64 65 /* Signals for notification/filtering of changes */ 66 void (*account_sel_changed) (GNCAccountSel *gas); 67 } GNCAccountSelClass; 68 69 GType gnc_account_sel_get_type (void); 70 GtkWidget* gnc_account_sel_new (void); 71 72 /** 73 * Sets the GAS to the given account. If the account doesn't exist in the 74 * list, then it doesn't change the state of the GAS. If the account is 75 * NULL, then the first list selection is made if set_default_acct is TRUE. 76 **/ 77 void gnc_account_sel_set_account (GNCAccountSel *gas, Account *acct, 78 gboolean set_default_acct); 79 /** 80 * Returns the currently-selected Account. If, for some reason the selection 81 * is in a bad state, NULL will be returned. 82 **/ 83 Account* gnc_account_sel_get_account (GNCAccountSel *gas); 84 85 /** 86 * The GNCAccountSel can be setup to filter the accounts displayed. 87 * @param typeFilters A GList of GNCAccountType identifiers which are allowed. 88 * @param commodityFilters A GList of gnc_commodity types which are allowed. 89 * The list is copied, of course. 90 **/ 91 void gnc_account_sel_set_acct_filters (GNCAccountSel *gas, GList *typeFilters, 92 GList *commodityFilters); 93 94 /** 95 * Conditional inclusion of a new-account button to the right of the 96 * combobox. 97 * @param state TRUE if the new-account button is desired, FALSE otherwise. 98 **/ 99 void gnc_account_sel_set_new_account_ability (GNCAccountSel *gas, gboolean state); 100 101 /** 102 * Conditional call of the new-account window in modal mode. 103 * @param state TRUE if the new-account window should be modal, FALSE otherwise. 104 **/ 105 void gnc_account_sel_set_new_account_modal (GNCAccountSel *gas, gboolean state); 106 107 gint gnc_account_sel_get_num_account (GNCAccountSel *gas); 108 void gnc_account_sel_purge_account (GNCAccountSel *gas, Account *acc, gboolean recursive); 109 void gnc_account_sel_set_hexpand (GNCAccountSel *gas, gboolean expand); 110 111 #endif /* GNC_ACCOUNT_SEL_H */ 112