GnuCash  5.6-150-g038405b370+
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_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. More...
 
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. More...
 
void gppat_filter_show_hidden_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show hidden" button in the Filter dialog changed state. More...
 
void gppat_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show zero totals" button in the Filter dialog changed state. More...
 
void gppat_filter_show_unused_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 The "show unused" button in the Filter dialog changed state. More...
 
void gppat_filter_clear_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 The "clear all account types" button in the Filter dialog was clicked. More...
 
void gppat_filter_select_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 The "select all account types" button in the Filter dialog was clicked. More...
 
void gppat_filter_select_default_cb (GtkWidget *button, AccountFilterDialog *fd)
 The "select default account types" button in the Filter dialog was clicked. More...
 
void gppat_filter_response_cb (GtkWidget *dialog, gint response, AccountFilterDialog *fd)
 The Filter dialog was closed. More...
 
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. More...
 
void gppot_filter_show_inactive_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 The "only show active" button in the Filter dialog changed state. More...
 
void gppot_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 The "show zero totals" button in the Filter dialog changed state. More...
 
void gppot_filter_response_cb (GtkWidget *dialog, gint response, OwnerFilterDialog *fd)
 The Filter dialog was closed. More...
 
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 Model Constructors

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

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. More...
 
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. More...
 
GtkTreePath * gnc_tree_model_account_get_path_from_account (GncTreeModelAccount *model, Account *account)
 Convert a model/account pair into a gtk_tree_model_path. More...
 

Account Tree Model Constructors

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

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. More...
 
gboolean gnc_tree_model_commodity_iter_is_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a commodity. More...
 
gnc_commodity_namespace * gnc_tree_model_commodity_get_namespace (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity namespace. More...
 
gnc_commodity * gnc_tree_model_commodity_get_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity. More...
 

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. More...
 
gboolean gnc_tree_model_commodity_get_iter_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity, GtkTreeIter *iter)
 Convert a commodity pointer into a GtkTreeIter. More...
 
GtkTreePath * gnc_tree_model_commodity_get_path_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity)
 Convert a commodity pointer into a GtkTreePath. More...
 

Owner Tree Model Constructors

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

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. More...
 
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. More...
 
GtkTreePath * gnc_tree_model_owner_get_path_from_owner (GncTreeModelOwner *model, GncOwner *owner)
 Convert a model/owner pair into a gtk_tree_model_path. More...
 

Account Tree Model Constructors

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

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". More...
 
gboolean gnc_tree_model_price_iter_is_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a commodity. More...
 
gboolean gnc_tree_model_price_iter_is_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 Determine whether or not the specified GtkTreeIter points to a price. More...
 
gnc_commodity_namespace * gnc_tree_model_price_get_namespace (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity namespace. More...
 
gnc_commodity * gnc_tree_model_price_get_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash commodity. More...
 
GNCPrice * gnc_tree_model_price_get_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 Convert a model/iter pair to a gnucash price. More...
 

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. More...
 
gboolean gnc_tree_model_price_get_iter_from_commodity (GncTreeModelPrice *model, gnc_commodity *commodity, GtkTreeIter *iter)
 Convert a commodity pointer into a GtkTreeIter. More...
 
gboolean gnc_tree_model_price_get_iter_from_price (GncTreeModelPrice *model, GNCPrice *price, GtkTreeIter *iter)
 Convert a price pointer into a GtkTreeIter. More...
 
GtkTreePath * gnc_tree_model_price_get_path_from_price (GncTreeModelPrice *model, GNCPrice *price)
 Convert a price pointer into a GtkTreePath. More...
 

Account Tree View Constructors

GtkTreeView * gnc_tree_view_account_new_with_root (Account *root, gboolean show_root)
 Create a new account tree view. More...
 
GtkTreeView * gnc_tree_view_account_new (gboolean show_root)
 Create a new account tree view. More...
 

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

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

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. More...
 
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. More...
 
Accountgnc_tree_view_account_get_account_from_path (GncTreeViewAccount *view, GtkTreePath *path)
 This function returns the account associated with the specified path. More...
 
Accountgnc_tree_view_account_get_account_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 This function returns the account associated with the specified iter. More...
 
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. More...
 
Accountgnc_tree_view_account_get_selected_account (GncTreeViewAccount *view)
 This function returns the account associated with the selected item in the account tree view. More...
 
void gnc_tree_view_account_set_selected_account (GncTreeViewAccount *view, Account *account)
 This function selects an account in the account tree view. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

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

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. More...
 
void gnc_tree_view_commodity_refilter (GncTreeViewCommodity *view)
 This function forces the commodity tree filter to be evaluated. More...
 

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. More...
 
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. More...
 
void gnc_tree_view_commodity_select_commodity (GncTreeViewCommodity *view, gnc_commodity *commodity)
 Select the commodity in the associated commodity tree view. More...
 
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. More...
 

Owner Tree View Constructor

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

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. More...
 
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. More...
 
void gnc_tree_view_owner_refilter (GncTreeViewOwner *view)
 This function forces the owner tree filter to be evaluated. More...
 

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. More...
 
GncOwnergnc_tree_view_owner_get_owner_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 This function returns the owner associated with the specified iter. More...
 
GncOwnergnc_tree_view_owner_get_selected_owner (GncTreeViewOwner *view)
 This function returns the owner associated with the selected item in the owner tree view. More...
 
void gnc_tree_view_owner_set_selected_owner (GncTreeViewOwner *view, GncOwner *owner)
 This function selects an owner in the owner tree view. More...
 

Price Tree View Constructors

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

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. More...
 
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)
 

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. More...
 
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. More...
 
void gnc_tree_view_price_set_selected_price (GncTreeViewPrice *view, GNCPrice *price)
 This function selects an price in the price tree view. More...
 
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. More...
 
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. More...
 

Detailed Description

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

Function Documentation

◆ 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 2029 of file gnc-tree-view-account.c.

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

◆ 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 }
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 576 of file gnc-tree-model-account.c.

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

◆ 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 1244 of file gnc-tree-model-account.c.

1246 {
1247  g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1248  g_return_val_if_fail (iter != NULL, NULL);
1249  g_return_val_if_fail (iter->user_data != NULL, NULL);
1250  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
1251 
1252  return (Account *) iter->user_data;
1253 }
STRUCTS.

◆ 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 1261 of file gnc-tree-model-account.c.

1264 {
1265  Account *parent;
1266  gint i;
1267 
1268  ENTER("model %p, account %p, iter %p", model, account, iter);
1269  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), FALSE);
1270  gnc_leave_return_val_if_fail ((account != NULL), FALSE);
1271  gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
1272 
1273  iter->user_data = account;
1274  iter->stamp = model->stamp;
1275 
1276  if (account == model->root)
1277  {
1278  iter->user_data2 = NULL;
1279  iter->user_data3 = GINT_TO_POINTER(0);
1280  LEAVE("Matched root");
1281  return TRUE;
1282  }
1283 
1284  if (model->root != gnc_account_get_root (account))
1285  {
1286  LEAVE("Root doesn't match");
1287  return FALSE;
1288  }
1289 
1290  parent = gnc_account_get_parent (account);
1291  i = gnc_account_child_index (parent, account);
1292  iter->user_data2 = parent;
1293  iter->user_data3 = GINT_TO_POINTER(i);
1294  LEAVE("iter %s", iter_to_string (iter));
1295  return (i != -1);
1296 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.cpp:2906
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
gint gnc_account_child_index(const Account *parent, const Account *child)
Return the index of the specified child within the list of the parent&#39;s children. ...
Definition: Account.cpp:2954
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:2913

◆ 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 1304 of file gnc-tree-model-account.c.

1306 {
1307  GtkTreeIter tree_iter;
1308  GtkTreePath *tree_path;
1309 
1310  ENTER("model %p, account %p", model, account);
1311  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1312  gnc_leave_return_val_if_fail (account != NULL, NULL);
1313 
1314  if (!gnc_tree_model_account_get_iter_from_account (model, account,
1315  &tree_iter))
1316  {
1317  LEAVE("no iter");
1318  return NULL;
1319  }
1320 
1321  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1322  if (tree_path)
1323  {
1324  gchar *path_string = gtk_tree_path_to_string (tree_path);
1325  LEAVE("path (2) %s", path_string);
1326  g_free (path_string);
1327  }
1328  else
1329  {
1330  LEAVE("no path");
1331  }
1332  return tree_path;
1333 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#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
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 252 of file gnc-tree-model-account.c.

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

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
Definition: qofevent.cpp:73
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#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
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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 
843  if (!gnc_tree_model_owner_get_iter_from_owner (model, owner,
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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#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
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
OwnerList * gncBusinessGetOwnerList(QofBook *book, QofIdTypeConst type_name, gboolean all_including_inactive)
Returns a GList of all objects of the given type_name in the given book, but each object is wrapped i...
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
void(* QofEventHandler)(QofInstance *ent, QofEventId event_type, gpointer handler_data, gpointer event_data)
Handler invoked when an event is generated.
Definition: qofevent.h:89
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
Definition: qofevent.cpp:73
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition: gncOwner.c:235
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 
1217  list = gnc_commodity_namespace_get_commodity_list(name_space);
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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
gpointer qof_book_get_data(const QofBook *book, const gchar *key)
Retrieves arbitrary pointers to structs stored by qof_book_set_data.
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_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  {
1141  gnc_price_list_destroy(list);
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);
1150  gnc_price_list_destroy(list);
1151  LEAVE("iter %s", iter_to_string(model, iter));
1152  return TRUE;
1153 }
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...
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
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.

◆ 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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
Definition: qofevent.cpp:73
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 1967 of file gnc-tree-view-account.c.

1973 {
1974  GtkCellRenderer *renderer;
1975 
1976  g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view), NULL);
1977 
1978  renderer = gtk_cell_renderer_text_new();
1979 
1980  return gnc_tree_view_account_add_custom_column_renderer(
1981  account_view, column_title, col_source_cb, col_edited_cb, renderer);
1982 }

◆ 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 1868 of file gnc-tree-view-account.c.

1871 {
1872  GtkCellRenderer *renderer;
1873  GtkTreeViewColumn *column;
1874 
1875  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1876  g_return_val_if_fail (propname != NULL, NULL);
1877 
1878  column = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), column_title,
1879  propname, NULL, "Sample text",
1880  -1, -1, NULL);
1881 
1882  /* This new kvp column has only had one renderer added to it so
1883  * far. Find that renderer. */
1884  renderer = gnc_tree_view_column_get_renderer(column);
1885  g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
1886 
1887  // add a pointer to the view to make it easier to access in data_func
1888  g_object_set_data(G_OBJECT(column), "tree-view", (gpointer)view);
1889 
1890  gtk_tree_view_column_set_cell_data_func (column, renderer,
1891  account_cell_property_data_func,
1892  g_strdup(propname), g_free);
1893  return column;
1894 }
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 1190 of file gnc-tree-view-account.c.

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

◆ 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 1161 of file gnc-tree-view-account.c.

1163 {
1164  GtkTreeModel *s_model;
1165  GtkTreeIter s_iter;
1166  gint num_children;
1167 
1168  ENTER("view %p, account %p (%s)", view, account, xaccAccountGetName(account));
1169 
1170  if (account == NULL)
1171  {
1172  LEAVE("no account");
1173  return 0;
1174  }
1175 
1176  if (!gnc_tree_view_account_get_iter_from_account (view, account, &s_iter))
1177  {
1178  LEAVE("view_get_iter_from_account failed");
1179  return 0;
1180  }
1181 
1182  /* Any children? */
1183  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1184  num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
1185  LEAVE("%d children", num_children);
1186  return num_children;
1187 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3259

◆ 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 1734 of file gnc-tree-view-account.c.

1736 {
1737  GtkTreePath *path;
1738 
1739  g_return_if_fail(view != NULL);
1740  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1741  ENTER("view %p, account %p", view, account);
1742 
1743  path = gnc_tree_view_account_get_path_from_account(view, account);
1744  if (path)
1745  {
1746  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1747  gtk_tree_path_free(path);
1748  }
1749  LEAVE(" ");
1750 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 1373 of file gnc-tree-view-account.c.

1375 {
1376  GtkTreeModel *model, *f_model;
1377  GtkTreeIter iter, f_iter;
1378  Account *account;
1379 
1380  g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1381  g_return_val_if_fail (s_iter != NULL, NULL);
1382 
1383  ENTER("model %p, iter %p", s_model, s_iter);
1384 
1385  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1386  &f_iter,
1387  s_iter);
1388  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1389  gtk_tree_model_filter_convert_iter_to_child_iter (
1390  GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1391  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1393  GNC_TREE_MODEL_ACCOUNT(model), &iter);
1394  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1395  return account;
1396 }
STRUCTS.
Account * gnc_tree_model_account_get_account(GncTreeModelAccount *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash account.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3259

◆ 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 1327 of file gnc-tree-view-account.c.

1329 {
1330  GtkTreeModel *model, *f_model, *s_model;
1331  GtkTreePath *path, *f_path;
1332  GtkTreeIter iter;
1333  Account *account;
1334 
1335  ENTER("view %p", view);
1336  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1337  g_return_val_if_fail (s_path != NULL, NULL);
1338 
1339  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1340  f_path = gtk_tree_model_sort_convert_path_to_child_path (
1341  GTK_TREE_MODEL_SORT (s_model), s_path);
1342  if (!f_path)
1343  {
1344  LEAVE("no filter path");
1345  return NULL;
1346  }
1347 
1348  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1349  path = gtk_tree_model_filter_convert_path_to_child_path (
1350  GTK_TREE_MODEL_FILTER (f_model), f_path);
1351  gtk_tree_path_free(f_path);
1352  if (!path)
1353  {
1354  LEAVE("no path");
1355  return NULL;
1356  }
1357 
1358  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1359  if (!gtk_tree_model_get_iter (model, &iter, path))
1360  {
1361  LEAVE("no iter");
1362  return NULL;
1363  }
1364 
1365  account = iter.user_data;
1366  gtk_tree_path_free(path);
1367  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1368  return account;
1369 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3259

◆ 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 1757 of file gnc-tree-view-account.c.

1758 {
1759  GtkTreePath *s_path;
1760  Account *account;
1761 
1762  ENTER("view %p", view);
1763  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1764 
1765  gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1766  if (!s_path)
1767  {
1768  LEAVE("no account");
1769  return NULL;
1770  }
1771 
1772  account = gnc_tree_view_account_get_account_from_path (view, s_path);
1773  gtk_tree_path_free(s_path);
1774  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1775  return account;
1776 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
This function returns the account associated with the specified path.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3259

◆ 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 1404 of file gnc-tree-view-account.c.

1405 {
1406  GtkTreeSelection *selection;
1407  GtkTreeModel *f_model, *s_model;
1408  GtkTreeIter iter, f_iter, s_iter;
1409  Account *account;
1410  GtkSelectionMode mode;
1411 
1412  ENTER("view %p", view);
1413  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1414 
1415  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1416  mode = gtk_tree_selection_get_mode(selection);
1417  if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
1418  {
1419  return NULL;
1420  }
1421  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
1422  {
1423  LEAVE("no account, get_selected failed");
1424  return FALSE;
1425  }
1426 
1427  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1428  &f_iter, &s_iter);
1429 
1430  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1431  gtk_tree_model_filter_convert_iter_to_child_iter (
1432  GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
1433 
1434  account = iter.user_data;
1435  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1436  return account;
1437 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3259

◆ 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 1562 of file gnc-tree-view-account.c.

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

◆ 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 1210 of file gnc-tree-view-account.c.

1212 {
1213  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1214  g_return_if_fail(avi != NULL);
1215 
1216  *avi = view->avi;
1217 }

◆ 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 1066 of file gnc-tree-view-account.c.

1067 {
1068  Account *root;
1069 
1070  root = gnc_book_get_root_account (gnc_get_current_book ());
1071  return gnc_tree_view_account_new_with_root (root, show_root);
1072 }
STRUCTS.
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 761 of file gnc-tree-view-account.c.

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

◆ 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 1293 of file gnc-tree-view-account.c.

1294 {
1295  GtkTreeModel *f_model, *s_model;
1296 
1297  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1298 
1299  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1300  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1301  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
1302 }

◆ 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 1662 of file gnc-tree-view-account.c.

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

◆ 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 1267 of file gnc-tree-view-account.c.

1271 {
1272  ENTER("view %p, filter func %p, data %p, destroy %p",
1273  view, func, data, destroy);
1274 
1275  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1276 
1277  if (view->filter_destroy)
1278  {
1279  view->filter_destroy(view->filter_data);
1280  }
1281  view->filter_destroy = destroy;
1282  view->filter_data = data;
1283  view->filter_fn = func;
1284 
1286  LEAVE(" ");
1287 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 1444 of file gnc-tree-view-account.c.

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

◆ 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 1582 of file gnc-tree-view-account.c.

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

◆ 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 1224 of file gnc-tree-view-account.c.

1226 {
1227  ENTER("%p", view);
1228  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1229  g_return_if_fail(avi != NULL);
1230 
1231  view->avi = *avi;
1232 
1234  view, gnc_tree_view_account_filter_by_view_info,
1235  &view->avi, NULL);
1236 
1237  LEAVE(" ");
1238 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 FALSE;
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 }
gnc_commodity * gnc_tree_model_commodity_get_commodity(GncTreeModelCommodity *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash commodity.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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. */
323  ct = gnc_commodity_table_get_table (book);
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.
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
GtkTreeModel * gnc_tree_model_commodity_new(QofBook *book, gnc_commodity_table *ct)
Create a new GtkTreeModel for manipulating gnucash commodities.
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 651 of file gnc-tree-view-commodity.c.

652 {
653  GtkTreeSelection *selection;
654  GtkTreeModel *model, *f_model, *s_model;
655  GtkTreePath *tree_path;
656  GtkTreePath *f_tree_path;
657  GtkTreePath *s_tree_path;
658 
659  g_return_if_fail (GNC_IS_TREE_VIEW_COMMODITY(view));
660 
661  if (!commodity)
662  return;
663 
664  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
665 
666  s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
667  f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
668  model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
669 
670  tree_path = gnc_tree_model_commodity_get_path_from_commodity (GNC_TREE_MODEL_COMMODITY(model), commodity);
671 
672  if (tree_path)
673  {
674  f_tree_path = gtk_tree_model_filter_convert_child_path_to_path
675  (GTK_TREE_MODEL_FILTER (f_model), tree_path);
676 
677  s_tree_path = gtk_tree_model_sort_convert_child_path_to_path
678  (GTK_TREE_MODEL_SORT (s_model), f_tree_path);
679 
680  gtk_tree_view_expand_to_path (GTK_TREE_VIEW(view), s_tree_path);
681  gtk_tree_selection_select_path (selection, s_tree_path);
682  gtk_tree_path_free (tree_path);
683  gtk_tree_path_free (f_tree_path);
684  gtk_tree_path_free (s_tree_path);
685  }
686 }
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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GncOwner * gnc_tree_model_owner_get_owner(GncTreeModelOwner *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash owner.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
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.
GtkTreeModel * gnc_tree_model_owner_new(GncOwnerType owner_type)
Create a new GtkTreeModel for manipulating gnucash owners.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition: gncOwner.c:235
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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_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 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
This function forces the owner tree filter to be evaluated.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GtkTreePath * gnc_tree_model_owner_get_path_from_owner(GncTreeModelOwner *model, GncOwner *owner)
Convert a model/owner pair into a gtk_tree_model_path.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Return the pricedb associated with the book.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
const char * gnc_commodity_get_printname(const gnc_commodity *cm)
Retrieve the &#39;print&#39; 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.
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.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GtkTreePath * gnc_tree_model_price_get_path_from_price(GncTreeModelPrice *model, GNCPrice *price)
Convert a price pointer into a GtkTreePath.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2147 of file gnc-tree-view-account.c.

2149 {
2150  g_return_if_fail(GTK_IS_BUTTON(button));
2151 
2152  ENTER("button %p", button);
2153  fd->visible_types = 0;
2154  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2155  gnc_tree_view_account_refilter(fd->tree_view);
2156  LEAVE("types 0x%x", fd->visible_types);
2157 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2261 of file gnc-tree-view-account.c.

2264 {
2265  gpointer gptemp;
2266 
2267  g_return_if_fail(GTK_IS_DIALOG(dialog));
2268 
2269  ENTER("dialog %p, response %d", dialog, response);
2270 
2271  if (response != GTK_RESPONSE_OK)
2272  {
2273  fd->visible_types = fd->original_visible_types;
2274  fd->show_hidden = fd->original_show_hidden;
2275  fd->show_zero_total = fd->original_show_zero_total;
2276  fd->show_unused = fd->original_show_unused;
2277  gnc_tree_view_account_refilter(fd->tree_view);
2278  }
2279 
2280  /* Clean up and delete dialog */
2281  gptemp = (gpointer)fd->dialog;
2282  g_atomic_pointer_compare_and_exchange(&gptemp,
2283  (gpointer)dialog, NULL);
2284  fd->dialog = gptemp;
2285  gtk_widget_destroy(dialog);
2286  LEAVE("types 0x%x", fd->visible_types);
2287 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2166 of file gnc-tree-view-account.c.

2168 {
2169  g_return_if_fail(GTK_IS_BUTTON(button));
2170 
2171  ENTER("button %p", button);
2172  fd->visible_types = -1;
2173  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2174  gnc_tree_view_account_refilter(fd->tree_view);
2175  LEAVE("types 0x%x", fd->visible_types);
2176 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2186 of file gnc-tree-view-account.c.

2188 {
2189  ENTER("button %p", button);
2190  gppat_filter_select_all_cb(button, fd);
2191  LEAVE(" ");
2192 }
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select all account types" button in the Filter dialog was clicked.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2089 of file gnc-tree-view-account.c.

2091 {
2092  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2093 
2094  ENTER("button %p", button);
2095  fd->show_hidden = gtk_toggle_button_get_active(button);
2096  gnc_tree_view_account_refilter(fd->tree_view);
2097  LEAVE("show_hidden %d", fd->show_hidden);
2098 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2127 of file gnc-tree-view-account.c.

2129 {
2130  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2131 
2132  ENTER("button %p", button);
2133  fd->show_unused = gtk_toggle_button_get_active(button);
2134  gnc_tree_view_account_refilter(fd->tree_view);
2135  LEAVE("show_unused %d", fd->show_unused);
2136 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 2108 of file gnc-tree-view-account.c.

2110 {
2111  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2112 
2113  ENTER("button %p", button);
2114  fd->show_zero_total = gtk_toggle_button_get_active(button);
2115  gnc_tree_view_account_refilter(fd->tree_view);
2116  LEAVE("show_zero %d", fd->show_zero_total);
2117 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
This function forces the owner tree filter to be evaluated.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
This function forces the owner tree filter to be evaluated.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
This function forces the owner tree filter to be evaluated.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282