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_EARLIEST_DATE, GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
  GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_TOTAL, GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
  GNC_TREE_MODEL_ACCOUNT_COL_NOTES, GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO, GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT, GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
  GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER, GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE, GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
  GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS
}
 
enum  GncTreeModelCommodityColumn {
  GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE, GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC, GNC_TREE_MODEL_COMMODITY_COL_USER_SYMBOL, GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
  GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME, GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME, GNC_TREE_MODEL_COMMODITY_COL_CUSIP, GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
  GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG, GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE, GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ, GNC_TREE_MODEL_COMMODITY_COL_LAST_VISIBLE = GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY, GNC_TREE_MODEL_COMMODITY_NUM_COLUMNS
}
 
enum  GncTreeModelOwnerColumn {
  GNC_TREE_MODEL_OWNER_COL_NAME, GNC_TREE_MODEL_OWNER_COL_TYPE, GNC_TREE_MODEL_OWNER_COL_ID, GNC_TREE_MODEL_OWNER_COL_CURRENCY,
  GNC_TREE_MODEL_OWNER_COL_ADDRESS_NAME, GNC_TREE_MODEL_OWNER_COL_ADDRESS_1, GNC_TREE_MODEL_OWNER_COL_ADDRESS_2, GNC_TREE_MODEL_OWNER_COL_ADDRESS_3,
  GNC_TREE_MODEL_OWNER_COL_ADDRESS_4, GNC_TREE_MODEL_OWNER_COL_PHONE, GNC_TREE_MODEL_OWNER_COL_FAX, GNC_TREE_MODEL_OWNER_COL_EMAIL,
  GNC_TREE_MODEL_OWNER_COL_BALANCE, GNC_TREE_MODEL_OWNER_COL_BALANCE_REPORT, GNC_TREE_MODEL_OWNER_COL_NOTES, GNC_TREE_MODEL_OWNER_COL_ACTIVE,
  GNC_TREE_MODEL_OWNER_COL_LAST_VISIBLE = GNC_TREE_MODEL_OWNER_COL_ACTIVE, GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE, GNC_TREE_MODEL_OWNER_NUM_COLUMNS
}
 
enum  GncTreeModelPriceColumn {
  GNC_TREE_MODEL_PRICE_COL_COMMODITY, GNC_TREE_MODEL_PRICE_COL_CURRENCY, GNC_TREE_MODEL_PRICE_COL_DATE, GNC_TREE_MODEL_PRICE_COL_SOURCE,
  GNC_TREE_MODEL_PRICE_COL_TYPE, GNC_TREE_MODEL_PRICE_COL_VALUE, GNC_TREE_MODEL_PRICE_COL_LAST_VISIBLE = GNC_TREE_MODEL_PRICE_COL_VALUE, GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
  GNC_TREE_MODEL_PRICE_NUM_COLUMNS
}
 

Functions

GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types)
 
void gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model, guint32 types)
 
guint32 gnc_tree_model_account_types_get_mask (GtkTreeModel *f_model)
 
guint32 gnc_tree_model_account_types_get_selection (GtkTreeSelection *sel)
 
GNCAccountType gnc_tree_model_account_types_get_selection_single (GtkTreeSelection *sel)
 
GNCAccountType gnc_tree_model_account_types_get_active_combo (GtkComboBox *combo)
 
void gnc_tree_model_account_types_set_selection (GtkTreeSelection *sel, guint32 selected)
 
void gnc_tree_model_account_types_set_active_combo (GtkComboBox *combo, guint32 selected)
 
GtkTreeModel * gnc_tree_model_account_types_new (guint32 selected)
 
void gnc_tree_model_account_clear_cache (GncTreeModelAccount *model)
 Clear the tree model account cached values. 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...
 
gnc_commodity_namespace * gnc_tree_view_commodity_get_selected_namespace (GncTreeViewCommodity *view)
 This function returns the namespace associated with the selected item in the commodity tree view. 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 2033 of file gnc-tree-view-account.c.

2035 {
2036  AccountFilterDialog *fd = user_data;
2037  GNCAccountType acct_type;
2038  gnc_numeric total;
2039  gboolean result;
2040 
2041  ENTER("account %p:%s", account, xaccAccountGetName(account));
2042 
2043  if (g_hash_table_size (fd->filter_override) > 0)
2044  {
2045  Account *test_acc = NULL;
2046  test_acc = g_hash_table_lookup (fd->filter_override, account);
2047  if (test_acc != NULL)
2048  {
2049  LEAVE(" filter: override");
2050  return TRUE;
2051  }
2052  }
2053 
2054  if (!fd->show_hidden && xaccAccountIsHidden (account))
2055  {
2056  LEAVE(" hide: hidden");
2057  return FALSE;
2058  }
2059 
2060  if (!fd->show_zero_total)
2061  {
2062  total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
2063  if (gnc_numeric_zero_p(total))
2064  {
2065  LEAVE(" hide: zero balance");
2066  return FALSE;
2067  }
2068  }
2069 
2070  if (!fd->show_unused)
2071  {
2072  if (gnc_account_and_descendants_empty(account))
2073  {
2074  LEAVE(" hide: unused");
2075  return FALSE;
2076  }
2077  }
2078 
2079  acct_type = xaccAccountGetType(account);
2080  result = (fd->visible_types & (1 << acct_type)) ? TRUE : FALSE;
2081  LEAVE(" %s", result ? "show" : "hide");
2082  return result;
2083 }
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account&#39;s account type.
Definition: Account.cpp:3234
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:4154
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:3256

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

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

◆ gnc_tree_model_account_get_account()

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

Convert a model/iter pair to a gnucash account.

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

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

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

1252 {
1253  g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1254  g_return_val_if_fail (iter != NULL, NULL);
1255  g_return_val_if_fail (iter->user_data != NULL, NULL);
1256  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
1257 
1258  return (Account *) iter->user_data;
1259 }
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 1267 of file gnc-tree-model-account.c.

1270 {
1271  Account *parent;
1272  gint i;
1273 
1274  ENTER("model %p, account %p, iter %p", model, account, iter);
1275  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), FALSE);
1276  gnc_leave_return_val_if_fail ((account != NULL), FALSE);
1277  gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
1278 
1279  iter->user_data = account;
1280  iter->stamp = model->stamp;
1281 
1282  if (account == model->root)
1283  {
1284  iter->user_data2 = NULL;
1285  iter->user_data3 = GINT_TO_POINTER(0);
1286  LEAVE("Matched root");
1287  return TRUE;
1288  }
1289 
1290  if (model->root != gnc_account_get_root (account))
1291  {
1292  LEAVE("Root doesn't match");
1293  return FALSE;
1294  }
1295 
1296  parent = gnc_account_get_parent (account);
1297  i = gnc_account_child_index (parent, account);
1298  iter->user_data2 = parent;
1299  iter->user_data3 = GINT_TO_POINTER(i);
1300  LEAVE("iter %s", iter_to_string (iter));
1301  return (i != -1);
1302 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.cpp:2902
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:2950
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:2909

◆ gnc_tree_model_account_get_path_from_account()

GtkTreePath* gnc_tree_model_account_get_path_from_account ( GncTreeModelAccount *  model,
Account account 
)

Convert a model/account pair into a gtk_tree_model_path.

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

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

1312 {
1313  GtkTreeIter tree_iter;
1314  GtkTreePath *tree_path;
1315 
1316  ENTER("model %p, account %p", model, account);
1317  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(model), NULL);
1318  gnc_leave_return_val_if_fail (account != NULL, NULL);
1319 
1320  if (!gnc_tree_model_account_get_iter_from_account (model, account,
1321  &tree_iter))
1322  {
1323  LEAVE("no iter");
1324  return NULL;
1325  }
1326 
1327  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1328  if (tree_path)
1329  {
1330  gchar *path_string = gtk_tree_path_to_string (tree_path);
1331  LEAVE("path (2) %s", path_string);
1332  g_free (path_string);
1333  }
1334  else
1335  {
1336  LEAVE("no path");
1337  }
1338  return tree_path;
1339 }
#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 256 of file gnc-tree-model-account.c.

257 {
258  GncTreeModelAccount *model;
259  const GList *item;
260 
261  ENTER("root %p", root);
262  item = gnc_gobject_tracking_get_list (GNC_TREE_MODEL_ACCOUNT_NAME);
263  for ( ; item; item = g_list_next (item))
264  {
265  model = (GncTreeModelAccount *)item->data;
266  if (model->root == root)
267  {
268  g_object_ref (G_OBJECT(model));
269  LEAVE("returning existing model %p", model);
270  return GTK_TREE_MODEL(model);
271  }
272  }
273 
274  model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT, NULL);
275 
276  model->book = gnc_get_current_book();
277  model->root = root;
278 
279  model->event_handler_id = qof_event_register_handler
280  ((QofEventHandler)gnc_tree_model_account_event_handler, model);
281 
282  LEAVE("model %p", model);
283  return GTK_TREE_MODEL(model);
284 }
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 1971 of file gnc-tree-view-account.c.

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

◆ gnc_tree_view_account_add_property_column()

GtkTreeViewColumn* gnc_tree_view_account_add_property_column ( GncTreeViewAccount *  view,
const gchar *  column_title,
const gchar *  propname 
)

Add a new column to the set of columns in an account tree view.

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

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

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

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

◆ gnc_tree_view_account_clear_model_cache()

void gnc_tree_view_account_clear_model_cache ( GncTreeViewAccount *  view)

This function clears the tree model account cache so the values will be updated/refreshed.

Parameters
viewA pointer to an account tree view.

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

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

◆ gnc_tree_view_account_count_children()

gint gnc_tree_view_account_count_children ( GncTreeViewAccount *  view,
Account account 
)

This function determines if an account in the account tree view has any visible children.

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

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

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

◆ gnc_tree_view_account_expand_to_account()

void gnc_tree_view_account_expand_to_account ( GncTreeViewAccount *  view,
Account account 
)

This function forces the account tree expand whatever levels are necessary to make the specified account visible.

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

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

1740 {
1741  GtkTreePath *path;
1742 
1743  g_return_if_fail(view != NULL);
1744  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1745  ENTER("view %p, account %p", view, account);
1746 
1747  path = gnc_tree_view_account_get_path_from_account(view, account);
1748  if (path)
1749  {
1750  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1751  gtk_tree_path_free(path);
1752  }
1753  LEAVE(" ");
1754 }
#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 1377 of file gnc-tree-view-account.c.

1379 {
1380  GtkTreeModel *model, *f_model;
1381  GtkTreeIter iter, f_iter;
1382  Account *account;
1383 
1384  g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1385  g_return_val_if_fail (s_iter != NULL, NULL);
1386 
1387  ENTER("model %p, iter %p", s_model, s_iter);
1388 
1389  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1390  &f_iter,
1391  s_iter);
1392  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1393  gtk_tree_model_filter_convert_iter_to_child_iter (
1394  GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1395  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1397  GNC_TREE_MODEL_ACCOUNT(model), &iter);
1398  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1399  return account;
1400 }
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:3256

◆ gnc_tree_view_account_get_account_from_path()

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

This function returns the account associated with the specified path.

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

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

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

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

◆ gnc_tree_view_account_get_cursor_account()

Account* gnc_tree_view_account_get_cursor_account ( GncTreeViewAccount *  view)

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

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

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

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

1762 {
1763  GtkTreePath *s_path;
1764  Account *account;
1765 
1766  ENTER("view %p", view);
1767  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1768 
1769  gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1770  if (!s_path)
1771  {
1772  LEAVE("no account");
1773  return NULL;
1774  }
1775 
1776  account = gnc_tree_view_account_get_account_from_path (view, s_path);
1777  gtk_tree_path_free(s_path);
1778  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1779  return account;
1780 }
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:3256

◆ gnc_tree_view_account_get_selected_account()

Account* gnc_tree_view_account_get_selected_account ( GncTreeViewAccount *  view)

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

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

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

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

◆ gnc_tree_view_account_get_selected_accounts()

GList* gnc_tree_view_account_get_selected_accounts ( GncTreeViewAccount *  view)

This function returns a list of the accounts associated with the selected items in the account tree view.

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

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

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

◆ gnc_tree_view_account_get_view_info()

void gnc_tree_view_account_get_view_info ( GncTreeViewAccount *  account_view,
AccountViewInfo *  avi 
)

Given pointers to an account tree and old style filter block, this function will copy the current configuration of the account tree widget into the data block.

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

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

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

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

◆ gnc_tree_view_account_new()

GtkTreeView* gnc_tree_view_account_new ( gboolean  show_root)

Create a new account tree view.

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

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

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

1071 {
1072  Account *root;
1073 
1074  root = gnc_book_get_root_account (gnc_get_current_book ());
1075  return gnc_tree_view_account_new_with_root (root, show_root);
1076 }
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 759 of file gnc-tree-view-account.c.

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

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

◆ gnc_tree_view_account_select_subaccounts()

void gnc_tree_view_account_select_subaccounts ( GncTreeViewAccount *  view,
Account account 
)

This function selects all sub-accounts of an account in the account tree view.

All other accounts will be unselected.

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

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

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

◆ gnc_tree_view_account_set_filter()

void gnc_tree_view_account_set_filter ( GncTreeViewAccount *  account_view,
gnc_tree_view_account_filter_func  func,
gpointer  data,
GSourceFunc  destroy 
)

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

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

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

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

1275 {
1276  ENTER("view %p, filter func %p, data %p, destroy %p",
1277  view, func, data, destroy);
1278 
1279  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1280 
1281  if (view->filter_destroy)
1282  {
1283  view->filter_destroy(view->filter_data);
1284  }
1285  view->filter_destroy = destroy;
1286  view->filter_data = data;
1287  view->filter_fn = func;
1288 
1290  LEAVE(" ");
1291 }
#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 1448 of file gnc-tree-view-account.c.

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

◆ gnc_tree_view_account_set_selected_accounts()

void gnc_tree_view_account_set_selected_accounts ( GncTreeViewAccount *  view,
GList *  account_list,
gboolean  show_last 
)

This function selects a set of accounts in the account tree view.

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

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

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

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

1230 {
1231  ENTER("%p", view);
1232  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1233  g_return_if_fail(avi != NULL);
1234 
1235  view->avi = *avi;
1236 
1238  view, gnc_tree_view_account_filter_by_view_info,
1239  &view->avi, NULL);
1240 
1241  LEAVE(" ");
1242 }
#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 NULL;
630  }
631 
632  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
633  &f_iter, &s_iter);
634 
635  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
636  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
637  &iter, &f_iter);
638 
639  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
640  commodity = gnc_tree_model_commodity_get_commodity (GNC_TREE_MODEL_COMMODITY(model),
641  &iter);
642  LEAVE("commodity %p (%s)", commodity,
643  commodity ? gnc_commodity_get_mnemonic(commodity) : "");
644  return commodity;
645 }
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_get_selected_namespace()

gnc_commodity_namespace* gnc_tree_view_commodity_get_selected_namespace ( GncTreeViewCommodity *  view)

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

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

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

653 {
654  GtkTreeSelection *selection;
655  GtkTreeModel *model, *f_model, *s_model;
656  GtkTreeIter iter, f_iter, s_iter;
657  gnc_commodity_namespace *ns;
658 
659  g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY(view), NULL);
660 
661  ENTER("view %p", view);
662 
663  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
664  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
665  {
666  LEAVE("no namespace, get_selected failed");
667  return NULL;
668  }
669 
670  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
671  &f_iter, &s_iter);
672 
673  f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(s_model));
674  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
675  &iter, &f_iter);
676 
677  model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(f_model));
678 
679  ns = gnc_tree_model_commodity_get_namespace (GNC_TREE_MODEL_COMMODITY(model),
680  &iter);
681 
682  LEAVE("namespace %p (%s)", ns,
683  ns ? gnc_commodity_namespace_get_name(ns) : "");
684  return ns;
685 }
gnc_commodity_namespace * gnc_tree_model_commodity_get_namespace(GncTreeModelCommodity *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash commodity namespace.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
const char * gnc_commodity_namespace_get_name(const gnc_commodity_namespace *ns)
Return the textual name of a namespace data structure.
#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 691 of file gnc-tree-view-commodity.c.

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

◆ gnc_tree_view_commodity_select_subcommodities()

void gnc_tree_view_commodity_select_subcommodities ( GncTreeViewCommodity *  view,
gnc_commodity *  commodity 
)

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

All other commodities will be unselected.

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

◆ gnc_tree_view_commodity_set_filter()

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

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

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

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

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

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

2153 {
2154  g_return_if_fail(GTK_IS_BUTTON(button));
2155 
2156  ENTER("button %p", button);
2157  fd->visible_types = 0;
2158  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2159  gnc_tree_view_account_refilter(fd->tree_view);
2160  LEAVE("types 0x%x", fd->visible_types);
2161 }
#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 2265 of file gnc-tree-view-account.c.

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

2172 {
2173  g_return_if_fail(GTK_IS_BUTTON(button));
2174 
2175  ENTER("button %p", button);
2176  fd->visible_types = -1;
2177  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2178  gnc_tree_view_account_refilter(fd->tree_view);
2179  LEAVE("types 0x%x", fd->visible_types);
2180 }
#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 2190 of file gnc-tree-view-account.c.

2192 {
2193  ENTER("button %p", button);
2194  gppat_filter_select_all_cb(button, fd);
2195  LEAVE(" ");
2196 }
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select all account types" button in the Filter dialog was clicked.
#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 2093 of file gnc-tree-view-account.c.

2095 {
2096  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2097 
2098  ENTER("button %p", button);
2099  fd->show_hidden = gtk_toggle_button_get_active(button);
2100  gnc_tree_view_account_refilter(fd->tree_view);
2101  LEAVE("show_hidden %d", fd->show_hidden);
2102 }
#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 2131 of file gnc-tree-view-account.c.

2133 {
2134  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2135 
2136  ENTER("button %p", button);
2137  fd->show_unused = gtk_toggle_button_get_active(button);
2138  gnc_tree_view_account_refilter(fd->tree_view);
2139  LEAVE("show_unused %d", fd->show_unused);
2140 }
#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 2112 of file gnc-tree-view-account.c.

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