GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Enumerations | Functions | Variables
GnuCash Tree Model

Files

 
 
file  gnc-tree-model-commodity.h
 GtkTreeModel implementation for gnucash commodities.
 
file  gnc-tree-model-owner.h
 GtkTreeModel implementation for gnucash owner tree.
 
file  gnc-tree-model-price.h
 GtkTreeModel implementation for gnucash price database.
 
file  gnc-tree-model.h
 GtkTreeModel implementation for a generic gnucash tree.
 
 
file  gnc-tree-view-commodity.h
 GtkTreeView implementation for gnucash commodity tree.
 
file  gnc-tree-view-owner.h
 GtkTreeView implementation for gnucash owner tree.
 
file  gnc-tree-view-price.h
 GtkTreeView implementation for gnucash price tree.
 

Data Structures

struct  _GncTreeModelClass
 The class data structure for a generic tree model. More...
 
struct  AccountViewInfo
 
struct  AccountFilterDialog
 
struct  OwnerViewInfo
 
struct  OwnerFilterDialog
 

Macros

#define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES   (gnc_tree_model_account_types_get_type ())
 
#define GNC_TYPE_TREE_MODEL_ACCOUNT   (gnc_tree_model_account_get_type ())
 
#define GNC_TREE_MODEL_ACCOUNT_NAME   "GncTreeModelAccount"
 
#define GNC_TYPE_TREE_MODEL_COMMODITY   (gnc_tree_model_commodity_get_type ())
 
#define GNC_TREE_MODEL_COMMODITY_NAME   "GncTreeModelCommodity"
 
#define GNC_TYPE_TREE_MODEL_OWNER   (gnc_tree_model_owner_get_type ())
 
#define GNC_TREE_MODEL_OWNER_NAME   "GncTreeModelOwner"
 
#define GNC_TYPE_TREE_MODEL_PRICE   (gnc_tree_model_price_get_type ())
 
#define GNC_TREE_MODEL_PRICE_NAME   "GncTreeModelPrice"
 
#define GNC_TYPE_TREE_MODEL   (gnc_tree_model_get_type ())
 
#define GNC_TREE_MODEL_NAME   "GncTreeModel"
 
#define GNC_TYPE_TREE_VIEW_ACCOUNT   (gnc_tree_view_account_get_type ())
 
#define GNC_TREE_VIEW_ACCOUNT_NAME   "GncTreeViewAccount"
 
#define GNC_TYPE_TREE_VIEW_COMMODITY   (gnc_tree_view_commodity_get_type ())
 
#define GNC_TYPE_TREE_VIEW_OWNER   (gnc_tree_view_owner_get_type ())
 
#define GNC_TREE_VIEW_OWNER_NAME   "GncTreeViewOwner"
 
#define GNC_OWNER_TREE_NAME_COL   "name"
 
#define GNC_OWNER_TREE_TYPE_COL   "type"
 
#define GNC_OWNER_TREE_ID_COL   "owner-id"
 
#define GNC_OWNER_TREE_CURRENCY_COL   "currency"
 
#define GNC_OWNER_TREE_ADDRESS_NAME_COL   "address-name"
 
#define GNC_OWNER_TREE_ADDRESS_1_COL   "address-1"
 
#define GNC_OWNER_TREE_ADDRESS_2_COL   "address-2"
 
#define GNC_OWNER_TREE_ADDRESS_3_COL   "address-3"
 
#define GNC_OWNER_TREE_ADDRESS_4_COL   "address-4"
 
#define GNC_OWNER_TREE_PHONE_COL   "phone"
 
#define GNC_OWNER_TREE_FAX_COL   "fax"
 
#define GNC_OWNER_TREE_EMAIL_COL   "email"
 
#define GNC_OWNER_TREE_BALANCE_COL   "balance"
 
#define GNC_OWNER_TREE_BALANCE_REPORT_COL   "balance-report"
 
#define GNC_OWNER_TREE_BALANCE_PERIOD_COL   "balance-period"
 
#define GNC_OWNER_TREE_NOTES_COL   "notes"
 
#define GNC_OWNER_TREE_ACTIVE_COL   "active"
 
#define GNC_TYPE_TREE_VIEW_PRICE   (gnc_tree_view_price_get_type ())
 

Enumerations

enum  GncTreeModelAccountTypesColumn { GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE , GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME , GNC_TREE_MODEL_ACCOUNT_TYPES_COL_SELECTED , GNC_TREE_MODEL_ACCOUNT_TYPES_NUM_COLUMNS }
 
enum  GncTreeModelAccountColumn {
  GNC_TREE_MODEL_ACCOUNT_COL_NAME , GNC_TREE_MODEL_ACCOUNT_COL_TYPE , GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY , GNC_TREE_MODEL_ACCOUNT_COL_CODE ,
  GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION , GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM , GNC_TREE_MODEL_ACCOUNT_COL_PRESENT , GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT ,
  GNC_TREE_MODEL_ACCOUNT_COL_BALANCE , GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT , GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD , GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT ,
  GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT_EXPLANATION , GNC_TREE_MODEL_ACCOUNT_COL_CLEARED , GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT , GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED ,
  GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT , GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE , GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE , GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN ,
  GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT , GNC_TREE_MODEL_ACCOUNT_COL_TOTAL , GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT , GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD ,
  GNC_TREE_MODEL_ACCOUNT_COL_NOTES , GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO , GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT , GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN ,
  GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER , GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE , GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT ,
  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED ,
  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL , GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD ,
  GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS
}
 
enum  GncTreeModelCommodityColumn {
  GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE , GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC , GNC_TREE_MODEL_COMMODITY_COL_USER_SYMBOL , GNC_TREE_MODEL_COMMODITY_COL_FULLNAME ,
  GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME , GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME , GNC_TREE_MODEL_COMMODITY_COL_CUSIP , GNC_TREE_MODEL_COMMODITY_COL_FRACTION ,
  GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG , GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE , GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ , GNC_TREE_MODEL_COMMODITY_COL_LAST_VISIBLE = GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ ,
  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY , GNC_TREE_MODEL_COMMODITY_NUM_COLUMNS
}
 
enum  GncTreeModelOwnerColumn {
  GNC_TREE_MODEL_OWNER_COL_NAME , GNC_TREE_MODEL_OWNER_COL_TYPE , GNC_TREE_MODEL_OWNER_COL_ID , GNC_TREE_MODEL_OWNER_COL_CURRENCY ,
  GNC_TREE_MODEL_OWNER_COL_ADDRESS_NAME , GNC_TREE_MODEL_OWNER_COL_ADDRESS_1 , GNC_TREE_MODEL_OWNER_COL_ADDRESS_2 , GNC_TREE_MODEL_OWNER_COL_ADDRESS_3 ,
  GNC_TREE_MODEL_OWNER_COL_ADDRESS_4 , GNC_TREE_MODEL_OWNER_COL_PHONE , GNC_TREE_MODEL_OWNER_COL_FAX , GNC_TREE_MODEL_OWNER_COL_EMAIL ,
  GNC_TREE_MODEL_OWNER_COL_BALANCE , GNC_TREE_MODEL_OWNER_COL_BALANCE_REPORT , GNC_TREE_MODEL_OWNER_COL_NOTES , GNC_TREE_MODEL_OWNER_COL_ACTIVE ,
  GNC_TREE_MODEL_OWNER_COL_LAST_VISIBLE = GNC_TREE_MODEL_OWNER_COL_ACTIVE , GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE , GNC_TREE_MODEL_OWNER_NUM_COLUMNS
}
 
enum  GncTreeModelPriceColumn {
  GNC_TREE_MODEL_PRICE_COL_COMMODITY , GNC_TREE_MODEL_PRICE_COL_CURRENCY , GNC_TREE_MODEL_PRICE_COL_DATE , GNC_TREE_MODEL_PRICE_COL_SOURCE ,
  GNC_TREE_MODEL_PRICE_COL_TYPE , GNC_TREE_MODEL_PRICE_COL_VALUE , GNC_TREE_MODEL_PRICE_COL_LAST_VISIBLE = GNC_TREE_MODEL_PRICE_COL_VALUE , GNC_TREE_MODEL_PRICE_COL_VISIBILITY ,
  GNC_TREE_MODEL_PRICE_NUM_COLUMNS
}
 

Functions

GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types)
 
void gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model, guint32 types)
 
guint32 gnc_tree_model_account_types_get_mask (GtkTreeModel *f_model)
 
guint32 gnc_tree_model_account_types_get_selection (GtkTreeSelection *sel)
 
GNCAccountType gnc_tree_model_account_types_get_selection_single (GtkTreeSelection *sel)
 
GNCAccountType gnc_tree_model_account_types_get_active_combo (GtkComboBox *combo)
 
void gnc_tree_model_account_types_set_selection (GtkTreeSelection *sel, guint32 selected)
 
void gnc_tree_model_account_types_set_active_combo (GtkComboBox *combo, guint32 selected)
 
GtkTreeModel * gnc_tree_model_account_types_new (guint32 selected)
 
void gnc_tree_model_account_clear_cache (GncTreeModelAccount *model)
 Clear the tree model account cached values.
 
void account_filter_dialog_create (AccountFilterDialog *fd, GncPluginPage *page)
 
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.
 
void gppat_filter_show_hidden_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show hidden" button in the Filter dialog changed state.
 
void gppat_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show zero totals" button in the Filter dialog changed state.
 
void gppat_filter_show_unused_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show unused" button in the Filter dialog changed state.
 
void gppat_filter_clear_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 The "clear all account types" button in the Filter dialog was clicked.
 
void gppat_filter_select_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 The "select all account types" button in the Filter dialog was clicked.
 
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_response_cb (GtkWidget *dialog, gint response, AccountFilterDialog *fd)
 The Filter dialog was closed.
 
void gnc_tree_view_account_save (GncTreeViewAccount *tree_view, AccountFilterDialog *fd, GKeyFile *key_file, const gchar *group_name)
 
void gnc_tree_view_account_restore (GncTreeViewAccount *view, AccountFilterDialog *fd, GKeyFile *key_file, const gchar *group_name)
 
void gnc_tree_view_account_save_filter (GncTreeViewAccount *tree_view, AccountFilterDialog *fd, GKeyFile *key_file, const gchar *group_name)
 
void gnc_tree_view_account_restore_filter (GncTreeViewAccount *view, AccountFilterDialog *fd, GKeyFile *key_file, const gchar *group_name)
 
GType gnc_tree_view_account_get_type (void)
 
void owner_filter_dialog_create (OwnerFilterDialog *fd, GncPluginPage *page)
 
gboolean gnc_plugin_page_owner_tree_filter_owners (GncOwner *owner, gpointer user_data)
 This function tells the owner tree view whether or not to filter out a particular owner.
 
void gppot_filter_show_inactive_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 The "only show active" button in the Filter dialog changed state.
 
void gppot_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 The "show zero totals" button in the Filter dialog changed state.
 
void gppot_filter_response_cb (GtkWidget *dialog, gint response, OwnerFilterDialog *fd)
 The Filter dialog was closed.
 
void gnc_tree_view_owner_save (GncTreeViewOwner *tree_view, OwnerFilterDialog *fd, GKeyFile *key_file, const gchar *group_name)
 
void gnc_tree_view_owner_restore (GncTreeViewOwner *view, OwnerFilterDialog *fd, GKeyFile *key_file, const gchar *group_name, GncOwnerType owner_type)
 

Variables

gboolean OwnerViewInfo::show_inactive
 
GtkWidget * OwnerFilterDialog::dialog
 
GncTreeViewOwner * OwnerFilterDialog::tree_view
 
gboolean OwnerFilterDialog::show_inactive
 
gboolean OwnerFilterDialog::original_show_inactive
 
gboolean OwnerFilterDialog::show_zero_total
 
gboolean OwnerFilterDialog::original_show_zero_total
 

Account Tree View Configuration

typedef gchar *(* GncTreeViewAccountColumnSource) (Account *account, GtkTreeViewColumn *col, GtkCellRenderer *cell)
 
typedef void(* GncTreeViewAccountColumnTextEdited) (Account *account, GtkTreeViewColumn *col, const gchar *new_text)
 
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.
 
GtkTreeViewColumn * gnc_tree_view_account_add_custom_column_renderer (GncTreeViewAccount *account_view, const gchar *column_title, GncTreeViewAccountColumnSource col_source_cb, GncTreeViewAccountColumnTextEdited col_edited_cb, GtkCellRenderer *renderer)
 
void gnc_tree_view_account_set_name_edited (GncTreeViewAccount *view, GncTreeViewAccountColumnTextEdited edited_cb)
 
void gnc_tree_view_account_name_edited_cb (Account *account, GtkTreeViewColumn *col, const gchar *new_name)
 
void gnc_tree_view_account_set_code_edited (GncTreeViewAccount *view, GncTreeViewAccountColumnTextEdited edited_cb)
 
void gnc_tree_view_account_code_edited_cb (Account *account, GtkTreeViewColumn *col, const gchar *new_code)
 
void gnc_tree_view_account_set_description_edited (GncTreeViewAccount *view, GncTreeViewAccountColumnTextEdited edited_cb)
 
void gnc_tree_view_account_description_edited_cb (Account *account, GtkTreeViewColumn *col, const gchar *new_desc)
 
void gnc_tree_view_account_set_notes_edited (GncTreeViewAccount *view, GncTreeViewAccountColumnTextEdited edited_cb)
 
void gnc_tree_view_account_notes_edited_cb (Account *account, GtkTreeViewColumn *col, const gchar *new_notes)
 
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.
 

Account Tree View Filtering

typedef 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 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 configuration of the account tree widget into the data block.
 
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 specified to the current configuration of the account tree widget.
 
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.
 
gboolean gnc_tree_view_account_filter_by_view_info (Account *acct, gpointer data)
 
void gnc_tree_view_account_refilter (GncTreeViewAccount *view)
 This function forces the account tree filter to be evaluated.
 

Commodity Tree View Filtering

typedef gboolean(* gnc_tree_view_commodity_ns_filter_func) (gnc_commodity_namespace *, gpointer data)
 
typedef gboolean(* gnc_tree_view_commodity_cm_filter_func) (gnc_commodity *, gpointer data)
 
void gnc_tree_view_commodity_set_filter (GncTreeViewCommodity *view, gnc_tree_view_commodity_ns_filter_func ns_func, gnc_tree_view_commodity_cm_filter_func cm_func, gpointer data, GDestroyNotify destroy)
 This function attaches a filter function to the given commodity tree.
 
void gnc_tree_view_commodity_refilter (GncTreeViewCommodity *view)
 This function forces the commodity tree filter to be evaluated.
 

Owner Tree View Configuration

typedef gchar *(* GncTreeViewOwnerColumnSource) (GncOwner *owner, GtkTreeViewColumn *col, GtkCellRenderer *cell)
 
typedef void(* GncTreeViewOwnerColumnTextEdited) (GncOwner *owner, GtkTreeViewColumn *col, const gchar *new_text)
 

Owner Tree View Filtering

typedef gboolean(* gnc_tree_view_owner_filter_func) (GncOwner *owner, gpointer data)
 This is the description of a filter function used by the owner tree.
 
void gnc_tree_view_owner_set_filter (GncTreeViewOwner *owner_view, gnc_tree_view_owner_filter_func func, gpointer data, GSourceFunc destroy)
 This function attaches a filter function to the given owner tree.
 
void gnc_tree_view_owner_refilter (GncTreeViewOwner *view)
 This function forces the owner tree filter to be evaluated.
 

Price Tree View Filtering

typedef gboolean(* gnc_tree_view_price_ns_filter_func) (gnc_commodity_namespace *, gpointer data)
 This function attaches a filter function to the given price tree.
 
typedef gboolean(* gnc_tree_view_price_cm_filter_func) (gnc_commodity *, gpointer data)
 
typedef gboolean(* gnc_tree_view_price_pc_filter_func) (GNCPrice *, gpointer data)
 
void gnc_tree_view_price_set_filter (GncTreeViewPrice *view, gnc_tree_view_price_ns_filter_func ns_func, gnc_tree_view_price_cm_filter_func cm_func, gnc_tree_view_price_pc_filter_func pc_func, gpointer data, GDestroyNotify destroy)
 

Account Tree Model Constructors

GtkTreeModel * gnc_tree_model_account_new (Account *root)
 Create a new GtkTreeModel for manipulating gnucash accounts.
 

Account Tree Model Get/Set Functions

Accountgnc_tree_model_account_get_account (GncTreeModelAccount *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash account.
 
gboolean gnc_tree_model_account_get_iter_from_account (GncTreeModelAccount *model, Account *account, GtkTreeIter *iter)
 Convert a model/account pair into a gtk_tree_model_iter.
 
GtkTreePath * gnc_tree_model_account_get_path_from_account (GncTreeModelAccount *model, Account *account)
 Convert a model/account pair into a gtk_tree_model_path.
 

Account Tree Model Constructors

GtkTreeModel * gnc_tree_model_commodity_new (QofBook *book, gnc_commodity_table *ct)
 Create a new GtkTreeModel for manipulating gnucash commodities.
 

Commodity Tree Model Filter Helper Functions

gboolean gnc_tree_model_commodity_iter_is_namespace (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a commodity namespace.
 
gboolean gnc_tree_model_commodity_iter_is_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a commodity.
 
gnc_commodity_namespace * gnc_tree_model_commodity_get_namespace (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity namespace.
 
gnc_commodity * gnc_tree_model_commodity_get_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity.
 

Commodity Tree Model Lookup Functions

gboolean gnc_tree_model_commodity_get_iter_from_namespace (GncTreeModelCommodity *model, gnc_commodity_namespace *name_space, GtkTreeIter *iter)
 Convert a commodity namespace pointer into a GtkTreeIter.
 
gboolean gnc_tree_model_commodity_get_iter_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity, GtkTreeIter *iter)
 Convert a commodity pointer into a GtkTreeIter.
 
GtkTreePath * gnc_tree_model_commodity_get_path_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity)
 Convert a commodity pointer into a GtkTreePath.
 

Owner Tree Model Constructors

GtkTreeModel * gnc_tree_model_owner_new (GncOwnerType owner_type)
 Create a new GtkTreeModel for manipulating gnucash owners.
 

Owner Tree Model Get/Set Functions

GncOwnergnc_tree_model_owner_get_owner (GncTreeModelOwner *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash owner.
 
gboolean gnc_tree_model_owner_get_iter_from_owner (GncTreeModelOwner *model, GncOwner *owner, GtkTreeIter *iter)
 Convert a model/owner pair into a gtk_tree_model_iter.
 
GtkTreePath * gnc_tree_model_owner_get_path_from_owner (GncTreeModelOwner *model, GncOwner *owner)
 Convert a model/owner pair into a gtk_tree_model_path.
 

Account Tree Model Constructors

GtkTreeModel * gnc_tree_model_price_new (QofBook *book, GNCPriceDB *price_db)
 Create a new GtkTreeModel for manipulating gnucash commodity prices.
 

Price Tree Model Filter Helper Functions

gboolean gnc_tree_model_price_iter_is_namespace (GncTreeModelPrice *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a "commodity namespace".
 
gboolean gnc_tree_model_price_iter_is_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a commodity.
 
gboolean gnc_tree_model_price_iter_is_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a price.
 
gnc_commodity_namespace * gnc_tree_model_price_get_namespace (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity namespace.
 
gnc_commodity * gnc_tree_model_price_get_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity.
 
GNCPrice * gnc_tree_model_price_get_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash price.
 

Commodity Tree Model Lookup Functions

gboolean gnc_tree_model_price_get_iter_from_namespace (GncTreeModelPrice *model, gnc_commodity_namespace *name_space, GtkTreeIter *iter)
 Convert a commodity namespace pointer into a GtkTreeIter.
 
gboolean gnc_tree_model_price_get_iter_from_commodity (GncTreeModelPrice *model, gnc_commodity *commodity, GtkTreeIter *iter)
 Convert a commodity pointer into a GtkTreeIter.
 
gboolean gnc_tree_model_price_get_iter_from_price (GncTreeModelPrice *model, GNCPrice *price, GtkTreeIter *iter)
 Convert a price pointer into a GtkTreeIter.
 
GtkTreePath * gnc_tree_model_price_get_path_from_price (GncTreeModelPrice *model, GNCPrice *price)
 Convert a price pointer into a GtkTreePath.
 

Account Tree View Constructors

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.
 

Account Tree View Get/Set Functions

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.
 
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.
 
Accountgnc_tree_view_account_get_account_from_path (GncTreeViewAccount *view, GtkTreePath *path)
 This function returns the account associated with the specified path.
 
Accountgnc_tree_view_account_get_account_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 This function returns the account associated with the specified iter.
 
Accountgnc_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.
 
Accountgnc_tree_view_account_get_selected_account (GncTreeViewAccount *view)
 This function returns the account associated with the selected item in the account tree view.
 
void gnc_tree_view_account_set_selected_account (GncTreeViewAccount *view, Account *account)
 This function selects an account in the account tree view.
 
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 view.
 
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 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_expand_to_account (GncTreeViewAccount *view, Account *account)
 This function forces the account tree expand whatever levels are necessary to make the specified account visible.
 
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 column background in the account color.
 
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 the delete menu option as required.
 
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 the delete menu option as required.
 

Commodity Tree View Constructors

GtkTreeView * gnc_tree_view_commodity_new (QofBook *book, const gchar *first_property_name,...)
 Create a new commodity tree view.
 

Commodity Tree View Configuration

void gnc_tree_view_commodity_configure_columns (GncTreeViewCommodity *view, GSList *column_names)
 Configure (by name) the set of visible columns in an commodity tree view.
 

Commodity Tree View Get/Set Functions

gnc_commodity * gnc_tree_view_commodity_get_cursor_commodity (GncTreeViewCommodity *view)
 This function returns the commodity in the commodity tree view at the current location of the cursor.
 
gnc_commodity * gnc_tree_view_commodity_get_selected_commodity (GncTreeViewCommodity *view)
 This function returns the commodity associated with the selected item in the commodity tree view.
 
gnc_commodity_namespace * gnc_tree_view_commodity_get_selected_namespace (GncTreeViewCommodity *view)
 This function returns the namespace associated with the selected item in the commodity tree view.
 
void gnc_tree_view_commodity_select_commodity (GncTreeViewCommodity *view, gnc_commodity *commodity)
 Select the commodity in the associated commodity tree view.
 
void gnc_tree_view_commodity_select_subcommodities (GncTreeViewCommodity *view, gnc_commodity *commodity)
 This function selects all sub-commodities of an commodity in the commodity tree view.
 

Owner Tree View Constructor

GtkTreeView * gnc_tree_view_owner_new (GncOwnerType owner_type)
 Create a new owner tree view for one type of owners.
 

Owner Tree View Get/Set Functions

GncOwnergnc_tree_view_owner_get_owner_from_path (GncTreeViewOwner *view, GtkTreePath *path)
 This function returns the owner associated with the specified path.
 
GncOwnergnc_tree_view_owner_get_owner_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 This function returns the owner associated with the specified iter.
 
GncOwnergnc_tree_view_owner_get_selected_owner (GncTreeViewOwner *view)
 This function returns the owner associated with the selected item in the owner tree view.
 
void gnc_tree_view_owner_set_selected_owner (GncTreeViewOwner *view, GncOwner *owner)
 This function selects an owner in the owner tree view.
 

Price Tree View Constructors

GtkTreeView * gnc_tree_view_price_new (QofBook *book, const gchar *first_property_name,...)
 Create a new price tree view.
 

Price Tree View Get/Set Functions

GNCPrice * gnc_tree_view_price_get_cursor_price (GncTreeViewPrice *view)
 This function returns the price in the price tree view at the current location of the cursor.
 
GNCPrice * gnc_tree_view_price_get_selected_price (GncTreeViewPrice *view)
 This function returns the price associated with the selected item in the price tree view.
 
void gnc_tree_view_price_set_selected_price (GncTreeViewPrice *view, GNCPrice *price)
 This function selects an price in the price tree view.
 
GList * gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view)
 This function returns a list of the prices associated with the selected items in the price tree view.
 
GList * gnc_tree_view_price_get_selected_commodities (GncTreeViewPrice *view)
 This function returns a list of commodities associated with the selected rows that are not prices but are the parent rows for prices in the price tree view.
 

Detailed Description

Macro Definition Documentation

◆ GNC_OWNER_TREE_ACTIVE_COL

#define GNC_OWNER_TREE_ACTIVE_COL   "active"

Definition at line 88 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ADDRESS_1_COL

#define GNC_OWNER_TREE_ADDRESS_1_COL   "address-1"

Definition at line 77 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ADDRESS_2_COL

#define GNC_OWNER_TREE_ADDRESS_2_COL   "address-2"

Definition at line 78 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ADDRESS_3_COL

#define GNC_OWNER_TREE_ADDRESS_3_COL   "address-3"

Definition at line 79 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ADDRESS_4_COL

#define GNC_OWNER_TREE_ADDRESS_4_COL   "address-4"

Definition at line 80 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ADDRESS_NAME_COL

#define GNC_OWNER_TREE_ADDRESS_NAME_COL   "address-name"

Definition at line 76 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_BALANCE_COL

#define GNC_OWNER_TREE_BALANCE_COL   "balance"

Definition at line 84 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_BALANCE_PERIOD_COL

#define GNC_OWNER_TREE_BALANCE_PERIOD_COL   "balance-period"

Definition at line 86 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_BALANCE_REPORT_COL

#define GNC_OWNER_TREE_BALANCE_REPORT_COL   "balance-report"

Definition at line 85 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_CURRENCY_COL

#define GNC_OWNER_TREE_CURRENCY_COL   "currency"

Definition at line 75 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_EMAIL_COL

#define GNC_OWNER_TREE_EMAIL_COL   "email"

Definition at line 83 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_FAX_COL

#define GNC_OWNER_TREE_FAX_COL   "fax"

Definition at line 82 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_ID_COL

#define GNC_OWNER_TREE_ID_COL   "owner-id"

Definition at line 74 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_NAME_COL

#define GNC_OWNER_TREE_NAME_COL   "name"

Definition at line 72 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_NOTES_COL

#define GNC_OWNER_TREE_NOTES_COL   "notes"

Definition at line 87 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_PHONE_COL

#define GNC_OWNER_TREE_PHONE_COL   "phone"

Definition at line 81 of file gnc-tree-view-owner.h.

◆ GNC_OWNER_TREE_TYPE_COL

#define GNC_OWNER_TREE_TYPE_COL   "type"

Definition at line 73 of file gnc-tree-view-owner.h.

◆ GNC_TREE_MODEL_ACCOUNT_NAME

#define GNC_TREE_MODEL_ACCOUNT_NAME   "GncTreeModelAccount"

Definition at line 49 of file gnc-tree-model-account.h.

◆ GNC_TREE_MODEL_COMMODITY_NAME

#define GNC_TREE_MODEL_COMMODITY_NAME   "GncTreeModelCommodity"

Definition at line 50 of file gnc-tree-model-commodity.h.

◆ GNC_TREE_MODEL_NAME

#define GNC_TREE_MODEL_NAME   "GncTreeModel"

Definition at line 46 of file gnc-tree-model.h.

◆ GNC_TREE_MODEL_OWNER_NAME

#define GNC_TREE_MODEL_OWNER_NAME   "GncTreeModelOwner"

Definition at line 48 of file gnc-tree-model-owner.h.

◆ GNC_TREE_MODEL_PRICE_NAME

#define GNC_TREE_MODEL_PRICE_NAME   "GncTreeModelPrice"

Definition at line 50 of file gnc-tree-model-price.h.

◆ GNC_TREE_VIEW_ACCOUNT_NAME

#define GNC_TREE_VIEW_ACCOUNT_NAME   "GncTreeViewAccount"

Definition at line 49 of file gnc-tree-view-account.h.

◆ GNC_TREE_VIEW_OWNER_NAME

#define GNC_TREE_VIEW_OWNER_NAME   "GncTreeViewOwner"

Definition at line 50 of file gnc-tree-view-owner.h.

◆ GNC_TYPE_TREE_MODEL

#define GNC_TYPE_TREE_MODEL   (gnc_tree_model_get_type ())

Definition at line 43 of file gnc-tree-model.h.

◆ GNC_TYPE_TREE_MODEL_ACCOUNT

#define GNC_TYPE_TREE_MODEL_ACCOUNT   (gnc_tree_model_account_get_type ())

Definition at line 47 of file gnc-tree-model-account.h.

◆ GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES

#define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES   (gnc_tree_model_account_types_get_type ())

Definition at line 46 of file gnc-tree-model-account-types.h.

◆ GNC_TYPE_TREE_MODEL_COMMODITY

#define GNC_TYPE_TREE_MODEL_COMMODITY   (gnc_tree_model_commodity_get_type ())

Definition at line 47 of file gnc-tree-model-commodity.h.

◆ GNC_TYPE_TREE_MODEL_OWNER

#define GNC_TYPE_TREE_MODEL_OWNER   (gnc_tree_model_owner_get_type ())

Definition at line 45 of file gnc-tree-model-owner.h.

◆ GNC_TYPE_TREE_MODEL_PRICE

#define GNC_TYPE_TREE_MODEL_PRICE   (gnc_tree_model_price_get_type ())

Definition at line 47 of file gnc-tree-model-price.h.

◆ GNC_TYPE_TREE_VIEW_ACCOUNT

#define GNC_TYPE_TREE_VIEW_ACCOUNT   (gnc_tree_view_account_get_type ())

Definition at line 46 of file gnc-tree-view-account.h.

◆ GNC_TYPE_TREE_VIEW_COMMODITY

#define GNC_TYPE_TREE_VIEW_COMMODITY   (gnc_tree_view_commodity_get_type ())

Definition at line 46 of file gnc-tree-view-commodity.h.

◆ GNC_TYPE_TREE_VIEW_OWNER

#define GNC_TYPE_TREE_VIEW_OWNER   (gnc_tree_view_owner_get_type ())

Definition at line 47 of file gnc-tree-view-owner.h.

◆ GNC_TYPE_TREE_VIEW_PRICE

#define GNC_TYPE_TREE_VIEW_PRICE   (gnc_tree_view_price_get_type ())

Definition at line 46 of file gnc-tree-view-price.h.

Typedef Documentation

◆ gnc_tree_view_account_filter_func

typedef gboolean(* gnc_tree_view_account_filter_func) (Account *account, gpointer data)

This is the description of a filter function used by the account tree.

Parameters
accountThe account to be tested.
dataThe data provided when the filter function was added.
Returns
TRUE if the account should be displayed.

Definition at line 266 of file gnc-tree-view-account.h.

◆ gnc_tree_view_commodity_cm_filter_func

typedef gboolean(* gnc_tree_view_commodity_cm_filter_func) (gnc_commodity *, gpointer data)

Definition at line 110 of file gnc-tree-view-commodity.h.

◆ gnc_tree_view_commodity_ns_filter_func

typedef gboolean(* gnc_tree_view_commodity_ns_filter_func) (gnc_commodity_namespace *, gpointer data)

Definition at line 109 of file gnc-tree-view-commodity.h.

◆ gnc_tree_view_owner_filter_func

typedef gboolean(* gnc_tree_view_owner_filter_func) (GncOwner *owner, gpointer data)

This is the description of a filter function used by the owner tree.

Parameters
ownerThe owner to be tested.
dataThe data provided when the filter function was added.
Returns
TRUE if the owner should be displayed.

Definition at line 155 of file gnc-tree-view-owner.h.

◆ gnc_tree_view_price_cm_filter_func

typedef gboolean(* gnc_tree_view_price_cm_filter_func) (gnc_commodity *, gpointer data)

Definition at line 117 of file gnc-tree-view-price.h.

◆ gnc_tree_view_price_ns_filter_func

typedef gboolean(* gnc_tree_view_price_ns_filter_func) (gnc_commodity_namespace *, gpointer data)

This function attaches a filter function to the given price tree.

This function will be called for each price that the view thinks should possibly show. The filter may perform any actions necessary on the price to decide whether it should be shown or not. (I.E. Check type, placeholder status, etc.) If the filter returns TRUE then the price will be displayed.

Parameters
price_viewA pointer to an price tree view.
funcA filtration function that is called on individual elements in the tree. If this function returns TRUE, the price will be displayed.
dataA data block passed into each instance of the function.
destroyA function to destroy the data block. This function will be called when the filter is destroyed. may be NULL.

Definition at line 116 of file gnc-tree-view-price.h.

◆ gnc_tree_view_price_pc_filter_func

typedef gboolean(* gnc_tree_view_price_pc_filter_func) (GNCPrice *, gpointer data)

Definition at line 118 of file gnc-tree-view-price.h.

◆ GncTreeViewAccountColumnSource

typedef gchar *(* GncTreeViewAccountColumnSource) (Account *account, GtkTreeViewColumn *col, GtkCellRenderer *cell)

Definition at line 158 of file gnc-tree-view-account.h.

◆ GncTreeViewAccountColumnTextEdited

typedef void(* GncTreeViewAccountColumnTextEdited) (Account *account, GtkTreeViewColumn *col, const gchar *new_text)

Definition at line 162 of file gnc-tree-view-account.h.

◆ GncTreeViewOwnerColumnSource

typedef gchar *(* GncTreeViewOwnerColumnSource) (GncOwner *owner, GtkTreeViewColumn *col, GtkCellRenderer *cell)

Definition at line 133 of file gnc-tree-view-owner.h.

◆ GncTreeViewOwnerColumnTextEdited

typedef void(* GncTreeViewOwnerColumnTextEdited) (GncOwner *owner, GtkTreeViewColumn *col, const gchar *new_text)

Definition at line 137 of file gnc-tree-view-owner.h.

Enumeration Type Documentation

◆ GncTreeModelAccountColumn

enum GncTreeModelAccountColumn

Definition at line 51 of file gnc-tree-model-account.h.

52{
53 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
54 GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
55 GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
56 GNC_TREE_MODEL_ACCOUNT_COL_CODE,
57 GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
58 GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
59 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
60 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
61 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
62 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
63 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD,
64 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT,
65 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT_EXPLANATION,
66 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
67 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
68 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
69 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
70 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
71 GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE,
72 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
73 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
74 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
75 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
76 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
77 GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
78 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
79 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT,
80 GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
81 GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
82 GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE,
83
84 GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE,
85
86 /* internal hidden columns */
87 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
88 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT,
89 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
90 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
91 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
92 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
93 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
94 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
95 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
96
97 GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS
98} GncTreeModelAccountColumn;

◆ GncTreeModelAccountTypesColumn

enum GncTreeModelAccountTypesColumn

Definition at line 49 of file gnc-tree-model-account-types.h.

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;

◆ GncTreeModelCommodityColumn

enum GncTreeModelCommodityColumn

Definition at line 53 of file gnc-tree-model-commodity.h.

54{
55 GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
56 GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC,
57 GNC_TREE_MODEL_COMMODITY_COL_USER_SYMBOL,
58 GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
59 GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
60 GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
61 GNC_TREE_MODEL_COMMODITY_COL_CUSIP,
62 GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
63 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG,
64 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
65 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
66
67 GNC_TREE_MODEL_COMMODITY_COL_LAST_VISIBLE = GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
68
69 /* internal hidden columns */
70 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
71
72 GNC_TREE_MODEL_COMMODITY_NUM_COLUMNS
73} GncTreeModelCommodityColumn;

◆ GncTreeModelOwnerColumn

enum GncTreeModelOwnerColumn

Definition at line 51 of file gnc-tree-model-owner.h.

52{
53 GNC_TREE_MODEL_OWNER_COL_NAME,
54 GNC_TREE_MODEL_OWNER_COL_TYPE,
55 GNC_TREE_MODEL_OWNER_COL_ID,
56 GNC_TREE_MODEL_OWNER_COL_CURRENCY,
57 GNC_TREE_MODEL_OWNER_COL_ADDRESS_NAME,
58 GNC_TREE_MODEL_OWNER_COL_ADDRESS_1,
59 GNC_TREE_MODEL_OWNER_COL_ADDRESS_2,
60 GNC_TREE_MODEL_OWNER_COL_ADDRESS_3,
61 GNC_TREE_MODEL_OWNER_COL_ADDRESS_4,
62 GNC_TREE_MODEL_OWNER_COL_PHONE,
63 GNC_TREE_MODEL_OWNER_COL_FAX,
64 GNC_TREE_MODEL_OWNER_COL_EMAIL,
65 GNC_TREE_MODEL_OWNER_COL_BALANCE,
66 GNC_TREE_MODEL_OWNER_COL_BALANCE_REPORT,
67 GNC_TREE_MODEL_OWNER_COL_NOTES,
68 GNC_TREE_MODEL_OWNER_COL_ACTIVE,
69
70 GNC_TREE_MODEL_OWNER_COL_LAST_VISIBLE = GNC_TREE_MODEL_OWNER_COL_ACTIVE,
71
72 /* internal hidden columns */
73 GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE,
74
75 GNC_TREE_MODEL_OWNER_NUM_COLUMNS
76} GncTreeModelOwnerColumn;

◆ GncTreeModelPriceColumn

enum GncTreeModelPriceColumn

Definition at line 53 of file gnc-tree-model-price.h.

54{
55 GNC_TREE_MODEL_PRICE_COL_COMMODITY,
56 GNC_TREE_MODEL_PRICE_COL_CURRENCY,
57 GNC_TREE_MODEL_PRICE_COL_DATE,
58 GNC_TREE_MODEL_PRICE_COL_SOURCE,
59 GNC_TREE_MODEL_PRICE_COL_TYPE,
60 GNC_TREE_MODEL_PRICE_COL_VALUE,
61
62 GNC_TREE_MODEL_PRICE_COL_LAST_VISIBLE = GNC_TREE_MODEL_PRICE_COL_VALUE,
63
64 /* internal hidden columns */
65 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
66 GNC_TREE_MODEL_PRICE_NUM_COLUMNS
67} GncTreeModelPriceColumn;

Function Documentation

◆ account_filter_dialog_create()

void account_filter_dialog_create ( AccountFilterDialog fd,
GncPluginPage page 
)

Definition at line 2294 of file gnc-tree-view-account.c.

2295{
2296 GtkWidget *dialog, *button;
2297 GtkTreeView *view;
2298 GtkCellRenderer *renderer;
2299 GtkBuilder *builder;
2300 gchar *title;
2301
2302 ENTER("(fd %p, page %p)", fd, page);
2303
2304 if (fd->dialog)
2305 {
2306 gtk_window_present(GTK_WINDOW(fd->dialog));
2307 LEAVE("existing dialog");
2308 return;
2309 }
2310
2311 /* Create the dialog */
2312 builder = gtk_builder_new();
2313 gnc_builder_add_from_file (builder, "dialog-account.glade", "account_filter_by_dialog");
2314 dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_filter_by_dialog"));
2315 fd->dialog = dialog;
2316 gtk_window_set_transient_for(GTK_WINDOW(dialog),
2317 GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
2318 /* Translators: The %s is the name of the plugin page */
2319 title = g_strdup_printf(_("Filter %s by..."),
2320 _(gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page))));
2321 gtk_window_set_title(GTK_WINDOW(dialog), title);
2322 g_free(title);
2323
2324 /* Remember current state */
2325 fd->original_visible_types = fd->visible_types;
2326 fd->original_show_hidden = fd->show_hidden;
2327 fd->original_show_zero_total = fd->show_zero_total;
2328 fd->original_show_unused = fd->show_unused;
2329
2330 /* Update the dialog widgets for the current state */
2331 button = GTK_WIDGET(gtk_builder_get_object (builder, "show_hidden"));
2332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2333 fd->show_hidden);
2334 button = GTK_WIDGET(gtk_builder_get_object (builder, "show_zero"));
2335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2336 fd->show_zero_total);
2337 button = GTK_WIDGET(gtk_builder_get_object (builder, "show_unused"));
2338 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2339 fd->show_unused);
2340
2341 /* Set up the tree view and model */
2342 view = GTK_TREE_VIEW(gtk_builder_get_object (builder, FILTER_TREE_VIEW));
2343
2344 fd->model = gnc_tree_model_account_types_filter_using_mask
2345 (~(1 << ACCT_TYPE_ROOT));
2346 gtk_tree_view_set_model(view, fd->model);
2347 g_object_unref (fd->model);
2348
2349 renderer = gtk_cell_renderer_toggle_new();
2350
2351 g_signal_connect(renderer, "toggled",
2352 G_CALLBACK(gppat_filter_visible_toggled_cb), fd);
2353
2354 gtk_tree_view_insert_column_with_data_func (view, -1, NULL, renderer,
2355 gppat_filter_visible_set_func, fd, NULL);
2356
2357 gtk_tree_view_insert_column_with_attributes (view,
2358 -1, _("Account Types"), gtk_cell_renderer_text_new(),
2359 "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL);
2360
2361 /* Wire up the rest of the callbacks */
2362 gtk_builder_connect_signals(builder, fd);
2363 g_object_unref(G_OBJECT(builder));
2364
2365 /* Show it */
2366 gtk_widget_show_all(dialog);
2367 LEAVE(" ");
2368}
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ gnc_plugin_page_account_tree_filter_accounts()

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.

Accounts may be filtered if the user has decided not to display that particular account type, or if the user has requested that accounts with a zero total not be shown.

Parameters
accountThe account that was toggled.
user_dataA pointer to the AccountFilterDialog struct.
Returns
TRUE if the account should be visible. FALSE if the account should be hidden.

Definition at line 2033 of file gnc-tree-view-account.c.

2035{
2036 AccountFilterDialog *fd = user_data;
2037 GNCAccountType acct_type;
2038 gnc_numeric total;
2039 gboolean result;
2040
2041 ENTER("account %p:%s", account, xaccAccountGetName(account));
2042
2043 if (g_hash_table_size (fd->filter_override) > 0)
2044 {
2045 Account *test_acc = NULL;
2046 test_acc = g_hash_table_lookup (fd->filter_override, account);
2047 if (test_acc != NULL)
2048 {
2049 LEAVE(" filter: override");
2050 return TRUE;
2051 }
2052 }
2053
2054 if (!fd->show_hidden && xaccAccountIsHidden (account))
2055 {
2056 LEAVE(" hide: hidden");
2057 return FALSE;
2058 }
2059
2060 if (!fd->show_zero_total)
2061 {
2062 total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
2063 if (gnc_numeric_zero_p(total))
2064 {
2065 LEAVE(" hide: zero balance");
2066 return FALSE;
2067 }
2068 }
2069
2070 if (!fd->show_unused)
2071 {
2072 if (gnc_account_and_descendants_empty(account))
2073 {
2074 LEAVE(" hide: unused");
2075 return FALSE;
2076 }
2077 }
2078
2079 acct_type = xaccAccountGetType(account);
2080 result = (fd->visible_types & (1 << acct_type)) ? TRUE : FALSE;
2081 LEAVE(" %s", result ? "show" : "hide");
2082 return result;
2083}
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition Account.cpp:3289
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed.
Definition Account.h:103
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition Account.cpp:3267
gboolean xaccAccountIsHidden(const Account *acc)
Should this account be "hidden".
Definition Account.cpp:4202
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
STRUCTS.

◆ gnc_plugin_page_owner_tree_filter_owners()

gboolean gnc_plugin_page_owner_tree_filter_owners ( GncOwner owner,
gpointer  user_data 
)

This function tells the owner tree view whether or not to filter out a particular owner.

Owners may be filtered if the user has decided not to display inactive owners, or if the user has requested that owners with a zero total not be shown.

Parameters
ownerThe owner that is being evaluated.
user_dataA pointer to the OwnerFilterDialog struct.
Returns
TRUE if the owner should be visible. FALSE if the owner should be hidden.

Definition at line 1025 of file gnc-tree-view-owner.c.

1027{
1028 OwnerFilterDialog *fd = user_data;
1029 gnc_numeric total;
1030
1031 ENTER("owner %p:%s", owner, gncOwnerGetName(owner));
1032
1033 if (!fd->show_inactive && !gncOwnerGetActive (owner))
1034 {
1035 LEAVE(" hide: inactive");
1036 return FALSE;
1037 }
1038
1039 if (!fd->show_zero_total)
1040 {
1041 total = gncOwnerGetBalanceInCurrency (owner, NULL);
1042 if (gnc_numeric_zero_p(total))
1043 {
1044 LEAVE(" hide: zero balance");
1045 return FALSE;
1046 }
1047 }
1048
1049 return TRUE;
1050}
gnc_numeric gncOwnerGetBalanceInCurrency(const GncOwner *owner, const gnc_commodity *report_currency)
Given an owner, extract the open balance from the owner and then convert it to the desired currency.
Definition gncOwner.c:1478

◆ gnc_tree_model_account_clear_cache()

void gnc_tree_model_account_clear_cache ( GncTreeModelAccount *  model)

Clear the tree model account cached values.

Parameters
modelA pointer to the account tree model.

Definition at line 575 of file gnc-tree-model-account.c.

576{
577 if (model)
578 {
579 // destroy the cached account values and recreate
580 g_hash_table_destroy (model->account_values_hash);
581 model->account_values_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
582 g_free, g_free);
583
584 gtk_tree_model_foreach (GTK_TREE_MODEL(model), row_changed_foreach_func, NULL);
585 }
586}

◆ gnc_tree_model_account_get_account()

Account * gnc_tree_model_account_get_account ( GncTreeModelAccount *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash account.

This routine should only be called from an account tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the account tree model.
iterA gtk_tree_iter corresponding to a single account in the model.
Returns
A pointer to the corresponding account.

Definition at line 1250 of file gnc-tree-model-account.c.

1252{
1253 g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1254 g_return_val_if_fail (iter != NULL, NULL);
1255 g_return_val_if_fail (iter->user_data != NULL, NULL);
1256 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
1257
1258 return (Account *) iter->user_data;
1259}

◆ gnc_tree_model_account_get_iter_from_account()

gboolean gnc_tree_model_account_get_iter_from_account ( GncTreeModelAccount *  model,
Account account,
GtkTreeIter *  iter 
)

Convert a model/account pair into a gtk_tree_model_iter.

This routine should only be called from the file gnc-tree-view-account.c.

Definition at line 1267 of file gnc-tree-model-account.c.

1270{
1271 Account *parent;
1272 gint i;
1273
1274 ENTER("model %p, account %p, iter %p", model, account, iter);
1275 gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), FALSE);
1276 gnc_leave_return_val_if_fail ((account != NULL), FALSE);
1277 gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
1278
1279 iter->user_data = account;
1280 iter->stamp = model->stamp;
1281
1282 if (account == model->root)
1283 {
1284 iter->user_data2 = NULL;
1285 iter->user_data3 = GINT_TO_POINTER(0);
1286 LEAVE("Matched root");
1287 return TRUE;
1288 }
1289
1290 if (model->root != gnc_account_get_root (account))
1291 {
1292 LEAVE("Root doesn't match");
1293 return FALSE;
1294 }
1295
1296 parent = gnc_account_get_parent (account);
1297 i = gnc_account_child_index (parent, account);
1298 iter->user_data2 = parent;
1299 iter->user_data3 = GINT_TO_POINTER(i);
1300 LEAVE("iter %s", iter_to_string (iter));
1301 return (i != -1);
1302}
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to.
Definition Account.cpp:2942
gint gnc_account_child_index(const Account *parent, const Account *child)
Return the index of the specified child within the list of the parent's children.
Definition Account.cpp:2983
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition Account.cpp:2935
#define gnc_leave_return_val_if_fail(test, val)
Replacement for g_return_val_if_fail, but calls LEAVE if the test fails.
Definition qoflog.h:294

◆ gnc_tree_model_account_get_path_from_account()

GtkTreePath * gnc_tree_model_account_get_path_from_account ( GncTreeModelAccount *  model,
Account account 
)

Convert a model/account pair into a gtk_tree_model_path.

This routine should only be called from the file gnc-tree-view-account.c.

Definition at line 1310 of file gnc-tree-model-account.c.

1312{
1313 GtkTreeIter tree_iter;
1314 GtkTreePath *tree_path;
1315
1316 ENTER("model %p, account %p", model, account);
1317 gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1318 gnc_leave_return_val_if_fail (account != NULL, NULL);
1319
1321 &tree_iter))
1322 {
1323 LEAVE("no iter");
1324 return NULL;
1325 }
1326
1327 tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1328 if (tree_path)
1329 {
1330 gchar *path_string = gtk_tree_path_to_string (tree_path);
1331 LEAVE("path (2) %s", path_string);
1332 g_free (path_string);
1333 }
1334 else
1335 {
1336 LEAVE("no path");
1337 }
1338 return tree_path;
1339}
gboolean gnc_tree_model_account_get_iter_from_account(GncTreeModelAccount *model, Account *account, GtkTreeIter *iter)
Convert a model/account pair into a gtk_tree_model_iter.

◆ gnc_tree_model_account_new()

GtkTreeModel * gnc_tree_model_account_new ( Account root)

Create a new GtkTreeModel for manipulating gnucash accounts.

Parameters
rootThe account group to put at the top level of the tree hierarchy.

Definition at line 256 of file gnc-tree-model-account.c.

257{
258 GncTreeModelAccount *model;
259 const GList *item;
260
261 ENTER("root %p", root);
262 item = gnc_gobject_tracking_get_list (GNC_TREE_MODEL_ACCOUNT_NAME);
263 for ( ; item; item = g_list_next (item))
264 {
265 model = (GncTreeModelAccount *)item->data;
266 if (model->root == root)
267 {
268 g_object_ref (G_OBJECT(model));
269 LEAVE("returning existing model %p", model);
270 return GTK_TREE_MODEL(model);
271 }
272 }
273
274 model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT, NULL);
275
276 model->book = gnc_get_current_book();
277 model->root = root;
278
279 model->event_handler_id = qof_event_register_handler
280 ((QofEventHandler)gnc_tree_model_account_event_handler, model);
281
282 LEAVE("model %p", model);
283 return GTK_TREE_MODEL(model);
284}
void(* QofEventHandler)(QofInstance *ent, QofEventId event_type, gpointer handler_data, gpointer event_data)
Handler invoked when an event is generated.
Definition qofevent.h:89
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
Definition qofevent.cpp:73
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.

◆ gnc_tree_model_account_types_filter_using_mask()

GtkTreeModel * gnc_tree_model_account_types_filter_using_mask ( guint32  types)

Definition at line 120 of file gnc-tree-model-account-types.c.

121{
122 GtkTreeModel *f_model;
123
124 f_model = gtk_tree_model_filter_new (gnc_tree_model_account_types_master (),
125 NULL);
126 g_object_set_data (G_OBJECT (f_model), TYPE_MASK, GUINT_TO_POINTER (types));
127 gtk_tree_model_filter_set_visible_func (
128 GTK_TREE_MODEL_FILTER (f_model), gnc_tree_model_account_types_is_valid,
129 f_model, NULL);
130
131 return f_model;
132}

◆ gnc_tree_model_account_types_get_active_combo()

GNCAccountType gnc_tree_model_account_types_get_active_combo ( GtkComboBox *  combo)

Definition at line 208 of file gnc-tree-model-account-types.c.

209{
210 GtkTreeModelSort *s_model;
211 GtkTreeModelFilter *f_model;
212 GtkTreeIter iter;
213 guint32 bits = 0;
214 gint i;
215
216 g_return_val_if_fail (GTK_IS_COMBO_BOX(combo), 0);
217
218 if (gtk_combo_box_get_active_iter (combo, &iter))
219 {
220 s_model = GTK_TREE_MODEL_SORT(gtk_combo_box_get_model (combo));
221 f_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model (s_model));
222
223 if (gtk_tree_model_filter_get_model (f_model) != account_types_tree_model)
224 PERR("TreeSelection's TreeModel is not the account-types Model");
225 else
226 {
227 GtkTreePath *s_path = gtk_tree_model_get_path (GTK_TREE_MODEL(s_model), &iter);
228 GtkTreePath *f_path = gtk_tree_model_sort_convert_path_to_child_path (s_model, s_path);
229 GtkTreePath *path = gtk_tree_model_filter_convert_path_to_child_path (f_model, f_path);
230
231 gtk_tree_path_free (f_path);
232 gtk_tree_path_free (s_path);
233
234 if (!path || gtk_tree_path_get_depth (path) != 1)
235 {
236 PERR("Invalid Account-types TreePath.");
237 gtk_tree_path_free (path);
238 return ACCT_TYPE_NONE;
239 }
240 bits |= (1 << gtk_tree_path_get_indices (path)[0]);
241 gtk_tree_path_free (path);
242 }
243 }
244 for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
245 if (bits & (1 << i))
246 return i;
247 return ACCT_TYPE_NONE;
248}
@ NUM_ACCOUNT_TYPES
stop here; the following types just aren't ready for prime time
Definition Account.h:161
@ ACCT_TYPE_NONE
Not a type.
Definition Account.h:105
#define PERR(format, args...)
Log a serious error.
Definition qoflog.h:244

◆ gnc_tree_model_account_types_get_mask()

guint32 gnc_tree_model_account_types_get_mask ( GtkTreeModel *  f_model)

Definition at line 145 of file gnc-tree-model-account-types.c.

146{
147 g_return_val_if_fail (f_model, 0);
148
149 return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (f_model), TYPE_MASK));
150}

◆ gnc_tree_model_account_types_get_selection()

guint32 gnc_tree_model_account_types_get_selection ( GtkTreeSelection *  sel)

Definition at line 153 of file gnc-tree-model-account-types.c.

154{
155 GtkTreeModel *f_model, *model;
156 GtkTreePath *path;
157 GtkTreeView *view;
158 GList *list, *node;
159 guint32 bits = 0;
160
161 g_return_val_if_fail(GTK_IS_TREE_SELECTION(sel), 0);
162 view = gtk_tree_selection_get_tree_view(sel);
163 g_return_val_if_fail (view, 0);
164
165 /* circumvent a bug in gtk+ not always filling f_model */
166 f_model = NULL;
167 list = gtk_tree_selection_get_selected_rows(sel, &f_model);
168 if (!f_model)
169 f_model = gtk_tree_view_get_model(view);
170
171 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
172 if (model != account_types_tree_model)
173 PERR("TreeSelection's TreeModel is not the account-types Model");
174 else
175 {
176 for (node = list; node; node = node->next)
177 {
178 path = gtk_tree_model_filter_convert_path_to_child_path(
179 GTK_TREE_MODEL_FILTER(f_model), (GtkTreePath*)node->data);
180 if (!path || gtk_tree_path_get_depth(path) != 1)
181 {
182 PERR("Invalid Account-types TreePath.");
183 continue;
184 }
185 bits |= (1 << gtk_tree_path_get_indices(path)[0]);
186 }
187 }
188
189 g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
190 g_list_free (list);
191
192 return bits;
193}

◆ gnc_tree_model_account_types_get_selection_single()

GNCAccountType gnc_tree_model_account_types_get_selection_single ( GtkTreeSelection *  sel)

Definition at line 196 of file gnc-tree-model-account-types.c.

197{
198 gint i;
199 guint32 selected = gnc_tree_model_account_types_get_selection(sel);
200
201 for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
202 if (selected & (1 << i))
203 return i;
204 return ACCT_TYPE_NONE;
205}

◆ gnc_tree_model_account_types_new()

GtkTreeModel * gnc_tree_model_account_types_new ( guint32  selected)

Definition at line 88 of file gnc-tree-model-account-types.c.

89{
90 GncTreeModelAccountTypes *model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, NULL);
91 model->selected = selected;
92
93 return GTK_TREE_MODEL (model);
94}

◆ gnc_tree_model_account_types_set_active_combo()

void gnc_tree_model_account_types_set_active_combo ( GtkComboBox *  combo,
guint32  selected 
)

Definition at line 284 of file gnc-tree-model-account-types.c.

286{
287 GtkTreePath *path;
288 GtkTreeModelFilter *f_model;
289 GtkTreeModelSort *s_model;
290 gint i;
291
292 g_return_if_fail (GTK_IS_COMBO_BOX(combo));
293
294 s_model = GTK_TREE_MODEL_SORT(gtk_combo_box_get_model (combo));
295 f_model = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model (s_model));
296 g_return_if_fail (gtk_tree_model_filter_get_model (f_model) ==
297 account_types_tree_model);
298
299 gtk_combo_box_set_active (combo, -1);
300
301 path = gtk_tree_path_new_first ();
302
303 for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
304 {
305 if (selected & (1 << i))
306 {
307 GtkTreeIter iter;
308 GtkTreePath *f_path = gtk_tree_model_filter_convert_child_path_to_path (f_model, path);
309 GtkTreePath *s_path = gtk_tree_model_sort_convert_child_path_to_path (s_model, f_path);
310
311 gtk_tree_model_get_iter (GTK_TREE_MODEL(s_model), &iter, s_path);
312 gtk_combo_box_set_active_iter (combo, &iter);
313 gtk_tree_path_free (f_path);
314 gtk_tree_path_free (s_path);
315 }
316 gtk_tree_path_next (path);
317 }
318 gtk_tree_path_free (path);
319}

◆ gnc_tree_model_account_types_set_mask()

void gnc_tree_model_account_types_set_mask ( GtkTreeModel *  f_model,
guint32  types 
)

Definition at line 135 of file gnc-tree-model-account-types.c.

137{
138 g_return_if_fail (f_model);
139
140 g_object_set_data (G_OBJECT (f_model), TYPE_MASK, GUINT_TO_POINTER (types));
141 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
142}

◆ gnc_tree_model_account_types_set_selection()

void gnc_tree_model_account_types_set_selection ( GtkTreeSelection *  sel,
guint32  selected 
)

Definition at line 251 of file gnc-tree-model-account-types.c.

253{
254 GtkTreePath *path;
255 GtkTreeModelFilter *f_model;
256 gint i;
257 GtkTreeView *view;
258
259 g_return_if_fail(GTK_IS_TREE_SELECTION(sel));
260 view = gtk_tree_selection_get_tree_view(sel);
261 g_return_if_fail (view);
262 f_model = GTK_TREE_MODEL_FILTER(gtk_tree_view_get_model(view));
263 g_return_if_fail(gtk_tree_model_filter_get_model(f_model) ==
264 account_types_tree_model);
265 gtk_tree_selection_unselect_all(sel);
266 path = gtk_tree_path_new_first();
267
268 for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
269 {
270 if (selected & (1 << i))
271 {
272 GtkTreePath *f_path = gtk_tree_model_filter_convert_child_path_to_path(
273 f_model, path);
274 gtk_tree_selection_select_path(sel, f_path);
275 gtk_tree_view_scroll_to_cell(view, f_path, NULL, FALSE, 0.0, 0.0);
276 gtk_tree_path_free(f_path);
277 }
278 gtk_tree_path_next(path);
279 }
280 gtk_tree_path_free(path);
281}

◆ gnc_tree_model_commodity_get_commodity()

gnc_commodity * gnc_tree_model_commodity_get_commodity ( GncTreeModelCommodity *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash commodity.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single commodity in the model.
Returns
A pointer to the corresponding commodity.

Definition at line 237 of file gnc-tree-model-commodity.c.

239{
240 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
241 g_return_val_if_fail (iter != NULL, NULL);
242 g_return_val_if_fail (iter->user_data != NULL, NULL);
243 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
244
245 if (iter->user_data != ITER_IS_COMMODITY)
246 return NULL;
247 return (gnc_commodity *)iter->user_data2;
248}

◆ gnc_tree_model_commodity_get_iter_from_commodity()

gboolean gnc_tree_model_commodity_get_iter_from_commodity ( GncTreeModelCommodity *  model,
gnc_commodity *  commodity,
GtkTreeIter *  iter 
)

Convert a commodity pointer into a GtkTreeIter.

Parameters
modelA pointer to the commodity tree model.
commodityA pointer to the gnucash commodity.
iterA pointer to a GtkTreeIter. This iter will be filled in to point where the commodity appears in the commodity tree.
Returns
TRUE if the returned iter is valid, FALSE otherwise.

Definition at line 908 of file gnc-tree-model-commodity.c.

911{
912 gnc_commodity_namespace *name_space;
913 GList *list;
914 gint n;
915
916 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
917 g_return_val_if_fail ((commodity != NULL), FALSE);
918 g_return_val_if_fail ((iter != NULL), FALSE);
919
920 ENTER("model %p, commodity %p, iter %p", model, commodity, iter);
921
922 name_space = gnc_commodity_get_namespace_ds(commodity);
923 if (name_space == NULL)
924 {
925 LEAVE("no namespace");
926 return FALSE;
927 }
928
930 if (list == NULL)
931 {
932 LEAVE("empty list");
933 return FALSE;
934 }
935
936 n = g_list_index(list, commodity);
937 g_list_free (list);
938 if (n == -1)
939 {
940 LEAVE("not in list");
941 return FALSE;
942 }
943
944 iter->stamp = model->stamp;
945 iter->user_data = ITER_IS_COMMODITY;
946 iter->user_data2 = commodity;
947 iter->user_data3 = GINT_TO_POINTER(n);
948 LEAVE("iter %s", iter_to_string(iter));
949 return TRUE;
950}
GList * gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
Return a list of all commodity data structures in the specified namespace.
gnc_commodity_namespace * gnc_commodity_get_namespace_ds(const gnc_commodity *cm)
Retrieve the namespace data structure for the specified commodity.

◆ gnc_tree_model_commodity_get_iter_from_namespace()

gboolean gnc_tree_model_commodity_get_iter_from_namespace ( GncTreeModelCommodity *  model,
gnc_commodity_namespace *  name_space,
GtkTreeIter *  iter 
)

Convert a commodity namespace pointer into a GtkTreeIter.

Parameters
modelA pointer to the commodity tree model.
namespaceA pointer to the gnucash commodity namespace.
iterA pointer to a GtkTreeIter. This iter will be filled in to point where the namespace appears in the commodity tree.
Returns
TRUE if the returned iter is valid, FALSE otherwise.

Definition at line 994 of file gnc-tree-model-commodity.c.

997{
998 GList *list;
999 gint n;
1000
1001 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
1002 g_return_val_if_fail ((name_space != NULL), FALSE);
1003 g_return_val_if_fail ((iter != NULL), FALSE);
1004
1005 ENTER("model %p, namespace %p, iter %p", model, name_space, iter);
1006
1007 list = gnc_commodity_table_get_namespaces_list(model->commodity_table);
1008 if (list == NULL)
1009 {
1010 LEAVE("");
1011 return FALSE;
1012 }
1013
1014 n = g_list_index(list, name_space);
1015 g_list_free (list);
1016 if (n == -1)
1017 {
1018 LEAVE("");
1019 return FALSE;
1020 }
1021
1022 iter->stamp = model->stamp;
1023 iter->user_data = ITER_IS_NAMESPACE;
1024 iter->user_data2 = name_space;
1025 iter->user_data3 = GINT_TO_POINTER(n);
1026 LEAVE("iter %s", iter_to_string(iter));
1027 return TRUE;
1028}
GList * gnc_commodity_table_get_namespaces_list(const gnc_commodity_table *table)
Return a list of all namespace data structures in the commodity table.

◆ gnc_tree_model_commodity_get_namespace()

gnc_commodity_namespace * gnc_tree_model_commodity_get_namespace ( GncTreeModelCommodity *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash commodity namespace.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single namespace in the model.
Returns
A pointer to the corresponding namespace.

Definition at line 223 of file gnc-tree-model-commodity.c.

225{
226 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
227 g_return_val_if_fail (iter != NULL, NULL);
228 g_return_val_if_fail (iter->user_data != NULL, NULL);
229 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
230
231 if (iter->user_data != ITER_IS_NAMESPACE)
232 return NULL;
233 return (gnc_commodity_namespace *)iter->user_data2;
234}

◆ gnc_tree_model_commodity_get_path_from_commodity()

GtkTreePath * gnc_tree_model_commodity_get_path_from_commodity ( GncTreeModelCommodity *  model,
gnc_commodity *  commodity 
)

Convert a commodity pointer into a GtkTreePath.

Parameters
modelA pointer to the commodity tree model.
commodityA pointer to the gnucash commodity.
Returns
A pointer to a GtkTreePath describing the location of this commodity. This pointer must be freed by the caller when no longer needed. This routine will return NULL if the commodity does not exist in the tree.

Definition at line 958 of file gnc-tree-model-commodity.c.

960{
961 GtkTreeIter tree_iter;
962 GtkTreePath *tree_path;
963
964 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
965 g_return_val_if_fail (commodity != NULL, NULL);
966 ENTER("model %p, commodity %p", model, commodity);
967
968 if (!gnc_tree_model_commodity_get_iter_from_commodity (model, commodity, &tree_iter))
969 {
970 LEAVE("no iter");
971 return NULL;
972 }
973
974 tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
975 if (tree_path)
976 {
977 gchar *path_string = gtk_tree_path_to_string(tree_path);
978 LEAVE("path (2) %s", path_string);
979 g_free(path_string);
980 }
981 else
982 {
983 LEAVE("no path");
984 }
985 return tree_path;
986}
gboolean gnc_tree_model_commodity_get_iter_from_commodity(GncTreeModelCommodity *model, gnc_commodity *commodity, GtkTreeIter *iter)
Convert a commodity pointer into a GtkTreeIter.

◆ gnc_tree_model_commodity_iter_is_commodity()

gboolean gnc_tree_model_commodity_iter_is_commodity ( GncTreeModelCommodity *  model,
GtkTreeIter *  iter 
)

Determine whether or not the specified GtkTreeIter points to a commodity.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single item in the model.
Returns
TRUE if the iter points to a commodity, FALSE otherwise.

Definition at line 211 of file gnc-tree-model-commodity.c.

213{
214 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
215 g_return_val_if_fail (iter != NULL, FALSE);
216 g_return_val_if_fail (iter->user_data != NULL, FALSE);
217 g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
218
219 return (iter->user_data == ITER_IS_COMMODITY);
220}

◆ gnc_tree_model_commodity_iter_is_namespace()

gboolean gnc_tree_model_commodity_iter_is_namespace ( GncTreeModelCommodity *  model,
GtkTreeIter *  iter 
)

Determine whether or not the specified GtkTreeIter points to a commodity namespace.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single item in the model.
Returns
TRUE if the iter points to a commodity namespace, FALSE otherwise.

Definition at line 199 of file gnc-tree-model-commodity.c.

201{
202 g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
203 g_return_val_if_fail (iter != NULL, FALSE);
204 g_return_val_if_fail (iter->user_data != NULL, FALSE);
205 g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
206
207 return (iter->user_data == ITER_IS_NAMESPACE);
208}

◆ gnc_tree_model_commodity_new()

GtkTreeModel * gnc_tree_model_commodity_new ( QofBook book,
gnc_commodity_table *  ct 
)

Create a new GtkTreeModel for manipulating gnucash commodities.

Parameters
bookThe book that holds these commodities.
ctA pointer to the commodity table to use for this tree. All namespaces and commodities in this tree will be included.

Definition at line 168 of file gnc-tree-model-commodity.c.

169{
170 GncTreeModelCommodity *model;
171 const GList *item;
172
173 ENTER("");
174
175 item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_COMMODITY_NAME);
176 for ( ; item; item = g_list_next(item))
177 {
178 model = (GncTreeModelCommodity *)item->data;
179 if (model->commodity_table == ct)
180 {
181 g_object_ref(G_OBJECT(model));
182 LEAVE("returning existing model %p", model);
183 return GTK_TREE_MODEL(model);
184 }
185 }
186
187 model = g_object_new (GNC_TYPE_TREE_MODEL_COMMODITY, NULL);
188 model->book = book;
189 model->commodity_table = ct;
190
191 model->event_handler_id =
192 qof_event_register_handler (gnc_tree_model_commodity_event_handler, model);
193
194 LEAVE("");
195 return GTK_TREE_MODEL (model);
196}

◆ gnc_tree_model_owner_get_iter_from_owner()

gboolean gnc_tree_model_owner_get_iter_from_owner ( GncTreeModelOwner *  model,
GncOwner owner,
GtkTreeIter *  iter 
)

Convert a model/owner pair into a gtk_tree_model_iter.

This routine should only be called from the file gnc-tree-view-owner.c.

Definition at line 797 of file gnc-tree-model-owner.c.

800{
801 GList *owner_in_list;
802
803 ENTER("model %p, owner %p, iter %p", model, owner, iter);
804 gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), FALSE);
805 gnc_leave_return_val_if_fail ((owner != NULL), FALSE);
806 gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
807
808 owner_in_list = g_list_find_custom (model->owner_list, (gconstpointer)owner, (GCompareFunc)gncOwnerGCompareFunc);
809 if (owner_in_list)
810 {
811 iter->stamp = model->stamp;
812 iter->user_data = owner_in_list->data;
813 iter->user_data2 = GINT_TO_POINTER (g_list_position (model->owner_list, owner_in_list));
814 iter->user_data3 = NULL;
815 LEAVE("iter %s", iter_to_string (iter));
816 return TRUE;
817 }
818 else
819 {
820 iter->stamp = 0;
821 iter->user_data = NULL;
822 LEAVE("Owner not found in list");
823 return FALSE;
824 }
825}
int gncOwnerGCompareFunc(const GncOwner *a, const GncOwner *b)
Same as gncOwnerEqual, but returns 0 if equal to be used as a GList custom compare function.
Definition gncOwner.c:411

◆ gnc_tree_model_owner_get_owner()

GncOwner * gnc_tree_model_owner_get_owner ( GncTreeModelOwner *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash owner.

This routine should only be called from an owner tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the owner tree model.
iterA gtk_tree_iter corresponding to a single owner in the model.
Returns
A pointer to the corresponding owner.

Definition at line 780 of file gnc-tree-model-owner.c.

782{
783 g_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), NULL);
784 g_return_val_if_fail (iter != NULL, NULL);
785 g_return_val_if_fail (iter->user_data != NULL, NULL);
786 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
787
788 return (GncOwner *) iter->user_data;
789}

◆ gnc_tree_model_owner_get_path_from_owner()

GtkTreePath * gnc_tree_model_owner_get_path_from_owner ( GncTreeModelOwner *  model,
GncOwner owner 
)

Convert a model/owner pair into a gtk_tree_model_path.

This routine should only be called from the file gnc-tree-view-owner.c.

Definition at line 833 of file gnc-tree-model-owner.c.

835{
836 GtkTreeIter tree_iter;
837 GtkTreePath *tree_path;
838
839 ENTER("model %p, owner %p", model, owner);
840 gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), NULL);
841 gnc_leave_return_val_if_fail (owner != NULL, NULL);
842
844 &tree_iter))
845 {
846 LEAVE("no iter");
847 return NULL;
848 }
849
850 tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
851 if (tree_path)
852 {
853 gchar *path_string = gtk_tree_path_to_string(tree_path);
854 LEAVE("path (2) %s", path_string);
855 g_free(path_string);
856 }
857 else
858 {
859 LEAVE("no path");
860 }
861 return tree_path;
862}
gboolean gnc_tree_model_owner_get_iter_from_owner(GncTreeModelOwner *model, GncOwner *owner, GtkTreeIter *iter)
Convert a model/owner pair into a gtk_tree_model_iter.

◆ gnc_tree_model_owner_new()

GtkTreeModel * gnc_tree_model_owner_new ( GncOwnerType  owner_type)

Create a new GtkTreeModel for manipulating gnucash owners.

Parameters
rootThe owner group to put at the top level of the tree hierarchy.

Definition at line 224 of file gnc-tree-model-owner.c.

225{
226 GncTreeModelOwner *model;
227 const GList *item;
228
229 ENTER("owner_type %d", owner_type);
230 item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_OWNER_NAME);
231 for ( ; item; item = g_list_next(item))
232 {
233 model = (GncTreeModelOwner *)item->data;
234 if (model->owner_type == owner_type)
235 {
236 g_object_ref(G_OBJECT(model));
237 LEAVE("returning existing model %p", model);
238 return GTK_TREE_MODEL(model);
239 }
240 }
241
242 model = g_object_new (GNC_TYPE_TREE_MODEL_OWNER,
243 NULL);
244
245 model->book = gnc_get_current_book();
246 model->owner_type = owner_type;
247 model->owner_list = gncBusinessGetOwnerList (model->book, gncOwnerTypeToQofIdType(owner_type), TRUE);
248
249 model->event_handler_id = qof_event_register_handler
250 ((QofEventHandler)gnc_tree_model_owner_event_handler, model);
251
252 LEAVE("model %p", model);
253 return GTK_TREE_MODEL (model);
254}
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition gncOwner.c:235

◆ gnc_tree_model_price_get_commodity()

gnc_commodity * gnc_tree_model_price_get_commodity ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash commodity.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single commodity in the model.
Returns
A pointer to the corresponding commodity.

Definition at line 282 of file gnc-tree-model-price.c.

284{
285 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
286 g_return_val_if_fail (iter != NULL, NULL);
287 g_return_val_if_fail (iter->user_data != NULL, NULL);
288 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
289
290 if (iter->user_data != ITER_IS_COMMODITY)
291 return NULL;
292 return (gnc_commodity *)iter->user_data2;
293}

◆ gnc_tree_model_price_get_iter_from_commodity()

gboolean gnc_tree_model_price_get_iter_from_commodity ( GncTreeModelPrice *  model,
gnc_commodity *  commodity,
GtkTreeIter *  iter 
)

Convert a commodity pointer into a GtkTreeIter.

Parameters
modelA pointer to the price tree model.
commodityA pointer to the gnucash commodity.
iterA pointer to a GtkTreeIter. This iter will be filled in to point where the commodity appears in the price tree.
Returns
TRUE if the returned iter is valid, FALSE otherwise.

Definition at line 1197 of file gnc-tree-model-price.c.

1200{
1201 gnc_commodity_namespace *name_space;
1202 GList *list;
1203 gint n;
1204
1205 ENTER("model %p, commodity %p, iter %p", model, commodity, iter);
1206 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1207 g_return_val_if_fail ((commodity != NULL), FALSE);
1208 g_return_val_if_fail ((iter != NULL), FALSE);
1209
1210 name_space = gnc_commodity_get_namespace_ds(commodity);
1211 if (name_space == NULL)
1212 {
1213 LEAVE("no namespace");
1214 return FALSE;
1215 }
1216
1218 if (list == NULL)
1219 {
1220 LEAVE("empty list");
1221 return FALSE;
1222 }
1223
1224 n = g_list_index(list, commodity);
1225 g_list_free (list);
1226 if (n == -1)
1227 {
1228 LEAVE("commodity not in list");
1229 return FALSE;
1230 }
1231
1232 iter->stamp = model->stamp;
1233 iter->user_data = ITER_IS_COMMODITY;
1234 iter->user_data2 = commodity;
1235 iter->user_data3 = GINT_TO_POINTER(n);
1236 LEAVE("iter %s", iter_to_string(model, iter));
1237 return TRUE;
1238}

◆ gnc_tree_model_price_get_iter_from_namespace()

gboolean gnc_tree_model_price_get_iter_from_namespace ( GncTreeModelPrice *  model,
gnc_commodity_namespace *  name_space,
GtkTreeIter *  iter 
)

Convert a commodity namespace pointer into a GtkTreeIter.

Parameters
modelA pointer to the price tree model.
namespaceA pointer to the gnucash commodity namespace.
iterA pointer to a GtkTreeIter. This iter will be filled in to point where the namespace appears in the price tree.
Returns
TRUE if the returned iter is valid, FALSE otherwise.

Definition at line 1246 of file gnc-tree-model-price.c.

1249{
1250 gnc_commodity_table *ct;
1251 GList *list;
1252 gint n;
1253
1254 ENTER("model %p, namespace %p, iter %p", model, name_space, iter);
1255 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1256 g_return_val_if_fail ((name_space != NULL), FALSE);
1257 g_return_val_if_fail ((iter != NULL), FALSE);
1258
1259 ct = qof_book_get_data (model->book, GNC_COMMODITY_TABLE);
1261 if (list == NULL)
1262 {
1263 LEAVE("namespace list empty");
1264 return FALSE;
1265 }
1266
1267 n = g_list_index(list, name_space);
1268 g_list_free (list);
1269 if (n == -1)
1270 {
1271 LEAVE("namespace not found");
1272 return FALSE;
1273 }
1274
1275 iter->stamp = model->stamp;
1276 iter->user_data = ITER_IS_NAMESPACE;
1277 iter->user_data2 = name_space;
1278 iter->user_data3 = GINT_TO_POINTER(n);
1279 LEAVE("iter %s", iter_to_string(model, iter));
1280 return TRUE;
1281}

◆ gnc_tree_model_price_get_iter_from_price()

gboolean gnc_tree_model_price_get_iter_from_price ( GncTreeModelPrice *  model,
GNCPrice *  price,
GtkTreeIter *  iter 
)

Convert a price pointer into a GtkTreeIter.

Parameters
modelA pointer to the price tree model.
priceA pointer to the gnucash price.
iterA pointer to a GtkTreeIter. This iter will be filled in to point where the price appears in the price tree.
Returns
TRUE if the returned iter is valid, FALSE otherwise.

Definition at line 1111 of file gnc-tree-model-price.c.

1114{
1115 gnc_commodity *commodity;
1116 GList *list;
1117 gint n;
1118
1119 ENTER("model %p, price %p, iter %p", model, price, iter);
1120 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1121 g_return_val_if_fail ((price != NULL), FALSE);
1122 g_return_val_if_fail ((iter != NULL), FALSE);
1123
1124 commodity = gnc_price_get_commodity(price);
1125 if (commodity == NULL)
1126 {
1127 LEAVE("no commodity");
1128 return FALSE;
1129 }
1130
1131 list = gnc_pricedb_get_prices(model->price_db, commodity, NULL);
1132 if (list == NULL)
1133 {
1134 LEAVE("empty list");
1135 return FALSE;
1136 }
1137
1138 n = g_list_index(list, price);
1139 if (n == -1)
1140 {
1142 LEAVE("not in list");
1143 return FALSE;
1144 }
1145
1146 iter->stamp = model->stamp;
1147 iter->user_data = ITER_IS_PRICE;
1148 iter->user_data2 = price;
1149 iter->user_data3 = GINT_TO_POINTER(n);
1151 LEAVE("iter %s", iter_to_string(model, iter));
1152 return TRUE;
1153}
PriceList * gnc_pricedb_get_prices(GNCPriceDB *db, const gnc_commodity *commodity, const gnc_commodity *currency)
Return all the prices for a given commodity in another.
void gnc_price_list_destroy(PriceList *prices)
gnc_price_list_destroy - destroy the given price list, calling gnc_price_unref on all the prices incl...

◆ gnc_tree_model_price_get_namespace()

gnc_commodity_namespace * gnc_tree_model_price_get_namespace ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash commodity namespace.

This routine should only be called from a commodity tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the commodity tree model.
iterA GtkTreeIter corresponding to a single namespace in the model.
Returns
A pointer to the corresponding namespace.

Definition at line 268 of file gnc-tree-model-price.c.

270{
271 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
272 g_return_val_if_fail (iter != NULL, NULL);
273 g_return_val_if_fail (iter->user_data != NULL, NULL);
274 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
275
276 if (iter->user_data != ITER_IS_NAMESPACE)
277 return NULL;
278 return (gnc_commodity_namespace *)iter->user_data2;
279}

◆ gnc_tree_model_price_get_path_from_price()

GtkTreePath * gnc_tree_model_price_get_path_from_price ( GncTreeModelPrice *  model,
GNCPrice *  price 
)

Convert a price pointer into a GtkTreePath.

Parameters
modelA pointer to the price tree model.
priceA pointer to the commodity price.
Returns
A pointer to a GtkTreePath describing the location of this price. This pointer must be freed by the caller when no longer needed. This routine will return NULL if the price does not exist in the tree.

Definition at line 1161 of file gnc-tree-model-price.c.

1163{
1164 GtkTreeIter tree_iter;
1165 GtkTreePath *tree_path;
1166
1167 ENTER("model %p, price %p", model, price);
1168 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
1169 g_return_val_if_fail (price != NULL, NULL);
1170
1171 if (!gnc_tree_model_price_get_iter_from_price (model, price, &tree_iter))
1172 {
1173 LEAVE("no iter");
1174 return NULL;
1175 }
1176
1177 tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1178 if (tree_path)
1179 {
1180 gchar *path_string = gtk_tree_path_to_string(tree_path);
1181 LEAVE("path (2) %s", path_string);
1182 g_free(path_string);
1183 }
1184 else
1185 {
1186 LEAVE("no path");
1187 }
1188 return tree_path;
1189}
gboolean gnc_tree_model_price_get_iter_from_price(GncTreeModelPrice *model, GNCPrice *price, GtkTreeIter *iter)
Convert a price pointer into a GtkTreeIter.

◆ gnc_tree_model_price_get_price()

GNCPrice * gnc_tree_model_price_get_price ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Convert a model/iter pair to a gnucash price.

This routine should only be called from a price tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the price tree model.
iterA GtkTreeIter corresponding to a single price in the model.
Returns
A pointer to the corresponding price.

Definition at line 296 of file gnc-tree-model-price.c.

298{
299 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
300 g_return_val_if_fail (iter != NULL, NULL);
301 g_return_val_if_fail (iter->user_data != NULL, NULL);
302 g_return_val_if_fail (iter->stamp == model->stamp, NULL);
303
304 if (iter->user_data != ITER_IS_PRICE)
305 return NULL;
306 return (GNCPrice *)iter->user_data2;
307}

◆ gnc_tree_model_price_iter_is_commodity()

gboolean gnc_tree_model_price_iter_is_commodity ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Determine whether or not the specified GtkTreeIter points to a commodity.

This routine should only be called from a price tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the price tree model.
iterA GtkTreeIter corresponding to a single item in the model.
Returns
TRUE if the iter points to a commodity, FALSE otherwise.

Definition at line 244 of file gnc-tree-model-price.c.

246{
247 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
248 g_return_val_if_fail (iter != NULL, FALSE);
249 g_return_val_if_fail (iter->user_data != NULL, FALSE);
250 g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
251
252 return (iter->user_data == ITER_IS_COMMODITY);
253}

◆ gnc_tree_model_price_iter_is_namespace()

gboolean gnc_tree_model_price_iter_is_namespace ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Determine whether or not the specified GtkTreeIter points to a "commodity namespace".

This routine should only be called from a price tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the price tree model.
iterA GtkTreeIter corresponding to a single item in the model.
Returns
TRUE if the iter points to a commodity namespace, FALSE otherwise.

Definition at line 232 of file gnc-tree-model-price.c.

234{
235 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
236 g_return_val_if_fail (iter != NULL, FALSE);
237 g_return_val_if_fail (iter->user_data != NULL, FALSE);
238 g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
239
240 return (iter->user_data == ITER_IS_NAMESPACE);
241}

◆ gnc_tree_model_price_iter_is_price()

gboolean gnc_tree_model_price_iter_is_price ( GncTreeModelPrice *  model,
GtkTreeIter *  iter 
)

Determine whether or not the specified GtkTreeIter points to a price.

This routine should only be called from a price tree view filter function. The model and iter values will be provided as part of the call to the filter.

Parameters
modelA pointer to the price tree model.
iterA GtkTreeIter corresponding to a single item in the model.
Returns
TRUE if the iter points to a price, FALSE otherwise.

Definition at line 256 of file gnc-tree-model-price.c.

258{
259 g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
260 g_return_val_if_fail (iter != NULL, FALSE);
261 g_return_val_if_fail (iter->user_data != NULL, FALSE);
262 g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
263
264 return (iter->user_data == ITER_IS_PRICE);
265}

◆ gnc_tree_model_price_new()

GtkTreeModel * gnc_tree_model_price_new ( QofBook book,
GNCPriceDB *  price_db 
)

Create a new GtkTreeModel for manipulating gnucash commodity prices.

Parameters
bookThe book that holds these prices.
price_dbA pointer to the price database for this tree. All namespaces and commodities in the book, and all prices in this tree will be included.

Definition at line 200 of file gnc-tree-model-price.c.

201{
202 GncTreeModelPrice *model;
203 const GList *item;
204
205 ENTER(" ");
206
207 item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_PRICE_NAME);
208 for ( ; item; item = g_list_next(item))
209 {
210 model = (GncTreeModelPrice *)item->data;
211 if (model->price_db == price_db)
212 {
213 g_object_ref(G_OBJECT(model));
214 LEAVE("returning existing model %p", model);
215 return GTK_TREE_MODEL(model);
216 }
217 }
218
219 model = g_object_new (GNC_TYPE_TREE_MODEL_PRICE, NULL);
220
221 model->book = book;
222 model->price_db = price_db;
223
224 model->event_handler_id =
225 qof_event_register_handler (gnc_tree_model_price_event_handler, model);
226
227 LEAVE("returning new model %p", model);
228 return GTK_TREE_MODEL (model);
229}

◆ gnc_tree_view_account_add_custom_column()

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.

This column will be visible as soon as it is added and will query the provided functions to determine what data to display. The TreeView will own the resulting TreeViewColumn, but caller may set any additional properties they wish.

Parameters
viewA pointer to an account tree view.
column_titleThe title for this new column.
source_cbA callback function that is expected to provide the data to be displayed.
edited_cbA callback function that will be called if the user edits the displayed data.

Definition at line 1971 of file gnc-tree-view-account.c.

1977{
1978 GtkCellRenderer *renderer;
1979
1980 g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view), NULL);
1981
1982 renderer = gtk_cell_renderer_text_new();
1983
1984 return gnc_tree_view_account_add_custom_column_renderer(
1985 account_view, column_title, col_source_cb, col_edited_cb, renderer);
1986}

◆ gnc_tree_view_account_add_custom_column_renderer()

GtkTreeViewColumn * gnc_tree_view_account_add_custom_column_renderer ( GncTreeViewAccount *  account_view,
const gchar *  column_title,
GncTreeViewAccountColumnSource  col_source_cb,
GncTreeViewAccountColumnTextEdited  col_edited_cb,
GtkCellRenderer *  renderer 
)

Definition at line 1989 of file gnc-tree-view-account.c.

1996{
1997 GtkTreeViewColumn *column;
1998
1999 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (account_view), NULL);
2000
2001 g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
2002
2003 column = gtk_tree_view_column_new_with_attributes (column_title,
2004 renderer, NULL);
2005 if (col_edited_cb)
2006 {
2007 gtva_setup_column_renderer_edited_cb(account_view, column,
2008 renderer, col_edited_cb);
2009 }
2010 gtk_tree_view_column_set_cell_data_func (column, renderer,
2011 col_source_helper,
2012 col_source_cb, NULL);
2013 gnc_tree_view_append_column (GNC_TREE_VIEW(account_view), column);
2014 return column;
2015}
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.

◆ gnc_tree_view_account_add_property_column()

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.

This column will be visible as soon as it is added and will display the contents of the specified account property

Parameters
viewA pointer to an account tree view.
column_titleThe title for this new column.
propnameThe g_object_property name of the desired value. This must be a string property.

Definition at line 1872 of file gnc-tree-view-account.c.

1875{
1876 GtkCellRenderer *renderer;
1877 GtkTreeViewColumn *column;
1878
1879 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1880 g_return_val_if_fail (propname != NULL, NULL);
1881
1882 column = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), column_title,
1883 propname, NULL, "Sample text",
1884 -1, -1, NULL);
1885
1886 /* This new kvp column has only had one renderer added to it so
1887 * far. Find that renderer. */
1888 renderer = gnc_tree_view_column_get_renderer(column);
1889 g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
1890
1891 // add a pointer to the view to make it easier to access in data_func
1892 g_object_set_data(G_OBJECT(column), "tree-view", (gpointer)view);
1893
1894 gtk_tree_view_column_set_cell_data_func (column, renderer,
1895 account_cell_property_data_func,
1896 g_strdup(propname), g_free);
1897 return column;
1898}
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
Return the "main" cell renderer from a GtkTreeViewColumn added to a GncTreeView my one of the conveni...
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text column to a GncTreeView base view.

◆ gnc_tree_view_account_clear_model_cache()

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.

Parameters
viewA pointer to an account tree view.

Definition at line 1194 of file gnc-tree-view-account.c.

1195{
1196 GtkTreeModel *model, *f_model, *s_model;
1197
1198 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
1199 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(s_model));
1200 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(f_model));
1201
1202 gnc_tree_model_account_clear_cache (GNC_TREE_MODEL_ACCOUNT(model));
1203}
void gnc_tree_model_account_clear_cache(GncTreeModelAccount *model)
Clear the tree model account cached values.

◆ gnc_tree_view_account_code_edited_cb()

void gnc_tree_view_account_code_edited_cb ( Account account,
GtkTreeViewColumn *  col,
const gchar *  new_code 
)

Definition at line 2733 of file gnc-tree-view-account.c.

2734{
2735 if (g_strcmp0(xaccAccountGetCode(account), new_code) == 0)
2736 return;
2737 xaccAccountSetCode(account, new_code);
2738}
void xaccAccountSetCode(Account *acc, const char *str)
Set the account's accounting code.
Definition Account.cpp:2478
const char * xaccAccountGetCode(const Account *acc)
Get the account's accounting code.
Definition Account.cpp:3336

◆ gnc_tree_view_account_column_add_color()

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 column background in the account color.

Definition at line 740 of file gnc-tree-view-account.c.

741{
742 GtkCellRenderer *renderer = gnc_tree_view_column_get_renderer(col);
743
744 gtk_tree_view_column_set_cell_data_func (col, renderer, acc_color_data_func,
745 GTK_TREE_VIEW(view), NULL);
746}

◆ gnc_tree_view_account_count_children()

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.

Parameters
viewA pointer to an account tree view.
accountA pointer to the account to check.
Returns
The number of children of the specified account. Returns 0 on error.

Definition at line 1165 of file gnc-tree-view-account.c.

1167{
1168 GtkTreeModel *s_model;
1169 GtkTreeIter s_iter;
1170 gint num_children;
1171
1172 ENTER("view %p, account %p (%s)", view, account, xaccAccountGetName(account));
1173
1174 if (account == NULL)
1175 {
1176 LEAVE("no account");
1177 return 0;
1178 }
1179
1180 if (!gnc_tree_view_account_get_iter_from_account (view, account, &s_iter))
1181 {
1182 LEAVE("view_get_iter_from_account failed");
1183 return 0;
1184 }
1185
1186 /* Any children? */
1187 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1188 num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
1189 LEAVE("%d children", num_children);
1190 return num_children;
1191}

◆ gnc_tree_view_account_description_edited_cb()

void gnc_tree_view_account_description_edited_cb ( Account account,
GtkTreeViewColumn *  col,
const gchar *  new_desc 
)

Definition at line 2741 of file gnc-tree-view-account.c.

2742{
2743 if (g_strcmp0(xaccAccountGetDescription(account), new_desc) == 0)
2744 return;
2745 xaccAccountSetDescription(account, new_desc);
2746}
const char * xaccAccountGetDescription(const Account *acc)
Get the account's description.
Definition Account.cpp:3343
void xaccAccountSetDescription(Account *acc, const char *str)
Set the account's description.
Definition Account.cpp:2497

◆ gnc_tree_view_account_expand_to_account()

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 account visible.

Parameters
viewA pointer to an account tree view.
accountA pointer to the account to show.

Definition at line 1738 of file gnc-tree-view-account.c.

1740{
1741 GtkTreePath *path;
1742
1743 g_return_if_fail(view != NULL);
1744 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1745 ENTER("view %p, account %p", view, account);
1746
1747 path = gnc_tree_view_account_get_path_from_account(view, account);
1748 if (path)
1749 {
1750 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1751 gtk_tree_path_free(path);
1752 }
1753 LEAVE(" ");
1754}

◆ gnc_tree_view_account_filter_by_view_info()

gboolean gnc_tree_view_account_filter_by_view_info ( Account acct,
gpointer  data 
)

Definition at line 1309 of file gnc-tree-view-account.c.

1310{
1311 GNCAccountType acct_type;
1312 AccountViewInfo* avi = (AccountViewInfo*)data;
1313
1314 g_return_val_if_fail(GNC_IS_ACCOUNT(acct), FALSE);
1315 acct_type = xaccAccountGetType(acct);
1316
1317 if (!avi->include_type[acct_type]) return FALSE;
1318 if (!avi->show_hidden && xaccAccountIsHidden(acct)) return FALSE;
1319 return TRUE;
1320}

◆ gnc_tree_view_account_get_account_from_iter()

Account * gnc_tree_view_account_get_account_from_iter ( GtkTreeModel *  model,
GtkTreeIter *  iter 
)

This function returns the account associated with the specified iter.

This function is useful in selection callbacks on an account tree widget.

Parameters
modelThe model provided to the callback function.
iterThe iter provided to the callback function.
Returns
The account associated with this iter.

Definition at line 1377 of file gnc-tree-view-account.c.

1379{
1380 GtkTreeModel *model, *f_model;
1381 GtkTreeIter iter, f_iter;
1382 Account *account;
1383
1384 g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1385 g_return_val_if_fail (s_iter != NULL, NULL);
1386
1387 ENTER("model %p, iter %p", s_model, s_iter);
1388
1389 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1390 &f_iter,
1391 s_iter);
1392 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1393 gtk_tree_model_filter_convert_iter_to_child_iter (
1394 GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1395 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1397 GNC_TREE_MODEL_ACCOUNT(model), &iter);
1398 LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1399 return account;
1400}
Account * gnc_tree_model_account_get_account(GncTreeModelAccount *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash account.

◆ gnc_tree_view_account_get_account_from_path()

Account * gnc_tree_view_account_get_account_from_path ( GncTreeViewAccount *  view,
GtkTreePath *  path 
)

This function returns the account associated with the specified path.

This function is useful in selection callbacks on an account tree widget.

Parameters
viewA pointer to an account tree view.
pathA path specifying a node in the account tree.
Returns
The account associated with this path.

Definition at line 1331 of file gnc-tree-view-account.c.

1333{
1334 GtkTreeModel *model, *f_model, *s_model;
1335 GtkTreePath *path, *f_path;
1336 GtkTreeIter iter;
1337 Account *account;
1338
1339 ENTER("view %p", view);
1340 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1341 g_return_val_if_fail (s_path != NULL, NULL);
1342
1343 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1344 f_path = gtk_tree_model_sort_convert_path_to_child_path (
1345 GTK_TREE_MODEL_SORT (s_model), s_path);
1346 if (!f_path)
1347 {
1348 LEAVE("no filter path");
1349 return NULL;
1350 }
1351
1352 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1353 path = gtk_tree_model_filter_convert_path_to_child_path (
1354 GTK_TREE_MODEL_FILTER (f_model), f_path);
1355 gtk_tree_path_free(f_path);
1356 if (!path)
1357 {
1358 LEAVE("no path");
1359 return NULL;
1360 }
1361
1362 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1363 if (!gtk_tree_model_get_iter (model, &iter, path))
1364 {
1365 LEAVE("no iter");
1366 return NULL;
1367 }
1368
1369 account = iter.user_data;
1370 gtk_tree_path_free(path);
1371 LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1372 return account;
1373}

◆ gnc_tree_view_account_get_cursor_account()

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.

(The outline frame. Usually is selected and therefore filled in, but not always.)

Parameters
viewA pointer to an account tree view.
Returns
The account at the cursor.

Definition at line 1761 of file gnc-tree-view-account.c.

1762{
1763 GtkTreePath *s_path;
1764 Account *account;
1765
1766 ENTER("view %p", view);
1767 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1768
1769 gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1770 if (!s_path)
1771 {
1772 LEAVE("no account");
1773 return NULL;
1774 }
1775
1776 account = gnc_tree_view_account_get_account_from_path (view, s_path);
1777 gtk_tree_path_free(s_path);
1778 LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1779 return account;
1780}
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
This function returns the account associated with the specified path.

◆ gnc_tree_view_account_get_selected_account()

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.

Note
It only makes sense to call this function when the account tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an account tree view.
Returns
The selected account, or NULL if no account was selected.

Definition at line 1408 of file gnc-tree-view-account.c.

1409{
1410 GtkTreeSelection *selection;
1411 GtkTreeModel *f_model, *s_model;
1412 GtkTreeIter iter, f_iter, s_iter;
1413 Account *account;
1414 GtkSelectionMode mode;
1415
1416 ENTER("view %p", view);
1417 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1418
1419 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1420 mode = gtk_tree_selection_get_mode(selection);
1421 if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
1422 {
1423 return NULL;
1424 }
1425 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
1426 {
1427 LEAVE("no account, get_selected failed");
1428 return FALSE;
1429 }
1430
1431 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1432 &f_iter, &s_iter);
1433
1434 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1435 gtk_tree_model_filter_convert_iter_to_child_iter (
1436 GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
1437
1438 account = iter.user_data;
1439 LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1440 return account;
1441}

◆ gnc_tree_view_account_get_selected_accounts()

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 view.

Note
It only makes sense to call this function when the account tree is set to select multiple items. There is a different function to use when the tree supports single selection.
Parameters
viewA pointer to an account tree view.
Returns
A list of accounts, or NULL if no account was selected.

Definition at line 1566 of file gnc-tree-view-account.c.

1567{
1568 GtkTreeSelection *selection;
1570
1571 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1572
1573 info.return_list = NULL;
1574 info.view = view;
1575 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1576 gtk_tree_selection_selected_foreach(selection, get_selected_accounts_helper, &info);
1577 info.return_list = g_list_reverse (info.return_list);
1578 return info.return_list;
1579}

◆ gnc_tree_view_account_get_view_info()

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 configuration of the account tree widget into the data block.

This may be used in conjunction with the gnc_tree_view_account_set_view_info function to modify the filters on an existing account tree.

Parameters
account_viewA pointer to an account tree view.
aviA pointer to an old style filter block to fill in.

Definition at line 1214 of file gnc-tree-view-account.c.

1216{
1217 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1218 g_return_if_fail(avi != NULL);
1219
1220 *avi = view->avi;
1221}

◆ gnc_tree_view_account_name_edited_cb()

void gnc_tree_view_account_name_edited_cb ( Account account,
GtkTreeViewColumn *  col,
const gchar *  new_name 
)

Definition at line 2715 of file gnc-tree-view-account.c.

2716{
2717 // check for accounts with the same name among our parent's children.
2718 // should probably factor this consistency check out to the account
2719 // itself....
2720 {
2721 Account *parent = gnc_account_get_parent(account);
2722 Account *existing = gnc_account_lookup_by_name(parent, new_name);
2723 if (existing != NULL && existing != account)
2724 {
2725 PERR("account with the same name [%s] already exists.", new_name);
2726 return;
2727 }
2728 }
2729 xaccAccountSetName(account, new_name);
2730}
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
Definition Account.cpp:2458
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the s...
Definition Account.cpp:3093

◆ gnc_tree_view_account_new()

GtkTreeView * gnc_tree_view_account_new ( gboolean  show_root)

Create a new account tree view.

This view may or may not show a pseudo top-level account. The gnucash engine does not have a single top level account (it has a list of top level accounts), but this code provides one so that it can be used with all parts of the gnucash gui. The first level of accounts in the created tree will be the top level of accounts in the current book.

Parameters
show_rootShow the pseudo top-level account in this view.
Returns
A pointer to a new account tree view.

Definition at line 1070 of file gnc-tree-view-account.c.

1071{
1072 Account *root;
1073
1074 root = gnc_book_get_root_account (gnc_get_current_book ());
1075 return gnc_tree_view_account_new_with_root (root, show_root);
1076}
GtkTreeView * gnc_tree_view_account_new_with_root(Account *root, gboolean show_root)
Create a new account tree view.

◆ gnc_tree_view_account_new_with_root()

GtkTreeView * gnc_tree_view_account_new_with_root ( Account root,
gboolean  show_root 
)

Create a new account tree view.

This view may or may not show a pseudo top-level account. The gnucash engine does not have a single top level account (it has a list of top level accounts), but this code provides one so that it can be used with all parts of the gnucash gui.

Parameters
rootThe account to use as the first level of the created tree.
show_rootShow the pseudo top-level account in this view.
Returns
A pointer to a new account tree view.

Definition at line 759 of file gnc-tree-view-account.c.

760{
761 GtkTreeModel *model, *f_model, *s_model;
762 GtkTreePath *virtual_root_path = NULL;
763 const gchar *sample_type, *sample_commodity;
764 GtkTreeViewColumn *tax_info_column, *acc_color_column, *acc_balance_limit_column;
765 GtkCellRenderer *renderer;
766 GList *col_list = NULL, *node = NULL;
767
768 ENTER(" ");
769 /* Create our view */
770 GncTreeViewAccount *view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT,
771 "has-tooltip", true,
772 "name", "gnc-id-account-tree", NULL);
773
774 /* Get the show_account_color value from gsettings */
775 view->show_account_color = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_COLOR);
776
777 /* Create/get a pointer to the existing model for this set of books. */
778 model = gnc_tree_model_account_new (root);
779
780 /* Set up the view private filter layer on the common model. */
781 if (!show_root)
782 virtual_root_path = gtk_tree_path_new_first ();
783 f_model = gtk_tree_model_filter_new (model, virtual_root_path);
784 /* A GncTreeModelAccount is based on a GncTreeModel, which is a
785 * GObject that provides a GtkTreeModel interface. */
786 g_object_unref(G_OBJECT(model));
787 if (virtual_root_path)
788 gtk_tree_path_free(virtual_root_path);
789
790 /* Set up the view private sort layer on the common model. */
791 s_model = gtk_tree_model_sort_new_with_model(f_model);
792 g_object_unref(G_OBJECT(f_model));
793 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
794 g_object_unref(G_OBJECT(s_model));
795
796 /* Set default visibilities */
797 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
798
799 sample_type = xaccAccountGetTypeStr(ACCT_TYPE_CREDIT);
801
802 view->name_column
803 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Account Name"), "name",
804 GNC_ICON_ACCOUNT, "Expenses:Entertainment",
805 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
806 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
807 sort_by_string);
808
809 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Type"), "type", NULL, sample_type,
810 GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
811 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
812 sort_by_string);
813
814 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Commodity"), "commodity", NULL,
815 sample_commodity,
816 GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
817 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
818 sort_by_string);
819 view->code_column
820 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Account Code"), "account-code", NULL,
821 "1-123-1234",
822 GNC_TREE_MODEL_ACCOUNT_COL_CODE,
823 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
824 sort_by_code);
825 view->desc_column
826 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Description"), "description", NULL,
827 "Sample account description.",
828 GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
829 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
830 sort_by_string);
831
832 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Last Num"), "lastnum", "12345",
833 GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
834 GNC_TREE_VIEW_COLUMN_COLOR_NONE,
835 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
836 sort_by_string);
837
838 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Present"), "present",
839 SAMPLE_ACCOUNT_VALUE,
840 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
841 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
842 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
843 sort_by_present_value);
844 view->present_report_column
845 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Present (Report)"), "present_report",
846 SAMPLE_ACCOUNT_VALUE,
847 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
848 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
849 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
850 sort_by_present_value);
851
852 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Balance"), "balance",
853 SAMPLE_ACCOUNT_VALUE,
854 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
855 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
856 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
857 sort_by_balance_value);
858 view->balance_report_column
859 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Balance (Report)"), "balance_report",
860 SAMPLE_ACCOUNT_VALUE,
861 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
862 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
863 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
864 sort_by_balance_value);
865
866 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Balance (Period)"), "balance-period",
867 SAMPLE_ACCOUNT_VALUE,
868 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD,
869 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
870 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
871 sort_by_balance_period_value);
872
873 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Cleared"), "cleared",
874 SAMPLE_ACCOUNT_VALUE,
875 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
876 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
877 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
878 sort_by_cleared_value);
879 view->cleared_report_column
880 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Cleared (Report)"), "cleared_report",
881 SAMPLE_ACCOUNT_VALUE,
882 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
883 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
884 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
885 sort_by_cleared_value);
886
887 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Reconciled"), "reconciled",
888 SAMPLE_ACCOUNT_VALUE,
889 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
890 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
891 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
892 sort_by_reconciled_value);
893 view->reconciled_report_column
894 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Reconciled (Report)"), "reconciled_report",
895 SAMPLE_ACCOUNT_VALUE,
896 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
897 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
898 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
899 sort_by_reconciled_value);
900
901 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Earliest Date"), "earliest-date", NULL,
902 "31 December 2000",
903 GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE,
904 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
905 sort_by_earliest_date);
906
907 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Last Reconcile Date"), "last-recon-date", NULL,
908 "Last Reconcile Date",
909 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
910 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
911 sort_by_last_reconcile_date);
912
913 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Future Minimum"), "future_min",
914 SAMPLE_ACCOUNT_VALUE,
915 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
916 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
917 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
918 sort_by_future_min_value);
919 view->future_min_report_column
920 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Future Minimum (Report)"), "future_min_report",
921 SAMPLE_ACCOUNT_VALUE,
922 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
923 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
924 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
925 sort_by_future_min_value);
926
927 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Total"), "total",
928 SAMPLE_ACCOUNT_VALUE,
929 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
930 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
931 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
932 sort_by_total_value);
933 view->total_report_column
934 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Total (Report)"), "total_report",
935 SAMPLE_ACCOUNT_VALUE,
936 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
937 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
938 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
939 sort_by_total_value);
940
941 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Total (Period)"), "total-period",
942 SAMPLE_ACCOUNT_VALUE,
943 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
944 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
945 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
946 sort_by_total_period_value);
947
948 /* Translators: The C is the column title and stands for Color, this should be one character */
949 acc_color_column
950 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), C_("Column header for 'Color'", "C"), "account-color", NULL,
951 "xx",
952 GNC_TREE_VIEW_COLUMN_DATA_NONE,
953 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
954 NULL);
955
956 /* Add the full title to the object for menu creation */
957 g_object_set_data_full(G_OBJECT(acc_color_column), REAL_TITLE,
958 g_strdup(_("Account Color")), g_free);
959
960 /* Also add the full title to the column header as a tooltip */
961 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_color_column), _("Account Color"));
962
963 acc_balance_limit_column
964 = gnc_tree_view_add_pix_column (GNC_TREE_VIEW(view),
965 C_("Column header for 'Balance Limit'", "L"),
966 "account-balance-limit",
967 "xx",
968 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT,
969 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
970 NULL);
971
972 /* Add the full title to the object for menu creation */
973 g_object_set_data_full(G_OBJECT(acc_balance_limit_column), REAL_TITLE,
974 g_strdup(_("Balance Limit")), g_free);
975
976 /* Also add the full title to the column header as a tooltip */
977 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_balance_limit_column), _("Balance Limit"));
978
979 view->notes_column
980 = gnc_tree_view_add_text_view_column(GNC_TREE_VIEW(view), _("Notes"), "notes", NULL,
981 "Sample account notes.",
982 GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
983 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
984 sort_by_string);
985
986 tax_info_column
987 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Tax Info"), "tax-info", NULL,
988 "Sample tax info.",
989 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
990 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
991 sort_by_string);
992
993 renderer = gnc_tree_view_column_get_renderer(tax_info_column);
994 gtk_tree_view_column_set_cell_data_func(tax_info_column,
995 renderer,
996 tax_info_data_func,
997 GTK_TREE_VIEW(view),
998 NULL);
999
1000 gnc_tree_view_add_toggle_column (GNC_TREE_VIEW(view), _("Hidden"),
1001 C_("Column header for 'Hidden'", "H"),
1002 "hidden",
1003 GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
1004 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1005 sort_by_hidden,
1006 gnc_tree_view_account_hidden_toggled);
1007
1008 gnc_tree_view_add_toggle_column(GNC_TREE_VIEW(view), _("Placeholder"),
1009 C_("Column header for 'Placeholder'", "P"),
1010 "placeholder",
1011 GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
1012 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1013 sort_by_placeholder,
1014 gnc_tree_view_account_placeholder_toggled);
1015
1016 gnc_tree_view_add_toggle_column(GNC_TREE_VIEW(view), _("Opening Balance"),
1017 C_("Column header for 'Opening Balance'", "O"),
1018 "opening-balance",
1019 GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE,
1020 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1021 sort_by_opening_balance,
1022 NULL);
1023
1024 /* Add function to each column that optionally sets a background color for accounts */
1025 col_list = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
1026 for (node = col_list; node; node = node->next)
1027 {
1028 renderer = gnc_tree_view_column_get_renderer(node->data);
1029 gtk_tree_view_column_set_cell_data_func(node->data,
1030 renderer,
1031 acc_color_data_func,
1032 GTK_TREE_VIEW(view),
1033 NULL);
1034 }
1035 g_list_free (col_list);
1036
1037 /* Update column titles to use the currency name. */
1038 gtva_update_column_names(view);
1039
1040 /* By default only the first column is visible. */
1041 gnc_tree_view_configure_columns(GNC_TREE_VIEW(view));
1042 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
1043 gnc_tree_view_account_filter_helper,
1044 view,
1045 NULL);
1046
1047 /* Default the sorting to account name */
1048 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
1049 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
1050 GTK_SORT_ASCENDING);
1051
1052 /* Set account find-as-you-type search function */
1053 gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(view), gnc_tree_view_search_compare, NULL, NULL);
1054
1055 g_signal_connect (G_OBJECT(view), "query-tooltip",
1056 G_CALLBACK(gnc_tree_view_tooltip_cb), NULL);
1057
1058 gtk_widget_show(GTK_WIDGET(view));
1059 LEAVE("%p", view);
1060 return GTK_TREE_VIEW(view);
1061}
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
Definition Account.cpp:4357
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting,...
GtkTreeViewColumn * gnc_tree_view_add_toggle_column(GncTreeView *view, const gchar *column_title, const gchar *column_short_title, const gchar *pref_name, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn, renderer_toggled toggle_edited_cb)
This function adds a new toggle column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_add_numeric_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_color_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new numeric column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_add_text_view_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text view column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_add_pix_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new pixbuf view column to a GncTreeView base view.
GtkTreeModel * gnc_tree_model_account_new(Account *root)
Create a new GtkTreeModel for manipulating gnucash accounts.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_tree_view_account_notes_edited_cb()

void gnc_tree_view_account_notes_edited_cb ( Account account,
GtkTreeViewColumn *  col,
const gchar *  new_notes 
)

Definition at line 2749 of file gnc-tree-view-account.c.

2750{
2751 if (g_strcmp0(xaccAccountGetNotes(account), new_notes) == 0)
2752 return;
2753 xaccAccountSetNotes(account, new_notes);
2754}
void xaccAccountSetNotes(Account *acc, const char *str)
Set the account's notes.
Definition Account.cpp:2655
const char * xaccAccountGetNotes(const Account *acc)
Get the account's notes.
Definition Account.cpp:3374

◆ gnc_tree_view_account_refilter()

void gnc_tree_view_account_refilter ( GncTreeViewAccount *  view)

This function forces the account tree filter to be evaluated.

It may be necessary to call this function if the initial state of the view is incorrect. This appears to only be necessary if the filter affects one of the top level accounts in gnucash.

Note
This calls a function in gtk that is annotated in the sources as being slow. You have been warned.
Parameters
viewA pointer to an account tree view.

Definition at line 1297 of file gnc-tree-view-account.c.

1298{
1299 GtkTreeModel *f_model, *s_model;
1300
1301 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1302
1303 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1304 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1305 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
1306}

◆ gnc_tree_view_account_restore()

void gnc_tree_view_account_restore ( GncTreeViewAccount *  view,
AccountFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name 
)

Definition at line 2564 of file gnc-tree-view-account.c.

2567{
2568 GError *error = NULL;
2569 gchar *key, *value;
2570 gint i, count;
2571 gboolean show;
2572
2573 /* Filter information. Ignore missing keys. */
2574 show = g_key_file_get_boolean(key_file, group_name, SHOW_HIDDEN, &error);
2575 if (error)
2576 {
2577 g_warning("error reading group %s key %s: %s",
2578 group_name, SHOW_HIDDEN, error->message);
2579 g_error_free(error);
2580 error = NULL;
2581 show = TRUE;
2582 }
2583 fd->show_hidden = show;
2584
2585 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO, &error);
2586 if (error)
2587 {
2588 g_warning("error reading group %s key %s: %s",
2589 group_name, SHOW_ZERO, error->message);
2590 g_error_free(error);
2591 error = NULL;
2592 show = TRUE;
2593 }
2594 fd->show_zero_total = show;
2595
2596 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED, &error);
2597 if (error)
2598 {
2599 g_warning("error reading group %s key %s: %s",
2600 group_name, SHOW_UNUSED, error->message);
2601 g_error_free(error);
2602 error = NULL;
2603 show = TRUE;
2604 }
2605 fd->show_unused = show;
2606
2607 i = g_key_file_get_integer(key_file, group_name, ACCT_TYPES, &error);
2608 if (error)
2609 {
2610 g_warning("error reading group %s key %s: %s",
2611 group_name, ACCT_TYPES, error->message);
2612 g_error_free(error);
2613 error = NULL;
2614 i = -1;
2615 }
2616 fd->visible_types = i;
2617
2618 /* Expanded accounts. Skip if count key missing. */
2619 count = g_key_file_get_integer(key_file, group_name, ACCT_COUNT, &error);
2620 if (error == NULL)
2621 {
2622 for (i = 1; i <= count; i++)
2623 {
2624 key = g_strdup_printf(ACCT_OPEN, i);
2625 value = g_key_file_get_string(key_file, group_name, key, &error);
2626 if (error)
2627 {
2628 g_warning("error reading group %s key %s: %s",
2629 group_name, key, error->message);
2630 g_error_free(error);
2631 error = NULL;
2632 }
2633 else
2634 {
2635 tree_restore_expanded_row(view, value);
2636 g_free(value);
2637 }
2638 g_free(key);
2639 }
2640 }
2641 else
2642 {
2643 g_warning("error reading group %s key %s: %s",
2644 group_name, ACCT_COUNT, error->message);
2645 g_error_free(error);
2646 }
2647
2648 /* Selected account (if any) */
2649 value = g_key_file_get_string(key_file, group_name, ACCT_SELECTED, NULL);
2650 if (value)
2651 {
2652 tree_restore_selected_row(view, value);
2653 g_free(value);
2654 }
2655
2656 /* Update tree view for any changes */
2658}
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.

◆ gnc_tree_view_account_restore_filter()

void gnc_tree_view_account_restore_filter ( GncTreeViewAccount *  view,
AccountFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name 
)

Definition at line 2661 of file gnc-tree-view-account.c.

2665{
2666 GError *error = NULL;
2667 gint i;
2668 gboolean show;
2669
2670 g_return_if_fail (key_file != NULL);
2671 g_return_if_fail (group_name != NULL);
2672
2673 /* if entry not found, filter will use the default setting */
2674
2675 /* Filter information. Ignore missing keys. */
2676 show = g_key_file_get_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS, &error);
2677 if (error)
2678 {
2679 g_error_free (error);
2680 error = NULL;
2681 }
2682 else
2683 fd->show_hidden = show;
2684
2685 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO_TOTALS, &error);
2686 if (error)
2687 {
2688 g_error_free (error);
2689 error = NULL;
2690 }
2691 else
2692 fd->show_zero_total = show;
2693
2694 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED_ACCOUNTS, &error);
2695 if (error)
2696 {
2697 g_error_free (error);
2698 error = NULL;
2699 }
2700 else
2701 fd->show_unused = show;
2702
2703 i = g_key_file_get_integer(key_file, group_name, ACCOUNT_TYPES, &error);
2704 if (error)
2705 {
2706 g_error_free (error);
2707 error = NULL;
2708 }
2709 else
2710 fd->visible_types = i;
2711}

◆ gnc_tree_view_account_save()

void gnc_tree_view_account_save ( GncTreeViewAccount *  tree_view,
AccountFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name 
)

Definition at line 2462 of file gnc-tree-view-account.c.

2465{
2466 bar_t bar;
2467
2468 g_return_if_fail (key_file != NULL);
2469 g_return_if_fail (group_name != NULL);
2470
2471 ENTER("view %p, key_file %p, group_name %s", view, key_file,
2472 group_name);
2473
2474 g_key_file_set_integer(key_file, group_name, ACCT_TYPES,
2475 fd->visible_types);
2476 g_key_file_set_boolean(key_file, group_name, SHOW_HIDDEN,
2477 fd->show_hidden);
2478 g_key_file_set_boolean(key_file, group_name, SHOW_ZERO,
2479 fd->show_zero_total);
2480 g_key_file_set_boolean(key_file, group_name, SHOW_UNUSED,
2481 fd->show_unused);
2482
2483 bar.key_file = key_file;
2484 bar.group_name = group_name;
2485 bar.count = 0;
2486 tree_save_selected_row(view, &bar);
2487 gtk_tree_view_map_expanded_rows(
2488 GTK_TREE_VIEW(view), (GtkTreeViewMappingFunc) tree_save_expanded_row,
2489 &bar);
2490 g_key_file_set_integer(key_file, group_name, ACCT_COUNT, bar.count);
2491 LEAVE(" ");
2492
2493}

◆ gnc_tree_view_account_save_filter()

void gnc_tree_view_account_save_filter ( GncTreeViewAccount *  tree_view,
AccountFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name 
)

Definition at line 2496 of file gnc-tree-view-account.c.

2500{
2501 g_return_if_fail (key_file != NULL);
2502 g_return_if_fail (group_name != NULL);
2503
2504 ENTER("view %p, key_file %p, group_name %s", view, key_file,
2505 group_name);
2506
2507 g_key_file_set_integer (key_file, group_name, ACCOUNT_TYPES,
2508 fd->visible_types);
2509 g_key_file_set_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS,
2510 fd->show_hidden);
2511 g_key_file_set_boolean (key_file, group_name, SHOW_ZERO_TOTALS,
2512 fd->show_zero_total);
2513 g_key_file_set_boolean (key_file, group_name, SHOW_UNUSED_ACCOUNTS,
2514 fd->show_unused);
2515 LEAVE("");
2516}

◆ gnc_tree_view_account_select_subaccounts()

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.

All other accounts will be unselected.

Note
It only makes sense to call this function when the account tree is set to select multiple items. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an account tree view.
accountA pointer to the account whose children should be selected.

Definition at line 1666 of file gnc-tree-view-account.c.

1668{
1669 GtkTreeModel *s_model;
1670 GtkTreeSelection *selection;
1671 GtkTreePath *sp_account, *sp_start, *sp_end;
1672 GtkTreeIter si_account, si_start, si_end;
1673 gboolean have_start, have_end = FALSE;
1674 gint num_children;
1675
1676 ENTER("view %p, account %p (%s)", view, account, xaccAccountGetName(account));
1677
1678 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1679
1680 if (account == NULL)
1681 {
1682 LEAVE("no account");
1683 return;
1684 }
1685
1686 if (!gnc_tree_view_account_get_iter_from_account (view, account, &si_account))
1687 {
1688 LEAVE("view_get_iter_from_account failed");
1689 return;
1690 }
1691
1692 /* Any children? */
1693 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1694 num_children = gtk_tree_model_iter_n_children(s_model, &si_account);
1695 if (num_children == 0)
1696 {
1697 LEAVE("no children");
1698 return;
1699 }
1700
1701 /* Expand the tree. Required for selection to work */
1702 sp_account = gtk_tree_model_get_path (s_model, &si_account);
1703 gtk_tree_view_expand_row (GTK_TREE_VIEW(view), sp_account, TRUE);
1704
1705 /* compute start/end paths */
1706 have_start = gtk_tree_model_iter_nth_child(s_model, &si_start, &si_account, 0);
1707 si_end = si_account;
1708 while (num_children)
1709 {
1710 GtkTreeIter tmp_iter = si_end;
1711 have_end = gtk_tree_model_iter_nth_child(s_model, &si_end, &tmp_iter,
1712 num_children - 1);
1713 if (have_end)
1714 num_children = gtk_tree_model_iter_n_children(s_model, &si_end);
1715 else
1716 num_children = 0;
1717 }
1718
1719 if (have_start && have_end)
1720 {
1721 sp_start = gtk_tree_model_get_path (s_model, &si_start);
1722 sp_end = gtk_tree_model_get_path (s_model, &si_end);
1723
1724 /* select everything between */
1725 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1726 gtk_tree_selection_select_range (selection, sp_start, sp_end);
1727
1728 /* clean up */
1729 gtk_tree_path_free(sp_start);
1730 gtk_tree_path_free(sp_end);
1731 }
1732 gtk_tree_path_free(sp_account);
1733 LEAVE(" ");
1734 return;
1735}

◆ gnc_tree_view_account_set_code_edited()

void gnc_tree_view_account_set_code_edited ( GncTreeViewAccount *  view,
GncTreeViewAccountColumnTextEdited  edited_cb 
)

Definition at line 2784 of file gnc-tree-view-account.c.

2786{
2787 gtva_set_column_editor(view, view->code_column, edited_cb);
2788}

◆ gnc_tree_view_account_set_description_edited()

void gnc_tree_view_account_set_description_edited ( GncTreeViewAccount *  view,
GncTreeViewAccountColumnTextEdited  edited_cb 
)

Definition at line 2791 of file gnc-tree-view-account.c.

2793{
2794 gtva_set_column_editor(view, view->desc_column, edited_cb);
2795}

◆ gnc_tree_view_account_set_editing_finished_cb()

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 the delete menu option as required.

Definition at line 2870 of file gnc-tree-view-account.c.

2872{
2873 gnc_tree_view_set_editing_finished_cb (GNC_TREE_VIEW(view),
2874 editing_finished_cb, editing_cb_data);
2875}
void gnc_tree_view_set_editing_finished_cb(GncTreeView *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup a callback for when the user finishes editing so appropriate actions can be taken like enable t...

◆ gnc_tree_view_account_set_editing_started_cb()

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 the delete menu option as required.

Definition at line 2863 of file gnc-tree-view-account.c.

2865{
2866 gnc_tree_view_set_editing_started_cb (GNC_TREE_VIEW(view),
2867 editing_started_cb, editing_cb_data);
2868}
void gnc_tree_view_set_editing_started_cb(GncTreeView *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup a callback for when the user starts editing so appropriate actions can be taken like disable th...

◆ gnc_tree_view_account_set_filter()

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.

This function will be called for each account that the view thinks should possibly show. The filter may perform any actions necessary on the account to decide whether it should be shown or not. (I.E. Check type, placeholder status, etc.) If the filter returns TRUE then the account will be displayed.

Parameters
account_viewA pointer to an account tree view.
funcA filtration function that is called on individual elements in the tree. If this function returns TRUE, the account will be displayed.
dataA data block passed into each instance of the function.
destroyA function to destroy the data block. This function will be called when the filter is destroyed. may be NULL.

Definition at line 1271 of file gnc-tree-view-account.c.

1275{
1276 ENTER("view %p, filter func %p, data %p, destroy %p",
1277 view, func, data, destroy);
1278
1279 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1280
1281 if (view->filter_destroy)
1282 {
1283 view->filter_destroy(view->filter_data);
1284 }
1285 view->filter_destroy = destroy;
1286 view->filter_data = data;
1287 view->filter_fn = func;
1288
1290 LEAVE(" ");
1291}

◆ gnc_tree_view_account_set_name_edited()

void gnc_tree_view_account_set_name_edited ( GncTreeViewAccount *  view,
GncTreeViewAccountColumnTextEdited  edited_cb 
)

Definition at line 2777 of file gnc-tree-view-account.c.

2779{
2780 gtva_set_column_editor(view, view->name_column, edited_cb);
2781}

◆ gnc_tree_view_account_set_notes_edited()

void gnc_tree_view_account_set_notes_edited ( GncTreeViewAccount *  view,
GncTreeViewAccountColumnTextEdited  edited_cb 
)

Definition at line 2798 of file gnc-tree-view-account.c.

2800{
2801 gtva_set_column_editor(view, view->notes_column, edited_cb);
2802}

◆ gnc_tree_view_account_set_selected_account()

void gnc_tree_view_account_set_selected_account ( GncTreeViewAccount *  view,
Account account 
)

This function selects an account in the account tree view.

All other accounts will be unselected. In addition, this function collapses the entire tree and then expands only the path to the selected account, making the item easy to find. In general, this routine only need be called when initially putting up a window containing an account tree view widget.

Note
It only makes sense to call this function when the account tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an account tree view.
accountA pointer to the account to select.

Definition at line 1448 of file gnc-tree-view-account.c.

1450{
1451 GtkTreeModel *model, *f_model, *s_model;
1452 GtkTreePath *path, *f_path, *s_path, *parent_path;
1453 GtkTreeSelection *selection;
1454
1455 ENTER("view %p, account %p (%s)", view,
1456 account, xaccAccountGetName (account));
1457 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1458
1459 /* Clear any existing selection. */
1460 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1461 gtk_tree_selection_unselect_all (selection);
1462
1463 if (account == NULL)
1464 return;
1465
1466 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1467 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1468 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1469
1471 GNC_TREE_MODEL_ACCOUNT(model), account);
1472 if (path == NULL)
1473 {
1474 LEAVE("no path");
1475 return;
1476 }
1477 debug_path(DEBUG, path);
1478
1479 f_path = gtk_tree_model_filter_convert_child_path_to_path (
1480 GTK_TREE_MODEL_FILTER (f_model), path);
1481 gtk_tree_path_free(path);
1482 if (f_path == NULL)
1483 {
1484 LEAVE("no filter path");
1485 return;
1486 }
1487 debug_path(DEBUG, f_path);
1488
1489 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1490 f_path);
1491 gtk_tree_path_free(f_path);
1492 if (s_path == NULL)
1493 {
1494 LEAVE("no sort path");
1495 return;
1496 }
1497
1498 /* gtk_tree_view requires that a row be visible before it can be selected */
1499 parent_path = gtk_tree_path_copy (s_path);
1500 if (gtk_tree_path_up (parent_path))
1501 {
1502 /* This function is misnamed. It expands the actual item
1503 * specified, not the path to the item specified. I.E. It expands
1504 * one level too many, thus the get of the parent. */
1505 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1506 }
1507 gtk_tree_path_free(parent_path);
1508
1509 gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), s_path, 0, FALSE);
1510
1511 /* give gtk+ a chance to resize the tree view first by handling pending
1512 * configure events */
1513 while (gtk_events_pending ())
1514 gtk_main_iteration ();
1515 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1516 debug_path(LEAVE, s_path);
1517 gtk_tree_path_free(s_path);
1518}
GtkTreePath * gnc_tree_model_account_get_path_from_account(GncTreeModelAccount *model, Account *account)
Convert a model/account pair into a gtk_tree_model_path.
#define DEBUG(format, args...)
Print a debugging message.
Definition qoflog.h:264

◆ gnc_tree_view_account_set_selected_accounts()

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.

All other accounts will be unselected. In addition, this function collapses the entire tree and then expands only the path to the selected accounts, making them easy to find. In general, this routine only need be called when initially putting up a window containing an account tree view widget.

Note
It only makes sense to call this function when the account tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
It is the responsibility of the caller to free the returned list.
Parameters
viewA pointer to an account tree view.
account_listA list of accounts to select.
show_lastForce the window to scroll to the last account selected.

Definition at line 1586 of file gnc-tree-view-account.c.

1589{
1590 GtkTreeModel *model, *f_model, *s_model;
1591 GtkTreePath *path, *f_path, *s_path, *parent_path;
1592 GtkTreeSelection *selection;
1593 GList *element;
1594 Account *account;
1595
1596 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1597
1598 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1599 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1600 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1601
1602 /* Clear any existing selection. */
1603 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1604 gtk_tree_selection_unselect_all (selection);
1605 gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
1606
1607 /* Now go select what the user requested. */
1608 for (element = account_list; element; )
1609 {
1610 account = element->data;
1611 element = g_list_next(element);
1612
1613 if (account == NULL)
1614 {
1615 /*
1616 * Oops. Someone must have deleted this account and not cleaned
1617 * up all references to it.
1618 */
1619 continue;
1620 }
1621
1622 path = gnc_tree_model_account_get_path_from_account (GNC_TREE_MODEL_ACCOUNT(model), account);
1623 if (path == NULL)
1624 {
1625 /*
1626 * Oops. Someone must have deleted this account and not cleaned
1627 * up all references to it.
1628 */
1629 continue;
1630 }
1631
1632 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
1633 path);
1634 gtk_tree_path_free(path);
1635 if (f_path == NULL)
1636 continue;
1637
1638 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1639 f_path);
1640 gtk_tree_path_free(f_path);
1641 if (s_path == NULL)
1642 continue;
1643
1644 /* gtk_tree_view requires that a row be visible before it can be selected */
1645 parent_path = gtk_tree_path_copy (s_path);
1646 if (gtk_tree_path_up (parent_path))
1647 {
1648 /* This function is misnamed. It expands the actual item
1649 * specified, not the path to the item specified. I.E. It
1650 * expands one level too many, thus the get of the parent. */
1651 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1652 }
1653 gtk_tree_path_free(parent_path);
1654
1655 gtk_tree_selection_select_path (selection, s_path);
1656 if (show_last && (element == NULL))
1657 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1658 gtk_tree_path_free(s_path);
1659 }
1660}

◆ gnc_tree_view_account_set_view_info()

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 specified to the current configuration of the account tree widget.

This may be used in conjunction with the gnc_tree_view_account_get_view_info function to modify the filters on an existing account tree.

Parameters
account_viewA pointer to an account tree view.
aviA pointer to an old style filter block to apply to the view.

Definition at line 1228 of file gnc-tree-view-account.c.

1230{
1231 ENTER("%p", view);
1232 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1233 g_return_if_fail(avi != NULL);
1234
1235 view->avi = *avi;
1236
1238 view, gnc_tree_view_account_filter_by_view_info,
1239 &view->avi, NULL);
1240
1241 LEAVE(" ");
1242}
void gnc_tree_view_account_set_filter(GncTreeViewAccount *view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
This function attaches a filter function to the given account tree.

◆ gnc_tree_view_commodity_configure_columns()

void gnc_tree_view_commodity_configure_columns ( GncTreeViewCommodity *  view,
GSList *  column_names 
)

Configure (by name) the set of visible columns in an commodity tree view.

By default, only the commodity name column is show. The available list of columns can be found in the file gnc-tree-view-commodity.c

Parameters
viewA pointer to an commodity tree view.
column_namesA list of column names to make visible.

◆ gnc_tree_view_commodity_get_cursor_commodity()

gnc_commodity * gnc_tree_view_commodity_get_cursor_commodity ( GncTreeViewCommodity *  view)

This function returns the commodity in the commodity tree view at the current location of the cursor.

(The outline frame. Usually is selected and therefore filled in, but not always.)

Parameters
viewA pointer to an commodity tree view.
Returns
The commodity at the cursor.

◆ gnc_tree_view_commodity_get_selected_commodity()

gnc_commodity * gnc_tree_view_commodity_get_selected_commodity ( GncTreeViewCommodity *  view)

This function returns the commodity associated with the selected item in the commodity tree view.

Note
It only makes sense to call this function when the commodity tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an commodity tree view.
Returns
The selected commodity, or NULL if no commodity was selected.

Definition at line 614 of file gnc-tree-view-commodity.c.

615{
616 GtkTreeSelection *selection;
617 GtkTreeModel *model, *f_model, *s_model;
618 GtkTreeIter iter, f_iter, s_iter;
619 gnc_commodity *commodity;
620
621 g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY (view), NULL);
622
623 ENTER("view %p", view);
624
625 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
626 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
627 {
628 LEAVE("no commodity, get_selected failed");
629 return NULL;
630 }
631
632 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
633 &f_iter, &s_iter);
634
635 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
636 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
637 &iter, &f_iter);
638
639 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
640 commodity = gnc_tree_model_commodity_get_commodity (GNC_TREE_MODEL_COMMODITY(model),
641 &iter);
642 LEAVE("commodity %p (%s)", commodity,
643 commodity ? gnc_commodity_get_mnemonic(commodity) : "");
644 return commodity;
645}
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
gnc_commodity * gnc_tree_model_commodity_get_commodity(GncTreeModelCommodity *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash commodity.

◆ gnc_tree_view_commodity_get_selected_namespace()

gnc_commodity_namespace * gnc_tree_view_commodity_get_selected_namespace ( GncTreeViewCommodity *  view)

This function returns the namespace associated with the selected item in the commodity tree view.

Note
It only makes sense to call this function when the commodity tree is set to select a single item.
Parameters
viewA pointer to an commodity tree view.
Returns
The selected namespace, or NULL if no namespace was selected.

Definition at line 652 of file gnc-tree-view-commodity.c.

653{
654 GtkTreeSelection *selection;
655 GtkTreeModel *model, *f_model, *s_model;
656 GtkTreeIter iter, f_iter, s_iter;
657 gnc_commodity_namespace *ns;
658
659 g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY(view), NULL);
660
661 ENTER("view %p", view);
662
663 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
664 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
665 {
666 LEAVE("no namespace, get_selected failed");
667 return NULL;
668 }
669
670 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
671 &f_iter, &s_iter);
672
673 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(s_model));
674 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
675 &iter, &f_iter);
676
677 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(f_model));
678
679 ns = gnc_tree_model_commodity_get_namespace (GNC_TREE_MODEL_COMMODITY(model),
680 &iter);
681
682 LEAVE("namespace %p (%s)", ns,
684 return ns;
685}
const char * gnc_commodity_namespace_get_name(const gnc_commodity_namespace *ns)
Return the textual name of a namespace data structure.
gnc_commodity_namespace * gnc_tree_model_commodity_get_namespace(GncTreeModelCommodity *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash commodity namespace.

◆ gnc_tree_view_commodity_new()

GtkTreeView * gnc_tree_view_commodity_new ( QofBook book,
const gchar *  first_property_name,
  ... 
)

Create a new commodity tree view.

This view may or may not show a pseudo top-level commodity. The gnucash engine does not have a single top level commodity (it has a list of top level commodities), but this code provides one so that it can be used with all parts of the gnucash gui.

Parameters
bookThe book containing the commodities to show.
first_property_namePairs of property name/value settings for the newly created object. Terminate the properties with a single NULL argument.
Returns
A pointer to a new commodity tree view.

Definition at line 311 of file gnc-tree-view-commodity.c.

314{
315 GncTreeView *view;
316 GtkTreeModel *model, *f_model, *s_model;
317 GtkTreeViewColumn *col;
318 gnc_commodity_table *ct;
319 va_list var_args;
320
321 ENTER(" ");
322 /* Create/get a pointer to the existing model for this set of books. */
324 model = gnc_tree_model_commodity_new (book, ct);
325
326 /* Set up the view private filter on the common model. */
327 f_model = gtk_tree_model_filter_new (model, NULL);
328 g_object_unref(G_OBJECT(model));
329 s_model = gtk_tree_model_sort_new_with_model (f_model);
330 g_object_unref(G_OBJECT(f_model));
331
332 /* Create our view */
333 view = g_object_new (GNC_TYPE_TREE_VIEW_COMMODITY,
334 "name", "gnc-id-commodity-tree", NULL);
335 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
336 g_object_unref(G_OBJECT(s_model));
337
338 DEBUG("model ref count is %d", G_OBJECT(model)->ref_count);
339 DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
340 DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
341
342 /* Set default visibilities */
343 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
344
346 view, _("Namespace"), "namespace", NULL, "NASDAQ",
347 GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
348 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
349 sort_by_commodity_string);
351 view, _("Symbol"), "symbol", NULL, "ACMEACME",
352 GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC,
353 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
354 sort_by_commodity_string);
355 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
357 view, _("Name"), "name", NULL, "Acme Corporation, Inc.",
358 GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
359 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
360 sort_by_commodity_string);
361 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
363 view, _("Print Name"), "printname", NULL,
364 "ACMEACME (Acme Corporation, Inc.)",
365 GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
366 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
367 sort_by_commodity_string);
369 view, _("Display symbol"), "user_symbol", NULL, "ACME",
370 GNC_TREE_MODEL_COMMODITY_COL_USER_SYMBOL,
371 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
372 sort_by_commodity_string);
373 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
375 view, _("Unique Name"), "uniquename", NULL,
376 "NASDAQ::ACMEACME", GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
377 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
378 sort_by_commodity_string);
380 /* Translators: Again replace CUSIP by the name of your
381 National Securities Identifying Number. */
382 view, _("ISIN/CUSIP"), "cusip_code", NULL, "US1234567890",
383 GNC_TREE_MODEL_COMMODITY_COL_CUSIP,
384 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
385 sort_by_commodity_string);
386 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
388 view, _("Fraction"), "fraction", "10000",
389 GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
390 GNC_TREE_VIEW_COLUMN_COLOR_NONE,
391 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
392 sort_by_fraction);
393 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
395 view, _("Get Quotes"),
396 C_("Column letter for 'Get Quotes'", "Q"), "quote_flag",
397 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG,
398 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
399 sort_by_quote_flag,
400 NULL);
402 view, _("Source"), "quote_source", NULL, "alphavantage",
403 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
404 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
405 sort_by_commodity_string);
407 view, _("Timezone"), "quote_timezone", NULL, "America/New_York",
408 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
409 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
410 sort_by_commodity_string);
411 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
412
414
415 /* Set properties */
416 va_start (var_args, first_property_name);
417 g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
418 va_end (var_args);
419
420 /* Sort on the name column by default. This allows for a consistent
421 * sort if commodities are briefly removed and re-added. */
422 if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
423 NULL, NULL))
424 {
425 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
426 GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
427 GTK_SORT_ASCENDING);
428 }
429
430 gtk_widget_show(GTK_WIDGET(view));
431 LEAVE(" %p", view);
432 return GTK_TREE_VIEW(view);
433}
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
GtkTreeModel * gnc_tree_model_commodity_new(QofBook *book, gnc_commodity_table *ct)
Create a new GtkTreeModel for manipulating gnucash commodities.

◆ gnc_tree_view_commodity_refilter()

void gnc_tree_view_commodity_refilter ( GncTreeViewCommodity *  view)

This function forces the commodity tree filter to be evaluated.

It may be necessary to call this function if the initial state of the view is incorrect. This appears to only be necessary if the filter affects one of the top level commodities in gnucash.

Note
This calls a function in gtk that is annotated in the sources as being slow. You have been warned.
Parameters
viewA pointer to an commodity tree view.

Definition at line 591 of file gnc-tree-view-commodity.c.

592{
593 GtkTreeModel *f_model, *s_model;
594
595 g_return_if_fail(GNC_IS_TREE_VIEW_COMMODITY(view));
596
597 ENTER("view %p", view);
598 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
599 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
600 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
601 LEAVE(" ");
602}

◆ gnc_tree_view_commodity_select_commodity()

void gnc_tree_view_commodity_select_commodity ( GncTreeViewCommodity *  view,
gnc_commodity *  commodity 
)

Select the commodity in the associated commodity tree view.

Parameters
viewA pointer to an commodity tree view.
commodityThe commodity to select.

Definition at line 691 of file gnc-tree-view-commodity.c.

692{
693 GtkTreeSelection *selection;
694 GtkTreeModel *model, *f_model, *s_model;
695 GtkTreePath *tree_path;
696 GtkTreePath *f_tree_path;
697 GtkTreePath *s_tree_path;
698
699 g_return_if_fail (GNC_IS_TREE_VIEW_COMMODITY(view));
700
701 if (!commodity)
702 return;
703
704 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
705
706 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
707 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
708 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
709
710 tree_path = gnc_tree_model_commodity_get_path_from_commodity (GNC_TREE_MODEL_COMMODITY(model), commodity);
711
712 if (tree_path)
713 {
714 f_tree_path = gtk_tree_model_filter_convert_child_path_to_path
715 (GTK_TREE_MODEL_FILTER (f_model), tree_path);
716
717 s_tree_path = gtk_tree_model_sort_convert_child_path_to_path
718 (GTK_TREE_MODEL_SORT (s_model), f_tree_path);
719
720 gtk_tree_view_expand_to_path (GTK_TREE_VIEW(view), s_tree_path);
721 gtk_tree_selection_select_path (selection, s_tree_path);
722 gtk_tree_path_free (tree_path);
723 gtk_tree_path_free (f_tree_path);
724 gtk_tree_path_free (s_tree_path);
725 }
726}
GtkTreePath * gnc_tree_model_commodity_get_path_from_commodity(GncTreeModelCommodity *model, gnc_commodity *commodity)
Convert a commodity pointer into a GtkTreePath.

◆ gnc_tree_view_commodity_select_subcommodities()

void gnc_tree_view_commodity_select_subcommodities ( GncTreeViewCommodity *  view,
gnc_commodity *  commodity 
)

This function selects all sub-commodities of an commodity in the commodity tree view.

All other commodities will be unselected.

Note
It only makes sense to call this function when the commodity tree is set to select multiple items. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an commodity tree view.
commodityA pointer to the commodity whose children should be selected.

◆ gnc_tree_view_commodity_set_filter()

void gnc_tree_view_commodity_set_filter ( GncTreeViewCommodity *  view,
gnc_tree_view_commodity_ns_filter_func  ns_func,
gnc_tree_view_commodity_cm_filter_func  cm_func,
gpointer  data,
GDestroyNotify  destroy 
)

This function attaches a filter function to the given commodity tree.

This function will be called for each commodity that the view thinks should possibly show. The filter may perform any actions necessary on the commodity to decide whether it should be shown or not. (I.E. Check type, placeholder status, etc.) If the filter returns TRUE then the commodity will be displayed.

Parameters
viewA pointer to an commodity tree view.
ns_funcA filtration function that is called on individual tree elements that represent a namespace. If this function returns TRUE, the namespace (and commodities under it) will be displayed.
cm_funcA filtration function that is called on individual tree elements that represent a commodity. If this function returns TRUE, the commodity will be displayed.
dataA data block passed into each instance of the function.
destroyA function to destroy the data block. This function will be called when the filter is destroyed. may be NULL.

Definition at line 543 of file gnc-tree-view-commodity.c.

548{
549 GtkTreeModel *f_model, *s_model;
550 filter_user_data *fd = data;
551
552 g_return_if_fail(GNC_IS_TREE_VIEW_COMMODITY(view));
553 g_return_if_fail((ns_func != NULL) || (cm_func != NULL));
554
555 ENTER("view %p, ns func %p, cm func %p, data %p, destroy %p",
556 view, ns_func, cm_func, data, destroy);
557
558 fd = g_malloc(sizeof(filter_user_data));
559 fd->user_ns_fn = ns_func;
560 fd->user_cm_fn = cm_func;
561 fd->user_data = data;
562 fd->user_destroy = destroy;
563
564 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
565 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
566
567 /* disconnect model from view */
568 g_object_ref (G_OBJECT(s_model));
569 gtk_tree_view_set_model (GTK_TREE_VIEW(view), NULL);
570
571 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
572 gnc_tree_view_commodity_filter_helper,
573 fd,
574 gnc_tree_view_commodity_filter_destroy);
575
576 /* Whack any existing levels. The top two levels have been created
577 * before this routine can be called. */
578 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
579
580 /* connect model to view */
581 gtk_tree_view_set_model (GTK_TREE_VIEW(view), s_model);
582 g_object_unref (G_OBJECT(s_model));
583
584 LEAVE(" ");
585}

◆ gnc_tree_view_owner_get_owner_from_iter()

GncOwner * gnc_tree_view_owner_get_owner_from_iter ( GtkTreeModel *  model,
GtkTreeIter *  iter 
)

This function returns the owner associated with the specified iter.

This function is useful in selection callbacks on an owner tree widget.

Parameters
modelThe model provided to the callback function.
iterThe iter provided to the callback function.
Returns
The owner associated with this iter.

Definition at line 699 of file gnc-tree-view-owner.c.

701{
702 GtkTreeModel *model, *f_model;
703 GtkTreeIter iter, f_iter;
704 GncOwner *owner;
705
706 g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
707 g_return_val_if_fail (s_iter != NULL, NULL);
708
709 ENTER("model %p, iter %p", s_model, s_iter);
710
711 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
712 &f_iter,
713 s_iter);
714 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
715 gtk_tree_model_filter_convert_iter_to_child_iter (
716 GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
717 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
719 GNC_TREE_MODEL_OWNER(model), &iter);
720 LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
721 return owner;
722}
GncOwner * gnc_tree_model_owner_get_owner(GncTreeModelOwner *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash owner.

◆ gnc_tree_view_owner_get_owner_from_path()

GncOwner * gnc_tree_view_owner_get_owner_from_path ( GncTreeViewOwner *  view,
GtkTreePath *  path 
)

This function returns the owner associated with the specified path.

This function is useful in selection callbacks on an owner tree widget.

Parameters
viewA pointer to an owner tree view.
pathA path specifying a node in the owner tree.
Returns
The owner associated with this path.

Definition at line 653 of file gnc-tree-view-owner.c.

655{
656 GtkTreeModel *model, *f_model, *s_model;
657 GtkTreePath *path, *f_path;
658 GtkTreeIter iter;
659 GncOwner *owner;
660
661 ENTER("view %p", view);
662 g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
663 g_return_val_if_fail (s_path != NULL, NULL);
664
665 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
666 f_path = gtk_tree_model_sort_convert_path_to_child_path (
667 GTK_TREE_MODEL_SORT (s_model), s_path);
668 if (!f_path)
669 {
670 LEAVE("no filter path");
671 return NULL;
672 }
673
674 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
675 path = gtk_tree_model_filter_convert_path_to_child_path (
676 GTK_TREE_MODEL_FILTER (f_model), f_path);
677 gtk_tree_path_free(f_path);
678 if (!path)
679 {
680 LEAVE("no path");
681 return NULL;
682 }
683
684 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
685 if (!gtk_tree_model_get_iter (model, &iter, path))
686 {
687 LEAVE("no iter");
688 return NULL;
689 }
690
691 owner = iter.user_data;
692 gtk_tree_path_free(path);
693 LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
694 return owner;
695}

◆ gnc_tree_view_owner_get_selected_owner()

GncOwner * gnc_tree_view_owner_get_selected_owner ( GncTreeViewOwner *  view)

This function returns the owner associated with the selected item in the owner tree view.

Note
It only makes sense to call this function when the owner tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an owner tree view.
Returns
The selected owner, or NULL if no owner was selected.

Definition at line 730 of file gnc-tree-view-owner.c.

731{
732 GtkTreeSelection *selection;
733 GtkTreeModel *f_model, *s_model;
734 GtkTreeIter iter, f_iter, s_iter;
735 GncOwner *owner;
736 GtkSelectionMode mode;
737
738 ENTER("view %p", view);
739 g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
740
741 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
742 mode = gtk_tree_selection_get_mode(selection);
743 if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
744 {
745 return NULL;
746 }
747 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
748 {
749 LEAVE("no owner, get_selected failed");
750 return FALSE;
751 }
752
753 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
754 &f_iter, &s_iter);
755
756 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
757 gtk_tree_model_filter_convert_iter_to_child_iter (
758 GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
759
760 owner = iter.user_data;
761 LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
762 return owner;
763}

◆ gnc_tree_view_owner_new()

GtkTreeView * gnc_tree_view_owner_new ( GncOwnerType  owner_type)

Create a new owner tree view for one type of owners.

Parameters
owner_typeThe type of owners to use in the view.
Returns
A pointer to a new owner tree view.

Definition at line 319 of file gnc-tree-view-owner.c.

320{
321 GtkTreeModel *model, *f_model, *s_model;
322 const gchar *sample_type, *sample_currency;
323 const gchar *owner_name = NULL, * owner_id = NULL;
324
325 ENTER(" ");
326
327 switch (owner_type)
328 {
329 case GNC_OWNER_NONE :
330 case GNC_OWNER_UNDEFINED :
331 PWARN("missing owner_type");
332 owner_name = _("Name");
333 owner_id = _("ID #");
334 break;
335 case GNC_OWNER_CUSTOMER :
336 owner_name = _("Company Name");
337 owner_id = _("Customer Number");
338 break;
339 case GNC_OWNER_JOB :
340 owner_name = _("Job Name");
341 owner_id = _("Job Number");
342 break;
343 case GNC_OWNER_VENDOR :
344 owner_name = _("Company Name");
345 owner_id = _("Vendor Number");
346 break;
347 case GNC_OWNER_EMPLOYEE :
348 owner_name = _("Employee Name");
349 owner_id = _("Employee Number");
350 break;
351 }
352 /* Create our view */
353 GncTreeViewOwner *view = g_object_new (GNC_TYPE_TREE_VIEW_OWNER,
354 "name", "gnc-id-owner-tree", NULL);
355
356 /* Create/get a pointer to the existing model for this set of books. */
357 model = gnc_tree_model_owner_new (owner_type);
358
359 /* Set up the view private filter layer on the common model. */
360 f_model = gtk_tree_model_filter_new (model, NULL);
361 /* A GncTreeModelOwner is based on a GncTreeModel, which is a
362 * GObject that provides a GtkTreeModel interface. */
363 g_object_unref(G_OBJECT(model));
364
365 /* Set up the view private sort layer on the common model. */
366 s_model = gtk_tree_model_sort_new_with_model(f_model);
367 g_object_unref(G_OBJECT(f_model));
368 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
369 g_object_unref(G_OBJECT(s_model));
370
371 /* Set default visibilities */
372 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
373
374 sample_type = gncOwnerTypeToQofIdType (GNC_OWNER_CUSTOMER);
376
377 view->name_column
378 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), owner_name, GNC_OWNER_TREE_NAME_COL,
379 NULL, "GnuCash Inc.",
380 GNC_TREE_MODEL_OWNER_COL_NAME,
381 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
382 sort_by_string);
383 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Type"), GNC_OWNER_TREE_TYPE_COL,
384 NULL, sample_type,
385 GNC_TREE_MODEL_OWNER_COL_TYPE,
386 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
387 sort_by_string);
388 view->id_column
389 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), owner_id, GNC_OWNER_TREE_ID_COL,
390 NULL, "1-123-1234",
391 GNC_TREE_MODEL_OWNER_COL_ID,
392 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
393 sort_by_string);
394 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Currency"), GNC_OWNER_TREE_CURRENCY_COL,
395 NULL, sample_currency,
396 GNC_TREE_MODEL_OWNER_COL_CURRENCY,
397 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
398 sort_by_string);
399 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Address Name"), GNC_OWNER_TREE_ADDRESS_NAME_COL,
400 NULL, "GnuCash Inc.",
401 GNC_TREE_MODEL_OWNER_COL_ADDRESS_NAME,
402 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
403 sort_by_string);
404 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Address 1"), GNC_OWNER_TREE_ADDRESS_1_COL,
405 NULL, "Free Software Foundation",
406 GNC_TREE_MODEL_OWNER_COL_ADDRESS_1,
407 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
408 sort_by_string);
409 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Address 2"), GNC_OWNER_TREE_ADDRESS_2_COL,
410 NULL, "51 Franklin Street, Fifth Floor",
411 GNC_TREE_MODEL_OWNER_COL_ADDRESS_2,
412 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
413 sort_by_string);
414 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Address 3"), GNC_OWNER_TREE_ADDRESS_3_COL,
415 NULL, "Boston, MA 02110-1301",
416 GNC_TREE_MODEL_OWNER_COL_ADDRESS_3,
417 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
418 sort_by_string);
419 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Address 4"), GNC_OWNER_TREE_ADDRESS_4_COL,
420 NULL, "USA",
421 GNC_TREE_MODEL_OWNER_COL_ADDRESS_4,
422 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
423 sort_by_string);
424 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Phone"), GNC_OWNER_TREE_PHONE_COL,
425 NULL, "+1-617-542-5942",
426 GNC_TREE_MODEL_OWNER_COL_PHONE,
427 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
428 sort_by_string);
429 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Fax"), GNC_OWNER_TREE_FAX_COL,
430 NULL, "+1-617-542-2652",
431 GNC_TREE_MODEL_OWNER_COL_FAX,
432 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
433 sort_by_string);
434 gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("E-mail"), GNC_OWNER_TREE_EMAIL_COL,
435 NULL, "gnu@gnu.org",
436 GNC_TREE_MODEL_OWNER_COL_EMAIL,
437 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
438 sort_by_string);
439 gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Balance"), GNC_OWNER_TREE_BALANCE_COL,
440 SAMPLE_OWNER_VALUE,
441 GNC_TREE_MODEL_OWNER_COL_BALANCE,
442 GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE,
443 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
444 sort_by_balance_value);
445
446 view->balance_report_column
447 = gnc_tree_view_add_numeric_column(GNC_TREE_VIEW(view), _("Balance"), GNC_OWNER_TREE_BALANCE_REPORT_COL,
448 SAMPLE_OWNER_VALUE,
449 GNC_TREE_MODEL_OWNER_COL_BALANCE_REPORT,
450 GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE,
451 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
452 sort_by_balance_value);
453
454 view->notes_column
455 = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), _("Notes"), GNC_OWNER_TREE_NOTES_COL, NULL,
456 "Sample owner notes.",
457 GNC_TREE_MODEL_OWNER_COL_NOTES,
458 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
459 sort_by_string);
460 gnc_tree_view_add_toggle_column (GNC_TREE_VIEW(view), _("Active"),
461 C_("Column letter for 'Active'", "A"),
462 GNC_OWNER_TREE_ACTIVE_COL,
463 GNC_TREE_MODEL_OWNER_COL_ACTIVE,
464 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
465 sort_by_boolean,
466 gnc_tree_view_owner_active_toggled);
467
468 /* Update column titles to use the currency name. */
469 gtvo_update_column_names(view);
470
471 /* By default only the first column is visible. */
472 gnc_tree_view_configure_columns(GNC_TREE_VIEW(view));
473 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
474 gnc_tree_view_owner_filter_helper,
475 view,
476 NULL);
477
478 /* Default the sorting to owner name */
479 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
480 GNC_TREE_MODEL_OWNER_COL_NAME,
481 GTK_SORT_ASCENDING);
482
483 gtk_widget_show(GTK_WIDGET(view));
484 LEAVE("%p", view);
485 return GTK_TREE_VIEW(view);
486}
GtkTreeModel * gnc_tree_model_owner_new(GncOwnerType owner_type)
Create a new GtkTreeModel for manipulating gnucash owners.
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250

◆ gnc_tree_view_owner_refilter()

void gnc_tree_view_owner_refilter ( GncTreeViewOwner *  view)

This function forces the owner tree filter to be evaluated.

It may be necessary to call this function if the initial state of the view is incorrect. This appears to only be necessary if the filter affects one of the top level owners in gnucash.

Note
This calls a function in gtk that is annotated in the sources as being slow. You have been warned.
Parameters
viewA pointer to an owner tree view.

Definition at line 633 of file gnc-tree-view-owner.c.

634{
635 GtkTreeModel *f_model, *s_model;
636
637 g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(view));
638
639 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
640 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
641 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
642}

◆ gnc_tree_view_owner_restore()

void gnc_tree_view_owner_restore ( GncTreeViewOwner *  view,
OwnerFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name,
GncOwnerType  owner_type 
)

Definition at line 1262 of file gnc-tree-view-owner.c.

1266{
1267 GError *error = NULL;
1268 gchar *value;
1269 gboolean show;
1270
1271 /* Filter information. Ignore missing keys. */
1272 show = g_key_file_get_boolean(key_file, group_name, SHOW_INACTIVE_LABEL, &error);
1273 if (error)
1274 {
1275 g_warning("error reading group %s key %s: %s",
1276 group_name, SHOW_INACTIVE_LABEL, error->message);
1277 g_error_free(error);
1278 error = NULL;
1279 show = TRUE;
1280 }
1281 fd->show_inactive = show;
1282
1283 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO_LABEL, &error);
1284 if (error)
1285 {
1286 g_warning("error reading group %s key %s: %s",
1287 group_name, SHOW_ZERO_LABEL, error->message);
1288 g_error_free(error);
1289 error = NULL;
1290 show = TRUE;
1291 }
1292 fd->show_zero_total = show;
1293
1294 /* Selected owner (if any) */
1295 value = g_key_file_get_string(key_file, group_name, OWNER_SELECTED_LABEL, NULL);
1296 if (value)
1297 {
1298 tree_restore_selected_row(view, owner_type, value);
1299 g_free(value);
1300 }
1301
1302 /* Update tree view for any changes */
1304}
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
This function forces the owner tree filter to be evaluated.

◆ gnc_tree_view_owner_save()

void gnc_tree_view_owner_save ( GncTreeViewOwner *  tree_view,
OwnerFilterDialog fd,
GKeyFile *  key_file,
const gchar *  group_name 
)

Definition at line 1215 of file gnc-tree-view-owner.c.

1218{
1219 bar_t bar;
1220
1221 g_return_if_fail (key_file != NULL);
1222 g_return_if_fail (group_name != NULL);
1223
1224 ENTER("view %p, key_file %p, group_name %s", view, key_file,
1225 group_name);
1226
1227 g_key_file_set_boolean(key_file, group_name, SHOW_INACTIVE_LABEL,
1228 fd->show_inactive);
1229 g_key_file_set_boolean(key_file, group_name, SHOW_ZERO_LABEL,
1230 fd->show_zero_total);
1231
1232 bar.key_file = key_file;
1233 bar.group_name = group_name;
1234 tree_save_selected_row(view, &bar);
1235 LEAVE(" ");
1236
1237}

◆ gnc_tree_view_owner_set_filter()

void gnc_tree_view_owner_set_filter ( GncTreeViewOwner *  owner_view,
gnc_tree_view_owner_filter_func  func,
gpointer  data,
GSourceFunc  destroy 
)

This function attaches a filter function to the given owner tree.

This function will be called for each owner that the view thinks should possibly show. The filter may perform any actions necessary on the owner to decide whether it should be shown or not. (I.E. Check type, placeholder status, etc.) If the filter returns TRUE then the owner will be displayed.

Parameters
owner_viewA pointer to an owner tree view.
funcA filtration function that is called on individual elements in the tree. If this function returns TRUE, the owner will be displayed.
dataA data block passed into each instance of the function.
destroyA function to destroy the data block. This function will be called when the filter is destroyed. may be NULL.

Definition at line 607 of file gnc-tree-view-owner.c.

611{
612 ENTER("view %p, filter func %p, data %p, destroy %p",
613 view, func, data, destroy);
614
615 g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(view));
616
617 if (view->filter_destroy)
618 {
619 view->filter_destroy(view->filter_data);
620 }
621 view->filter_destroy = destroy;
622 view->filter_data = data;
623 view->filter_fn = func;
624
626 LEAVE(" ");
627}

◆ gnc_tree_view_owner_set_selected_owner()

void gnc_tree_view_owner_set_selected_owner ( GncTreeViewOwner *  view,
GncOwner owner 
)

This function selects an owner in the owner tree view.

All other owners will be unselected. In addition, this function collapses the entire tree and then expands only the path to the selected owner, making the item easy to find. In general, this routine only need be called when initially putting up a window containing an owner tree view widget.

Note
It only makes sense to call this function when the owner tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an owner tree view.
ownerA pointer to the owner to select.

Definition at line 770 of file gnc-tree-view-owner.c.

772{
773 GtkTreeModel *model, *f_model, *s_model;
774 GtkTreePath *path, *f_path, *s_path;
775 GtkTreeSelection *selection;
776
777 ENTER("view %p, owner %p (%s)", view,
778 owner, gncOwnerGetName (owner));
779 g_return_if_fail (GNC_IS_TREE_VIEW_OWNER (view));
780
781 /* Clear any existing selection. */
782 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
783 gtk_tree_selection_unselect_all (selection);
784
785 if (owner == NULL)
786 return;
787
788 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
789 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
790 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
791
793 GNC_TREE_MODEL_OWNER(model), owner);
794 if (path == NULL)
795 {
796 LEAVE("no path");
797 return;
798 }
799 debug_path(DEBUG, path);
800
801 f_path = gtk_tree_model_filter_convert_child_path_to_path (
802 GTK_TREE_MODEL_FILTER (f_model), path);
803 gtk_tree_path_free(path);
804 if (f_path == NULL)
805 {
806 LEAVE("no filter path");
807 return;
808 }
809 debug_path(DEBUG, f_path);
810
811 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
812 f_path);
813 gtk_tree_path_free(f_path);
814 if (s_path == NULL)
815 {
816 LEAVE("no sort path");
817 return;
818 }
819
820 gtk_tree_selection_select_path (selection, s_path);
821
822 /* give gtk+ a chance to resize the tree view first by handling pending
823 * configure events */
824 while (gtk_events_pending ())
825 gtk_main_iteration ();
826 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
827 debug_path(LEAVE, s_path);
828 gtk_tree_path_free(s_path);
829}
GtkTreePath * gnc_tree_model_owner_get_path_from_owner(GncTreeModelOwner *model, GncOwner *owner)
Convert a model/owner pair into a gtk_tree_model_path.

◆ gnc_tree_view_price_get_cursor_price()

GNCPrice * gnc_tree_view_price_get_cursor_price ( GncTreeViewPrice *  view)

This function returns the price in the price tree view at the current location of the cursor.

(The outline frame. Usually is selected and therefore filled in, but not always.)

Parameters
viewA pointer to an price tree view.
Returns
The price at the cursor.

◆ gnc_tree_view_price_get_selected_commodities()

GList * gnc_tree_view_price_get_selected_commodities ( GncTreeViewPrice *  view)

This function returns a list of commodities associated with the selected rows that are not prices but are the parent rows for prices in the price tree view.

Note
It only makes sense to call this function when the price tree is set to select multiple items.
Parameters
viewA pointer to an price tree view.
Returns
A list of commodities, or NULL if no commodity was selected.

Definition at line 810 of file gnc-tree-view-price.c.

811{
812 GtkTreeSelection *selection;
813 GList *return_list = NULL;
814
815 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
816 gtk_tree_selection_selected_foreach (selection, get_selected_commodity_helper, &return_list);
817 return g_list_reverse (return_list);
818}

◆ gnc_tree_view_price_get_selected_price()

GNCPrice * gnc_tree_view_price_get_selected_price ( GncTreeViewPrice *  view)

This function returns the price associated with the selected item in the price tree view.

Note
It only makes sense to call this function when the price tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an price tree view.
Returns
The selected price, or NULL if no price was selected.

Definition at line 628 of file gnc-tree-view-price.c.

629{
630 GtkTreeSelection *selection;
631 GtkTreeModel *model, *f_model, *s_model;
632 GtkTreeIter iter, f_iter, s_iter;
633 GNCPrice *price;
634
635 ENTER("view %p", view);
636 g_return_val_if_fail (GNC_IS_TREE_VIEW_PRICE (view), NULL);
637
638 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
639 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
640 {
641 LEAVE("no price, get_selected failed");
642 return FALSE;
643 }
644
645 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
646 &f_iter, &s_iter);
647
648 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
649 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
650 &iter, &f_iter);
651
652 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
653 price = gnc_tree_model_price_get_price (GNC_TREE_MODEL_PRICE(model),
654 &iter);
655 LEAVE("price %p", price);
656 return price;
657}
GNCPrice * gnc_tree_model_price_get_price(GncTreeModelPrice *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash price.

◆ gnc_tree_view_price_get_selected_prices()

GList * gnc_tree_view_price_get_selected_prices ( GncTreeViewPrice *  view)

This function returns a list of the prices associated with the selected items in the price tree view.

Note
It only makes sense to call this function when the price tree is set to select multiple items. There is a different function to use when the tree supports single selection.
Parameters
viewA pointer to an price tree view.
Returns
A list of prices, or NULL if no price was selected.

Definition at line 766 of file gnc-tree-view-price.c.

767{
768 GtkTreeSelection *selection;
769 GList *return_list = NULL;
770
771 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
772 gtk_tree_selection_selected_foreach(selection, get_selected_prices_helper, &return_list);
773 return g_list_reverse (return_list);
774}

◆ gnc_tree_view_price_new()

GtkTreeView * gnc_tree_view_price_new ( QofBook book,
const gchar *  first_property_name,
  ... 
)

Create a new price tree view.

This view may or may not show a pseudo top-level price. The gnucash engine does not have a single top level price (it has a list of top level prices), but this code provides one so that it can be used with all parts of the gnucash gui.

Parameters
bookThe book containing the prices to show.
first_property_namePairs of property name/value settings for the newly created object. Terminate the properties with a single NULL argument.
Returns
A pointer to a new price tree view.

Definition at line 350 of file gnc-tree-view-price.c.

353{
354 GncTreeView *view;
355 GtkTreeModel *model, *f_model, *s_model;
356 GtkTreeViewColumn *col;
357 GNCPriceDB *price_db;
358 va_list var_args;
359 const gchar *sample_text;
360 gchar *sample_text2;
361
362 ENTER(" ");
363 /* Create/get a pointer to the existing model for this set of books. */
364 price_db = gnc_pricedb_get_db(book);
365 model = gnc_tree_model_price_new (book, price_db);
366
367 /* Set up the view private filter on the common model. */
368 f_model = gtk_tree_model_filter_new (model, NULL);
369 g_object_unref(G_OBJECT(model));
370 s_model = gtk_tree_model_sort_new_with_model (f_model);
371 g_object_unref(G_OBJECT(f_model));
372
373 /* Create our view */
374 view = g_object_new (GNC_TYPE_TREE_VIEW_PRICE,
375 "name", "gnc-id-price-tree", NULL);
376 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
377 g_object_unref(G_OBJECT(s_model));
378
379 DEBUG("model ref count is %d", G_OBJECT(model)->ref_count);
380 DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
381 DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
382
384 sample_text2 = g_strdup_printf("%s%s", sample_text, sample_text);
386 view, _("Security"), "security", NULL, sample_text2,
387 GNC_TREE_MODEL_PRICE_COL_COMMODITY,
388 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
389 sort_by_name);
390 g_free(sample_text2);
392 view, _("Currency"), "currency", NULL, sample_text,
393 GNC_TREE_MODEL_PRICE_COL_CURRENCY,
394 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
395 sort_by_name);
396 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
398 view, _("Date"), "date", NULL, "2005-05-20",
399 GNC_TREE_MODEL_PRICE_COL_DATE,
400 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
401 sort_by_date);
402 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
404 view, _("Source"), "source", NULL, "Finance::Quote",
405 GNC_TREE_MODEL_PRICE_COL_SOURCE,
406 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
407 sort_by_source);
408 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
410 view, _("Type"), "type", NULL, "last",
411 GNC_TREE_MODEL_PRICE_COL_TYPE,
412 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
413 sort_by_type);
414 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
416 view, _("Price"), "price", "100.00000",
417 GNC_TREE_MODEL_PRICE_COL_VALUE,
418 GNC_TREE_VIEW_COLUMN_COLOR_NONE,
419 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
420 sort_by_value);
421 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
422
424
425 /* Set properties */
426 va_start (var_args, first_property_name);
427 g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
428 va_end (var_args);
429
430 /* Sort on the commodity column by default. This allows for a consistent
431 * sort if commodities are removed and re-added from the model. */
432 if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
433 NULL, NULL))
434 {
435 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
436 GNC_TREE_MODEL_PRICE_COL_COMMODITY,
437 GTK_SORT_ASCENDING);
438 }
439
440 gtk_widget_show(GTK_WIDGET(view));
441 LEAVE(" %p", view);
442 return GTK_TREE_VIEW(view);
443}
const char * gnc_commodity_get_printname(const gnc_commodity *cm)
Retrieve the 'print' name for the specified commodity.
GtkTreeModel * gnc_tree_model_price_new(QofBook *book, GNCPriceDB *price_db)
Create a new GtkTreeModel for manipulating gnucash commodity prices.
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Return the pricedb associated with the book.

◆ gnc_tree_view_price_set_filter()

void gnc_tree_view_price_set_filter ( GncTreeViewPrice *  view,
gnc_tree_view_price_ns_filter_func  ns_func,
gnc_tree_view_price_cm_filter_func  cm_func,
gnc_tree_view_price_pc_filter_func  pc_func,
gpointer  data,
GDestroyNotify  destroy 
)

Definition at line 569 of file gnc-tree-view-price.c.

575{
576 GtkTreeModel *f_model, *s_model;
577 filter_user_data *fd = data;
578
579 ENTER("view %p, ns func %p, cm func %p, pc func %p, data %p, destroy %p",
580 view, ns_func, cm_func, pc_func, data, destroy);
581
582 g_return_if_fail(GNC_IS_TREE_VIEW_PRICE(view));
583 g_return_if_fail((ns_func != NULL) || (cm_func != NULL));
584
585 fd = g_malloc(sizeof(filter_user_data));
586 fd->user_ns_fn = ns_func;
587 fd->user_cm_fn = cm_func;
588 fd->user_pc_fn = pc_func;
589 fd->user_data = data;
590 fd->user_destroy = destroy;
591
592 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
593 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
594
595 /* disconnect model from view */
596 g_object_ref (G_OBJECT(s_model));
597 gtk_tree_view_set_model (GTK_TREE_VIEW(view), NULL);
598
599 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
600 gnc_tree_view_price_filter_helper,
601 fd,
602 gnc_tree_view_price_filter_destroy);
603
604 /* Whack any existing levels. The top two levels have been created
605 * before this routine can be called. Unfortunately, if the just
606 * applied filter filters out all the nodes in the tree, the gtk
607 * code throws a critical error. This occurs when there are no
608 * prices in the price database. Once the very first price has been
609 * added this error message goes away. */
610 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
611
612 /* connect model to view */
613 gtk_tree_view_set_model (GTK_TREE_VIEW(view), s_model);
614 g_object_unref (G_OBJECT(s_model));
615
616 LEAVE(" ");
617}

◆ gnc_tree_view_price_set_selected_price()

void gnc_tree_view_price_set_selected_price ( GncTreeViewPrice *  view,
GNCPrice *  price 
)

This function selects an price in the price tree view.

All other prices will be unselected. In addition, this function collapses the entire tree and then expands only the path to the selected price, making the item easy to find. In general, this routine only need be called when initially putting up a window containing an price tree view widget.

Note
It only makes sense to call this function when the price tree is set to select a single item. There is a different function to use when the tree supports multiple selections.
Parameters
viewA pointer to an price tree view.
priceA pointer to the price to select.

Definition at line 664 of file gnc-tree-view-price.c.

666{
667 GtkTreeModel *model, *f_model, *s_model;
668 GtkTreePath *path, *f_path, *s_path, *parent_path;
669 GtkTreeSelection *selection;
670
671 ENTER("view %p, price %p", view, price);
672
673 /* Clear any existing selection. */
674 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
675 gtk_tree_selection_unselect_all (selection);
676
677 if (price == NULL)
678 return;
679
680 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
681 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
682 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
683
684 path = gnc_tree_model_price_get_path_from_price (GNC_TREE_MODEL_PRICE(model), price);
685 if (path == NULL)
686 {
687 LEAVE("get_path_from_price failed");
688 return;
689 }
690 debug_path(DEBUG, path);
691
692 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
693 path);
694 gtk_tree_path_free(path);
695 if (f_path == NULL)
696 {
697 LEAVE("no filter path");
698 return;
699 }
700 debug_path(DEBUG, f_path);
701
702 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
703 f_path);
704 gtk_tree_path_free(f_path);
705 if (s_path == NULL)
706 {
707 LEAVE("no sort path");
708 return;
709 }
710
711 /* gtk_tree_view requires that a row be visible before it can be selected */
712 parent_path = gtk_tree_path_copy (s_path);
713 if (gtk_tree_path_up (parent_path))
714 {
715 /* This function is misnamed. It expands the actual item
716 * specified, not the path to the item specified. I.E. It expands
717 * one level too many, thus the get of the parent. */
718 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
719 }
720 gtk_tree_path_free(parent_path);
721
722 gtk_tree_selection_select_path (selection, s_path);
723 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
724 debug_path(LEAVE, s_path);
725 gtk_tree_path_free(s_path);
726}
GtkTreePath * gnc_tree_model_price_get_path_from_price(GncTreeModelPrice *model, GNCPrice *price)
Convert a price pointer into a GtkTreePath.

◆ gppat_filter_clear_all_cb()

void gppat_filter_clear_all_cb ( GtkWidget *  button,
AccountFilterDialog fd 
)

The "clear all account types" button in the Filter dialog was clicked.

Clear all account types shown, and update the visible page.

Parameters
buttonThe button that was clicked.
fdA pointer to the account filter dialog struct.

Definition at line 2151 of file gnc-tree-view-account.c.

2153{
2154 g_return_if_fail(GTK_IS_BUTTON(button));
2155
2156 ENTER("button %p", button);
2157 fd->visible_types = 0;
2158 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2159 gnc_tree_view_account_refilter(fd->tree_view);
2160 LEAVE("types 0x%x", fd->visible_types);
2161}

◆ gppat_filter_response_cb()

void gppat_filter_response_cb ( GtkWidget *  dialog,
gint  response,
AccountFilterDialog fd 
)

The Filter dialog was closed.

Check to see if this was done via the OK button. If so, make the changes permanent. If not, revert any changes.

Parameters
dialogA pointer to the "Filter By" dialog.
responseThe response code from closing the dialog.
fdA pointer to the account filter dialog struct.

Definition at line 2265 of file gnc-tree-view-account.c.

2268{
2269 gpointer gptemp;
2270
2271 g_return_if_fail(GTK_IS_DIALOG(dialog));
2272
2273 ENTER("dialog %p, response %d", dialog, response);
2274
2275 if (response != GTK_RESPONSE_OK)
2276 {
2277 fd->visible_types = fd->original_visible_types;
2278 fd->show_hidden = fd->original_show_hidden;
2279 fd->show_zero_total = fd->original_show_zero_total;
2280 fd->show_unused = fd->original_show_unused;
2281 gnc_tree_view_account_refilter(fd->tree_view);
2282 }
2283
2284 /* Clean up and delete dialog */
2285 gptemp = (gpointer)fd->dialog;
2286 g_atomic_pointer_compare_and_exchange(&gptemp,
2287 (gpointer)dialog, NULL);
2288 fd->dialog = gptemp;
2289 gtk_widget_destroy(dialog);
2290 LEAVE("types 0x%x", fd->visible_types);
2291}

◆ gppat_filter_select_all_cb()

void gppat_filter_select_all_cb ( GtkWidget *  button,
AccountFilterDialog fd 
)

The "select all account types" button in the Filter dialog was clicked.

Make all account types visible, and update the page.

Parameters
buttonThe button that was clicked.
fdA pointer to the account filter dialog struct.

Definition at line 2170 of file gnc-tree-view-account.c.

2172{
2173 g_return_if_fail(GTK_IS_BUTTON(button));
2174
2175 ENTER("button %p", button);
2176 fd->visible_types = -1;
2177 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2178 gnc_tree_view_account_refilter(fd->tree_view);
2179 LEAVE("types 0x%x", fd->visible_types);
2180}

◆ gppat_filter_select_default_cb()

void gppat_filter_select_default_cb ( GtkWidget *  button,
AccountFilterDialog fd 
)

The "select default account types" button in the Filter dialog was clicked.

Set all account types to their default visibility (which happens to be visible for all of them), and update the page.

Parameters
buttonThe button that was clicked.
fdA pointer to the account filter dialog struct.

Definition at line 2190 of file gnc-tree-view-account.c.

2192{
2193 ENTER("button %p", button);
2194 gppat_filter_select_all_cb(button, fd);
2195 LEAVE(" ");
2196}
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select all account types" button in the Filter dialog was clicked.

◆ gppat_filter_show_hidden_toggled_cb()

void gppat_filter_show_hidden_toggled_cb ( GtkToggleButton *  button,
AccountFilterDialog fd 
)

The "show hidden" button in the Filter dialog changed state.

Update the page to reflect these changes.

Parameters
buttonThe GtkCheckButton that was toggled.
fdA pointer to the account filter dialog struct.

Definition at line 2093 of file gnc-tree-view-account.c.

2095{
2096 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2097
2098 ENTER("button %p", button);
2099 fd->show_hidden = gtk_toggle_button_get_active(button);
2100 gnc_tree_view_account_refilter(fd->tree_view);
2101 LEAVE("show_hidden %d", fd->show_hidden);
2102}

◆ gppat_filter_show_unused_toggled_cb()

void gppat_filter_show_unused_toggled_cb ( GtkToggleButton *  button,
AccountFilterDialog fd 
)

The "show unused" button in the Filter dialog changed state.

Update the page to reflect these changes.

Parameters
buttonThe GtkCheckButton that was toggled.
fdA pointer to the account filter dialog struct.

Definition at line 2131 of file gnc-tree-view-account.c.

2133{
2134 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2135
2136 ENTER("button %p", button);
2137 fd->show_unused = gtk_toggle_button_get_active(button);
2138 gnc_tree_view_account_refilter(fd->tree_view);
2139 LEAVE("show_unused %d", fd->show_unused);
2140}

◆ gppat_filter_show_zero_toggled_cb()

void gppat_filter_show_zero_toggled_cb ( GtkToggleButton *  button,
AccountFilterDialog fd 
)

The "show zero totals" button in the Filter dialog changed state.

Update the page to reflect these changes.

Parameters
buttonThe GtkCheckButton that was toggled.
fdA pointer to the account filter dialog struct.

Definition at line 2112 of file gnc-tree-view-account.c.

2114{
2115 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2116
2117 ENTER("button %p", button);
2118 fd->show_zero_total = gtk_toggle_button_get_active(button);
2119 gnc_tree_view_account_refilter(fd->tree_view);
2120 LEAVE("show_zero %d", fd->show_zero_total);
2121}

◆ gppot_filter_response_cb()

void gppot_filter_response_cb ( GtkWidget *  dialog,
gint  response,
OwnerFilterDialog fd 
)

The Filter dialog was closed.

Check to see if this was done via the OK button. If so, make the changes permanent. If not, revert any changes.

Parameters
dialogA pointer to the "Filter By" dialog.
responseThe response code from closing the dialog.
fdA pointer to the owner filter dialog struct.

Definition at line 1098 of file gnc-tree-view-owner.c.

1101{
1102 gpointer gptemp;
1103
1104 g_return_if_fail(GTK_IS_DIALOG(dialog));
1105
1106 ENTER("dialog %p, response %d", dialog, response);
1107
1108 if (response != GTK_RESPONSE_OK)
1109 {
1110 fd->show_inactive = fd->original_show_inactive;
1111 fd->show_zero_total = fd->original_show_zero_total;
1112 gnc_tree_view_owner_refilter(fd->tree_view);
1113 }
1114
1115 /* Clean up and delete dialog */
1116 gptemp = (gpointer)fd->dialog;
1117 g_atomic_pointer_compare_and_exchange(&gptemp,
1118 (gpointer)dialog, NULL);
1119 fd->dialog = gptemp;
1120 gtk_widget_destroy(dialog);
1121 LEAVE("");
1122}

◆ gppot_filter_show_inactive_toggled_cb()

void gppot_filter_show_inactive_toggled_cb ( GtkToggleButton *  button,
OwnerFilterDialog fd 
)

The "only show active" button in the Filter dialog changed state.

Update the page to reflect these changes.

Parameters
buttonThe GtkCheckButton that was toggled.
fdA pointer to the owner filter dialog struct.

Definition at line 1059 of file gnc-tree-view-owner.c.

1061{
1062 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1063
1064 ENTER("button %p", button);
1065 fd->show_inactive = !gtk_toggle_button_get_active(button);
1066 gnc_tree_view_owner_refilter(fd->tree_view);
1067 LEAVE("show_inactive %d", fd->show_inactive);
1068}

◆ gppot_filter_show_zero_toggled_cb()

void gppot_filter_show_zero_toggled_cb ( GtkToggleButton *  button,
OwnerFilterDialog fd 
)

The "show zero totals" button in the Filter dialog changed state.

Update the page to reflect these changes.

Parameters
buttonThe GtkCheckButton that was toggled.
fdA pointer to the owner filter dialog struct.

Definition at line 1077 of file gnc-tree-view-owner.c.

1079{
1080 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1081
1082 ENTER("button %p", button);
1083 fd->show_zero_total = gtk_toggle_button_get_active(button);
1084 gnc_tree_view_owner_refilter(fd->tree_view);
1085 LEAVE("show_zero %d", fd->show_zero_total);
1086}

◆ owner_filter_dialog_create()

void owner_filter_dialog_create ( OwnerFilterDialog fd,
GncPluginPage page 
)

Definition at line 1125 of file gnc-tree-view-owner.c.

1126{
1127 GtkWidget *dialog, *button;
1128 GtkBuilder *builder;
1129 gchar *title;
1130
1131 ENTER("(fd %p, page %p)", fd, page);
1132
1133 if (fd->dialog)
1134 {
1135 gtk_window_present(GTK_WINDOW(fd->dialog));
1136 LEAVE("existing dialog");
1137 return;
1138 }
1139
1140 /* Create the dialog */
1141 builder = gtk_builder_new();
1142 gnc_builder_add_from_file (builder, "gnc-tree-view-owner.glade", "filter_by_dialog");
1143 dialog = GTK_WIDGET(gtk_builder_get_object (builder, "filter_by_dialog"));
1144 fd->dialog = dialog;
1145 gtk_window_set_transient_for(GTK_WINDOW(dialog),
1146 GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
1147 /* Translators: The %s is the name of the plugin page */
1148 title = g_strdup_printf(_("Filter %s by…"),
1149 gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
1150 gtk_window_set_title(GTK_WINDOW(dialog), title);
1151 g_free(title);
1152
1153 /* Remember current state */
1154 fd->original_show_inactive = fd->show_inactive;
1155 fd->original_show_zero_total = fd->show_zero_total;
1156
1157 /* Update the dialog widgets for the current state */
1158 button = GTK_WIDGET(gtk_builder_get_object (builder, "show_inactive"));
1159 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
1160 !fd->show_inactive);
1161 button = GTK_WIDGET(gtk_builder_get_object (builder, "show_zero"));
1162 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button),
1163 fd->show_zero_total);
1164
1165 /* Wire up the rest of the callbacks */
1166 gtk_builder_connect_signals (builder, fd);
1167 g_object_unref(G_OBJECT(builder));
1168
1169 /* Show it */
1170 gtk_widget_show_all (dialog);
1171 LEAVE(" ");
1172}

Variable Documentation

◆ dialog

GtkWidget* OwnerFilterDialog::dialog

Definition at line 64 of file gnc-tree-view-owner.h.

◆ original_show_inactive

gboolean OwnerFilterDialog::original_show_inactive

Definition at line 67 of file gnc-tree-view-owner.h.

◆ original_show_zero_total

gboolean OwnerFilterDialog::original_show_zero_total

Definition at line 69 of file gnc-tree-view-owner.h.

◆ show_inactive [1/2]

gboolean OwnerViewInfo::show_inactive

Definition at line 58 of file gnc-tree-view-owner.h.

◆ show_inactive [2/2]

gboolean OwnerFilterDialog::show_inactive

Definition at line 66 of file gnc-tree-view-owner.h.

◆ show_zero_total

gboolean OwnerFilterDialog::show_zero_total

Definition at line 68 of file gnc-tree-view-owner.h.

◆ tree_view

GncTreeViewOwner* OwnerFilterDialog::tree_view

Definition at line 65 of file gnc-tree-view-owner.h.