GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Data Structures | Macros | Typedefs | 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  GncTreeModelAccountTypes
 
struct  GncTreeModelAccountTypesClass
 
struct  GncTreeModelAccount
 
struct  GncTreeModelAccountClass
 
struct  GncTreeModelCommodity
 
struct  GncTreeModelCommodityClass
 
struct  GncTreeModelOwner
 
struct  GncTreeModelOwnerClass
 
struct  GncTreeModelPrice
 
struct  GncTreeModelPriceClass
 
struct  GncTreeModel
 
struct  GncTreeModelClass
 
struct  AccountViewInfo_s
 
struct  GncTreeViewAccount
 
struct  GncTreeViewAccountClass
 
struct  AccountFilterDialog
 
struct  GncTreeViewCommodity
 
struct  GncTreeViewCommodityClass
 
struct  OwnerViewInfo_s
 
struct  GncTreeViewOwner
 
struct  GncTreeViewOwnerClass
 
struct  OwnerFilterDialog
 
struct  GncTreeViewPrice
 
struct  GncTreeViewPriceClass
 

Macros

#define GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES   (gnc_tree_model_account_types_get_type ())
 
#define GNC_TREE_MODEL_ACCOUNT_TYPES(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypes))
 
#define GNC_TREE_MODEL_ACCOUNT_TYPES_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
 
#define GNC_IS_TREE_MODEL_ACCOUNT_TYPES(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
 
#define GNC_IS_TREE_MODEL_ACCOUNT_TYPES_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES))
 
#define GNC_TREE_MODEL_ACCOUNT_TYPES_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesClass))
 
#define GNC_TYPE_TREE_MODEL_ACCOUNT   (gnc_tree_model_account_get_type ())
 
#define GNC_TREE_MODEL_ACCOUNT(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccount))
 
#define GNC_TREE_MODEL_ACCOUNT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccountClass))
 
#define GNC_IS_TREE_MODEL_ACCOUNT(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT))
 
#define GNC_IS_TREE_MODEL_ACCOUNT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_ACCOUNT))
 
#define GNC_TREE_MODEL_ACCOUNT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccountClass))
 
#define GNC_TREE_MODEL_ACCOUNT_NAME   "GncTreeModelAccount"
 
#define GNC_TYPE_TREE_MODEL_COMMODITY   (gnc_tree_model_commodity_get_type ())
 
#define GNC_TREE_MODEL_COMMODITY(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_COMMODITY, GncTreeModelCommodity))
 
#define GNC_TREE_MODEL_COMMODITY_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_COMMODITY, GncTreeModelCommodityClass))
 
#define GNC_IS_TREE_MODEL_COMMODITY(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_COMMODITY))
 
#define GNC_IS_TREE_MODEL_COMMODITY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_COMMODITY))
 
#define GNC_TREE_MODEL_COMMODITY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_COMMODITY, GncTreeModelCommodityClass))
 
#define GNC_TREE_MODEL_COMMODITY_NAME   "GncTreeModelCommodity"
 
#define GNC_TYPE_TREE_MODEL_OWNER   (gnc_tree_model_owner_get_type ())
 
#define GNC_TREE_MODEL_OWNER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_OWNER, GncTreeModelOwner))
 
#define GNC_TREE_MODEL_OWNER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_OWNER, GncTreeModelOwnerClass))
 
#define GNC_IS_TREE_MODEL_OWNER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_OWNER))
 
#define GNC_IS_TREE_MODEL_OWNER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_OWNER))
 
#define GNC_TREE_MODEL_OWNER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_OWNER, GncTreeModelOwnerClass))
 
#define GNC_TREE_MODEL_OWNER_NAME   "GncTreeModelOwner"
 
#define GNC_TYPE_TREE_MODEL_PRICE   (gnc_tree_model_price_get_type ())
 
#define GNC_TREE_MODEL_PRICE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_PRICE, GncTreeModelPrice))
 
#define GNC_TREE_MODEL_PRICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_PRICE, GncTreeModelPriceClass))
 
#define GNC_IS_TREE_MODEL_PRICE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_PRICE))
 
#define GNC_IS_TREE_MODEL_PRICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_PRICE))
 
#define GNC_TREE_MODEL_PRICE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_PRICE, GncTreeModelPriceClass))
 
#define GNC_TREE_MODEL_PRICE_NAME   "GncTreeModelPrice"
 
#define GNC_TYPE_TREE_MODEL   (gnc_tree_model_get_type ())
 
#define GNC_TREE_MODEL(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL, GncTreeModel))
 
#define GNC_TREE_MODEL_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL, GncTreeModelClass))
 
#define GNC_IS_TREE_MODEL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL))
 
#define GNC_IS_TREE_MODEL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL))
 
#define GNC_TREE_MODEL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL, GncTreeModelClass))
 
#define GNC_TREE_MODEL_NAME   "GncTreeModel"
 
#define GNC_TYPE_TREE_VIEW_ACCOUNT   (gnc_tree_view_account_get_type ())
 
#define GNC_TREE_VIEW_ACCOUNT(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccount))
 
#define GNC_TREE_VIEW_ACCOUNT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
 
#define GNC_IS_TREE_VIEW_ACCOUNT(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT))
 
#define GNC_IS_TREE_VIEW_ACCOUNT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT))
 
#define GNC_TREE_VIEW_ACCOUNT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
 
#define GNC_TREE_VIEW_ACCOUNT_NAME   "GncTreeViewAccount"
 
#define GNC_TYPE_TREE_VIEW_COMMODITY   (gnc_tree_view_commodity_get_type ())
 
#define GNC_TREE_VIEW_COMMODITY(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_COMMODITY, GncTreeViewCommodity))
 
#define GNC_TREE_VIEW_COMMODITY_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_COMMODITY, GncTreeViewCommodityClass))
 
#define GNC_IS_TREE_VIEW_COMMODITY(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_COMMODITY))
 
#define GNC_IS_TREE_VIEW_COMMODITY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_COMMODITY))
 
#define GNC_TREE_VIEW_COMMODITY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_COMMODITY, GncTreeViewCommodityClass))
 
#define GNC_TYPE_TREE_VIEW_OWNER   (gnc_tree_view_owner_get_type ())
 
#define GNC_TREE_VIEW_OWNER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_OWNER, GncTreeViewOwner))
 
#define GNC_TREE_VIEW_OWNER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_OWNER, GncTreeViewOwnerClass))
 
#define GNC_IS_TREE_VIEW_OWNER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_OWNER))
 
#define GNC_IS_TREE_VIEW_OWNER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_OWNER))
 
#define GNC_TREE_VIEW_OWNER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_OWNER, GncTreeViewOwnerClass))
 
#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 ())
 
#define GNC_TREE_VIEW_PRICE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_PRICE, GncTreeViewPrice))
 
#define GNC_TREE_VIEW_PRICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_PRICE, GncTreeViewPriceClass))
 
#define GNC_IS_TREE_VIEW_PRICE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_PRICE))
 
#define GNC_IS_TREE_VIEW_PRICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_PRICE))
 
#define GNC_TREE_VIEW_PRICE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_PRICE, GncTreeViewPriceClass))
 

Typedefs

typedef struct AccountViewInfo_s AccountViewInfo
 
typedef struct OwnerViewInfo_s OwnerViewInfo
 

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_CLEARED,
  GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED, GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
  GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN, GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_TOTAL, GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
  GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD, GNC_TREE_MODEL_ACCOUNT_COL_NOTES, GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO, GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT,
  GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER, GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER, 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

GType gnc_tree_model_account_types_get_type (void)
 
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)
 
void gnc_tree_model_account_types_set_selection (GtkTreeSelection *sel, guint32 selected)
 
GtkTreeModel * gnc_tree_model_account_types_new (guint32 selected)
 
GType gnc_tree_model_account_get_type (void)
 
GType gnc_tree_model_commodity_get_type (void)
 
GType gnc_tree_model_owner_get_type (void)
 
GType gnc_tree_model_price_get_type (void)
 
GType gnc_tree_model_get_type (void)
 
void account_filter_dialog_create (AccountFilterDialog *fd, GncPluginPage *page)
 
gboolean gnc_plugin_page_account_tree_filter_accounts (Account *account, gpointer user_data)
 
void gppat_filter_show_hidden_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 
void gppat_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 
void gppat_filter_show_unused_toggled_cb (GtkToggleButton *togglebutton, AccountFilterDialog *fd)
 
void gppat_filter_clear_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 
void gppat_filter_select_all_cb (GtkWidget *button, AccountFilterDialog *fd)
 
void gppat_filter_select_default_cb (GtkWidget *button, AccountFilterDialog *fd)
 
void gppat_filter_response_cb (GtkWidget *dialog, gint response, AccountFilterDialog *fd)
 
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)
 
GType gnc_tree_view_account_get_type (void)
 
GType gnc_tree_view_commodity_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)
 
void gppot_filter_show_inactive_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 
void gppot_filter_show_zero_toggled_cb (GtkToggleButton *togglebutton, OwnerFilterDialog *fd)
 
void gppot_filter_response_cb (GtkWidget *dialog, gint response, OwnerFilterDialog *fd)
 
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)
 
GType gnc_tree_view_owner_get_type (void)
 
GType gnc_tree_view_price_get_type (void)
 

Variables

gboolean OwnerViewInfo_s::show_inactive
 
GncTreeView GncTreeViewOwner::gnc_tree_view
 
int GncTreeViewOwner::stamp
 
GncTreeViewClass GncTreeViewOwnerClass::gnc_tree_view
 
GtkWidget * OwnerFilterDialog::dialog
 
GncTreeViewOwnerOwnerFilterDialog::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)
 

Account Tree Model Get/Set Functions

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

Account Tree Model Constructors

GtkTreeModel * gnc_tree_model_commodity_new (QofBook *book, gnc_commodity_table *ct)
 

Commodity Tree Model Filter Helper Functions

gboolean gnc_tree_model_commodity_iter_is_namespace (GncTreeModelCommodity *model, GtkTreeIter *iter)
 
gboolean gnc_tree_model_commodity_iter_is_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 
gnc_commodity_namespacegnc_tree_model_commodity_get_namespace (GncTreeModelCommodity *model, GtkTreeIter *iter)
 
gnc_commoditygnc_tree_model_commodity_get_commodity (GncTreeModelCommodity *model, GtkTreeIter *iter)
 

Commodity Tree Model Lookup Functions

gboolean gnc_tree_model_commodity_get_iter_from_namespace (GncTreeModelCommodity *model, gnc_commodity_namespace *name_space, GtkTreeIter *iter)
 
gboolean gnc_tree_model_commodity_get_iter_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity, GtkTreeIter *iter)
 
GtkTreePath * gnc_tree_model_commodity_get_path_from_commodity (GncTreeModelCommodity *model, gnc_commodity *commodity)
 

Owner Tree Model Constructors

GtkTreeModel * gnc_tree_model_owner_new (GncOwnerType owner_type)
 

Owner Tree Model Get/Set Functions

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

Account Tree Model Constructors

GtkTreeModel * gnc_tree_model_price_new (QofBook *book, GNCPriceDB *price_db)
 

Price Tree Model Filter Helper Functions

gboolean gnc_tree_model_price_iter_is_namespace (GncTreeModelPrice *model, GtkTreeIter *iter)
 
gboolean gnc_tree_model_price_iter_is_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 
gboolean gnc_tree_model_price_iter_is_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 
gnc_commodity_namespacegnc_tree_model_price_get_namespace (GncTreeModelPrice *model, GtkTreeIter *iter)
 
gnc_commoditygnc_tree_model_price_get_commodity (GncTreeModelPrice *model, GtkTreeIter *iter)
 
GNCPricegnc_tree_model_price_get_price (GncTreeModelPrice *model, GtkTreeIter *iter)
 

Commodity Tree Model Lookup Functions

gboolean gnc_tree_model_price_get_iter_from_namespace (GncTreeModelPrice *model, gnc_commodity_namespace *name_space, GtkTreeIter *iter)
 
gboolean gnc_tree_model_price_get_iter_from_commodity (GncTreeModelPrice *model, gnc_commodity *commodity, GtkTreeIter *iter)
 
gboolean gnc_tree_model_price_get_iter_from_price (GncTreeModelPrice *model, GNCPrice *price, GtkTreeIter *iter)
 
GtkTreePath * gnc_tree_model_price_get_path_from_price (GncTreeModelPrice *model, GNCPrice *price)
 

Account Tree View Constructors

GtkTreeView * gnc_tree_view_account_new_with_root (Account *root, gboolean show_root)
 
GtkTreeView * gnc_tree_view_account_new (gboolean show_root)
 

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

Account Tree View Filtering

typedef gboolean(* gnc_tree_view_account_filter_func )(Account *account, gpointer data)
 
void gnc_tree_view_account_get_view_info (GncTreeViewAccount *account_view, AccountViewInfo *avi)
 
void gnc_tree_view_account_set_view_info (GncTreeViewAccount *account_view, AccountViewInfo *avi)
 
void gnc_tree_view_account_set_filter (GncTreeViewAccount *account_view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
 
gboolean gnc_tree_view_account_filter_by_view_info (Account *acct, gpointer data)
 
void gnc_tree_view_account_refilter (GncTreeViewAccount *view)
 

Account Tree View Get/Set Functions

gint gnc_tree_view_account_count_children (GncTreeViewAccount *view, Account *account)
 
Accountgnc_tree_view_account_get_account_from_path (GncTreeViewAccount *view, GtkTreePath *path)
 
Accountgnc_tree_view_account_get_account_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 
Accountgnc_tree_view_account_get_cursor_account (GncTreeViewAccount *view)
 
Accountgnc_tree_view_account_get_selected_account (GncTreeViewAccount *view)
 
void gnc_tree_view_account_set_selected_account (GncTreeViewAccount *view, Account *account)
 
GList * gnc_tree_view_account_get_selected_accounts (GncTreeViewAccount *view)
 
void gnc_tree_view_account_set_selected_accounts (GncTreeViewAccount *view, GList *account_list, gboolean show_last)
 
void gnc_tree_view_account_select_subaccounts (GncTreeViewAccount *view, Account *account)
 
void gnc_tree_view_account_expand_to_account (GncTreeViewAccount *view, Account *account)
 

Commodity Tree View Constructors

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

Commodity Tree View Configuration

void gnc_tree_view_commodity_configure_columns (GncTreeViewCommodity *view, GSList *column_names)
 

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)
 
void gnc_tree_view_commodity_refilter (GncTreeViewCommodity *view)
 

Commodity Tree View Get/Set Functions

gnc_commoditygnc_tree_view_commodity_get_cursor_commodity (GncTreeViewCommodity *view)
 
gnc_commoditygnc_tree_view_commodity_get_selected_commodity (GncTreeViewCommodity *view)
 
void gnc_tree_view_commodity_select_subcommodities (GncTreeViewCommodity *view, gnc_commodity *commodity)
 

Owner Tree View Constructor

GtkTreeView * gnc_tree_view_owner_new (GncOwnerType owner_type)
 

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)
 
void gnc_tree_view_owner_set_filter (GncTreeViewOwner *owner_view, gnc_tree_view_owner_filter_func func, gpointer data, GSourceFunc destroy)
 
void gnc_tree_view_owner_refilter (GncTreeViewOwner *view)
 

Owner Tree View Get/Set Functions

GncOwnergnc_tree_view_owner_get_owner_from_path (GncTreeViewOwner *view, GtkTreePath *path)
 
GncOwnergnc_tree_view_owner_get_owner_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
 
GncOwnergnc_tree_view_owner_get_selected_owner (GncTreeViewOwner *view)
 
void gnc_tree_view_owner_set_selected_owner (GncTreeViewOwner *view, GncOwner *owner)
 

Price Tree View Constructors

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

Price Tree View Filtering

typedef gboolean(* gnc_tree_view_price_ns_filter_func )(gnc_commodity_namespace *, gpointer data)
 
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

GNCPricegnc_tree_view_price_get_cursor_price (GncTreeViewPrice *view)
 
GNCPricegnc_tree_view_price_get_selected_price (GncTreeViewPrice *view)
 
void gnc_tree_view_price_set_selected_price (GncTreeViewPrice *view, GNCPrice *price)
 
GList * gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view)
 

Detailed Description

Typedef Documentation

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.

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 173 of file gnc-tree-view-owner.h.

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 wil 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 138 of file gnc-tree-view-price.h.

Function Documentation

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

1906 {
1907  AccountFilterDialog *fd = user_data;
1908  GNCAccountType acct_type;
1909  gnc_numeric total;
1910  gboolean result;
1911 
1912  ENTER("account %p:%s", account, xaccAccountGetName(account));
1913 
1914  if (!fd->show_hidden && xaccAccountIsHidden (account))
1915  {
1916  LEAVE(" hide: hidden");
1917  return FALSE;
1918  }
1919 
1920  if (!fd->show_zero_total)
1921  {
1922  total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
1923  if (gnc_numeric_zero_p(total))
1924  {
1925  LEAVE(" hide: zero balance");
1926  return FALSE;
1927  }
1928  }
1929 
1930  if (!fd->show_unused)
1931  {
1932  if (xaccAccountCountSplits(account, TRUE) == 0)
1933  {
1934  LEAVE(" hide: unused");
1935  return FALSE;
1936  }
1937  }
1938 
1939  acct_type = xaccAccountGetType(account);
1940  result = (fd->visible_types & (1 << acct_type)) ? TRUE : FALSE;
1941  LEAVE(" %s", result ? "show" : "hide");
1942  return result;
1943 }
GNCAccountType xaccAccountGetType(const Account *acc)
Definition: Account.c:3009
gboolean gnc_numeric_zero_p(gnc_numeric a)
#define ENTER(format, args...)
Definition: qoflog.h:261
gboolean xaccAccountIsHidden(const Account *acc)
Definition: Account.c:3982
GNCAccountType
Definition: Account.h:96
gint64 xaccAccountCountSplits(const Account *acc, gboolean include_children)
Definition: Account.c:3725
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1056 of file gnc-tree-view-owner.c.

1058 {
1059  OwnerFilterDialog *fd = user_data;
1060  gnc_numeric total;
1061 
1062  ENTER("owner %p:%s", owner, gncOwnerGetName(owner));
1063 
1064  if (!fd->show_inactive && !gncOwnerGetActive (owner))
1065  {
1066  LEAVE(" hide: inactive");
1067  return FALSE;
1068  }
1069 
1070  if (!fd->show_zero_total)
1071  {
1072  total = gncOwnerGetBalanceInCurrency (owner, NULL);
1073  if (gnc_numeric_zero_p(total))
1074  {
1075  LEAVE(" hide: zero balance");
1076  return FALSE;
1077  }
1078  }
1079 
1080  return TRUE;
1081 }
gboolean gnc_numeric_zero_p(gnc_numeric a)
#define ENTER(format, args...)
Definition: qoflog.h:261
gnc_numeric gncOwnerGetBalanceInCurrency(const GncOwner *owner, const gnc_commodity *report_currency)
Definition: gncOwner.c:1417
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1130 of file gnc-tree-model-account.c.

1132 {
1133  g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), NULL);
1134  g_return_val_if_fail (iter != NULL, NULL);
1135  g_return_val_if_fail (iter->user_data != NULL, NULL);
1136  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
1137 
1138  return (Account *) iter->user_data;
1139 }
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 1147 of file gnc-tree-model-account.c.

1150 {
1152  Account *parent;
1153  gint i;
1154 
1155  ENTER("model %p, account %p, iter %p", model, account, iter);
1156  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), FALSE);
1157  gnc_leave_return_val_if_fail ((account != NULL), FALSE);
1158  gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
1159 
1160  iter->user_data = account;
1161  iter->stamp = model->stamp;
1162 
1163  priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
1164  if (account == priv->root)
1165  {
1166  iter->user_data2 = NULL;
1167  iter->user_data3 = GINT_TO_POINTER (0);
1168  LEAVE("Matched root");
1169  return TRUE;
1170  }
1171 
1172  if (priv->root != gnc_account_get_root (account))
1173  {
1174  LEAVE("Root doesn't match");
1175  return FALSE;
1176  }
1177 
1178  parent = gnc_account_get_parent(account);
1179  i = gnc_account_child_index(parent, account);
1180  iter->user_data2 = parent;
1181  iter->user_data3 = GINT_TO_POINTER (i);
1182  LEAVE("iter %s", iter_to_string(iter));
1183  return (i != -1);
1184 }
Account * gnc_account_get_parent(const Account *acc)
Definition: Account.c:2623
#define ENTER(format, args...)
Definition: qoflog.h:261
#define gnc_leave_return_val_if_fail(test, val)
Definition: qoflog.h:283
#define LEAVE(format, args...)
Definition: qoflog.h:271
gint gnc_account_child_index(const Account *parent, const Account *child)
Definition: Account.c:2683
Account * gnc_account_get_root(Account *acc)
Definition: Account.c:2630
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 1192 of file gnc-tree-model-account.c.

1194 {
1195  GtkTreeIter tree_iter;
1196  GtkTreePath *tree_path;
1197 
1198  ENTER("model %p, account %p", model, account);
1199  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), NULL);
1200  gnc_leave_return_val_if_fail (account != NULL, NULL);
1201 
1202  if (!gnc_tree_model_account_get_iter_from_account (model, account,
1203  &tree_iter))
1204  {
1205  LEAVE("no iter");
1206  return NULL;
1207  }
1208 
1209  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1210  if (tree_path)
1211  {
1212  gchar *path_string = gtk_tree_path_to_string(tree_path);
1213  LEAVE("path (2) %s", path_string);
1214  g_free(path_string);
1215  }
1216  else
1217  {
1218  LEAVE("no path");
1219  }
1220  return tree_path;
1221 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define gnc_leave_return_val_if_fail(test, val)
Definition: qoflog.h:283
gboolean gnc_tree_model_account_get_iter_from_account(GncTreeModelAccount *model, Account *account, GtkTreeIter *iter)
#define LEAVE(format, args...)
Definition: qoflog.h:271
GType gnc_tree_model_account_get_type ( void  )

Get the type of an account tree plugin.

Returns
A GType.

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

138 {
139  static GType gnc_tree_model_account_type = 0;
140 
141  if (gnc_tree_model_account_type == 0)
142  {
143  static const GTypeInfo our_info =
144  {
145  sizeof (GncTreeModelAccountClass), /* class_size */
146  NULL, /* base_init */
147  NULL, /* base_finalize */
148  (GClassInitFunc) gnc_tree_model_account_class_init,
149  NULL, /* class_finalize */
150  NULL, /* class_data */
151  sizeof (GncTreeModelAccount), /* */
152  0, /* n_preallocs */
153  (GInstanceInitFunc) gnc_tree_model_account_init
154  };
155 
156  static const GInterfaceInfo tree_model_info =
157  {
158  (GInterfaceInitFunc) gnc_tree_model_account_tree_model_init,
159  NULL,
160  NULL
161  };
162 
163  gnc_tree_model_account_type = g_type_register_static (GNC_TYPE_TREE_MODEL,
164  GNC_TREE_MODEL_ACCOUNT_NAME,
165  &our_info, 0);
166 
167  g_type_add_interface_static (gnc_tree_model_account_type,
168  GTK_TYPE_TREE_MODEL,
169  &tree_model_info);
170  }
171 
172  return gnc_tree_model_account_type;
173 }
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 273 of file gnc-tree-model-account.c.

274 {
275  GncTreeModelAccount *model;
277  const GList *item;
278 
279  ENTER("root %p", root);
280  item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_ACCOUNT_NAME);
281  for ( ; item; item = g_list_next(item))
282  {
283  model = (GncTreeModelAccount *)item->data;
284  priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
285  if (priv->root == root)
286  {
287  g_object_ref(G_OBJECT(model));
288  LEAVE("returning existing model %p", model);
289  return GTK_TREE_MODEL(model);
290  }
291  }
292 
293  model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT,
294  NULL);
295 
296  priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
297  priv->book = gnc_get_current_book();
298  priv->root = root;
299 
300  priv->event_handler_id = qof_event_register_handler
301  ((QofEventHandler)gnc_tree_model_account_event_handler, model);
302 
303  LEAVE("model %p", model);
304  return GTK_TREE_MODEL (model);
305 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
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...)
Definition: qoflog.h:261
gint qof_event_register_handler(QofEventHandler handler, gpointer handler_data)
Register a handler for events.
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 287 of file gnc-tree-model-commodity.c.

289 {
290  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
291  g_return_val_if_fail (iter != NULL, NULL);
292  g_return_val_if_fail (iter->user_data != NULL, NULL);
293  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
294 
295  if (iter->user_data != ITER_IS_COMMODITY)
296  return NULL;
297  return (gnc_commodity *)iter->user_data2;
298 }
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 969 of file gnc-tree-model-commodity.c.

972 {
973  gnc_commodity_namespace *name_space;
974  GList *list;
975  gint n;
976 
977  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
978  g_return_val_if_fail ((commodity != NULL), FALSE);
979  g_return_val_if_fail ((iter != NULL), FALSE);
980 
981  ENTER("model %p, commodity %p, iter %p", model, commodity, iter);
982 
983  name_space = gnc_commodity_get_namespace_ds(commodity);
984  if (name_space == NULL)
985  {
986  LEAVE("no namespace");
987  return FALSE;
988  }
989 
991  if (list == NULL)
992  {
993  LEAVE("empty list");
994  return FALSE;
995  }
996 
997  n = g_list_index(list, commodity);
998  if (n == -1)
999  {
1000  LEAVE("not in list");
1001  return FALSE;
1002  }
1003 
1004  iter->stamp = model->stamp;
1005  iter->user_data = ITER_IS_COMMODITY;
1006  iter->user_data2 = commodity;
1007  iter->user_data3 = GINT_TO_POINTER(n);
1008  LEAVE("iter %s", iter_to_string(iter));
1009  return TRUE;
1010 }
#define ENTER(format, args...)
Definition: qoflog.h:261
GList * gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
gnc_commodity_namespace * gnc_commodity_get_namespace_ds(const gnc_commodity *cm)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1054 of file gnc-tree-model-commodity.c.

1057 {
1059  GList *list;
1060  gint n;
1061 
1062  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
1063  g_return_val_if_fail ((name_space != NULL), FALSE);
1064  g_return_val_if_fail ((iter != NULL), FALSE);
1065 
1066  ENTER("model %p, namespace %p, iter %p", model, name_space, iter);
1067 
1068  priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
1069  list = gnc_commodity_table_get_namespaces_list(priv->commodity_table);
1070  if (list == NULL)
1071  {
1072  LEAVE("");
1073  return FALSE;
1074  }
1075 
1076  n = g_list_index(list, name_space);
1077  if (n == -1)
1078  {
1079  LEAVE("");
1080  return FALSE;
1081  }
1082 
1083  iter->stamp = model->stamp;
1084  iter->user_data = ITER_IS_NAMESPACE;
1085  iter->user_data2 = name_space;
1086  iter->user_data3 = GINT_TO_POINTER(n);
1087  LEAVE("iter %s", iter_to_string(iter));
1088  return TRUE;
1089 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
GList * gnc_commodity_table_get_namespaces_list(const gnc_commodity_table *table)
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 273 of file gnc-tree-model-commodity.c.

275 {
276  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
277  g_return_val_if_fail (iter != NULL, NULL);
278  g_return_val_if_fail (iter->user_data != NULL, NULL);
279  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
280 
281  if (iter->user_data != ITER_IS_NAMESPACE)
282  return NULL;
283  return (gnc_commodity_namespace *)iter->user_data2;
284 }
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 1018 of file gnc-tree-model-commodity.c.

1020 {
1021  GtkTreeIter tree_iter;
1022  GtkTreePath *tree_path;
1023 
1024  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
1025  g_return_val_if_fail (commodity != NULL, NULL);
1026  ENTER("model %p, commodity %p", model, commodity);
1027 
1028  if (!gnc_tree_model_commodity_get_iter_from_commodity (model, commodity, &tree_iter))
1029  {
1030  LEAVE("no iter");
1031  return NULL;
1032  }
1033 
1034  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1035  if (tree_path)
1036  {
1037  gchar *path_string = gtk_tree_path_to_string(tree_path);
1038  LEAVE("path (2) %s", path_string);
1039  g_free(path_string);
1040  }
1041  else
1042  {
1043  LEAVE("no path");
1044  }
1045  return tree_path;
1046 }
gboolean gnc_tree_model_commodity_get_iter_from_commodity(GncTreeModelCommodity *model, gnc_commodity *commodity, GtkTreeIter *iter)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
GType gnc_tree_model_commodity_get_type ( void  )

Get the type of a commodity tree plugin.

Returns
A GType.

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

111 {
112  static GType gnc_tree_model_commodity_type = 0;
113 
114  if (gnc_tree_model_commodity_type == 0)
115  {
116  static const GTypeInfo our_info =
117  {
119  NULL,
120  NULL,
121  (GClassInitFunc) gnc_tree_model_commodity_class_init,
122  NULL,
123  NULL,
124  sizeof (GncTreeModelCommodity),
125  0,
126  (GInstanceInitFunc) gnc_tree_model_commodity_init
127  };
128 
129  static const GInterfaceInfo tree_model_info =
130  {
131  (GInterfaceInitFunc) gnc_tree_model_commodity_tree_model_init,
132  NULL,
133  NULL
134  };
135 
136  gnc_tree_model_commodity_type = g_type_register_static (GNC_TYPE_TREE_MODEL,
137  GNC_TREE_MODEL_COMMODITY_NAME,
138  &our_info, 0);
139 
140  g_type_add_interface_static (gnc_tree_model_commodity_type,
141  GTK_TYPE_TREE_MODEL,
142  &tree_model_info);
143  }
144 
145  return gnc_tree_model_commodity_type;
146 }
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 261 of file gnc-tree-model-commodity.c.

263 {
264  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
265  g_return_val_if_fail (iter != NULL, FALSE);
266  g_return_val_if_fail (iter->user_data != NULL, FALSE);
267  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
268 
269  return (iter->user_data == ITER_IS_COMMODITY);
270 }
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 249 of file gnc-tree-model-commodity.c.

251 {
252  g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), FALSE);
253  g_return_val_if_fail (iter != NULL, FALSE);
254  g_return_val_if_fail (iter->user_data != NULL, FALSE);
255  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
256 
257  return (iter->user_data == ITER_IS_NAMESPACE);
258 }
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 215 of file gnc-tree-model-commodity.c.

216 {
217  GncTreeModelCommodity *model;
219  const GList *item;
220 
221  ENTER("");
222 
223  item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_COMMODITY_NAME);
224  for ( ; item; item = g_list_next(item))
225  {
226  model = (GncTreeModelCommodity *)item->data;
227  priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
228  if (priv->commodity_table == ct)
229  {
230  g_object_ref(G_OBJECT(model));
231  LEAVE("returning existing model %p", model);
232  return GTK_TREE_MODEL(model);
233  }
234  }
235 
236  model = g_object_new (GNC_TYPE_TREE_MODEL_COMMODITY, NULL);
237  priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
238  priv->book = book;
239  priv->commodity_table = ct;
240 
241  priv->event_handler_id =
242  qof_event_register_handler (gnc_tree_model_commodity_event_handler, model);
243 
244  LEAVE("");
245  return GTK_TREE_MODEL (model);
246 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
#define ENTER(format, args...)
Definition: qoflog.h:261
gint qof_event_register_handler(QofEventHandler handler, gpointer handler_data)
Register a handler for events.
#define LEAVE(format, args...)
Definition: qoflog.h:271
GType gnc_tree_model_get_type ( void  )

Get the type of a generic tree model plugin.

Returns
A GType.

Definition at line 61 of file gnc-tree-model.c.

62 {
63  static GType gnc_tree_model_type = 0;
64 
65  if (gnc_tree_model_type == 0)
66  {
67  static const GTypeInfo our_info =
68  {
69  sizeof (GncTreeModelClass), /* class_size */
70  NULL, /* base_init */
71  NULL, /* base_finalize */
72  (GClassInitFunc) gnc_tree_model_class_init,
73  NULL, /* class_finalize */
74  NULL, /* class_data */
75  sizeof (GncTreeModel), /* */
76  0, /* n_preallocs */
77  (GInstanceInitFunc) gnc_tree_model_init
78  };
79 
80  //static const GInterfaceInfo tree_model_info = {
81  // (GInterfaceInitFunc) gnc_tree_model_tree_model_init,
82  // NULL,
83  // NULL
84  //};
85 
86  gnc_tree_model_type = g_type_register_static (G_TYPE_OBJECT,
87  GNC_TREE_MODEL_NAME,
88  &our_info, 0);
89 
90  //g_type_add_interface_static (gnc_tree_model_type,
91  // GTK_TYPE_TREE_MODEL,
92  // &tree_model_info);
93  }
94 
95  return gnc_tree_model_type;
96 }
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 878 of file gnc-tree-model-owner.c.

881 {
883  GList *owner_in_list;
884 
885  ENTER("model %p, owner %p, iter %p", model, owner, iter);
886  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), FALSE);
887  gnc_leave_return_val_if_fail ((owner != NULL), FALSE);
888  gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
889 
890 
891  priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
892  owner_in_list = g_list_find_custom (priv->owner_list, (gconstpointer)owner, (GCompareFunc)gncOwnerGCompareFunc);
893  if (owner_in_list)
894  {
895  iter->stamp = model->stamp;
896  iter->user_data = owner_in_list->data;
897  iter->user_data2 = GINT_TO_POINTER (g_list_position (priv->owner_list, owner_in_list));
898  iter->user_data3 = NULL;
899  LEAVE("iter %s", iter_to_string (iter));
900  return TRUE;
901  }
902  else
903  {
904  iter->stamp = 0;
905  iter->user_data = NULL;
906  LEAVE("Owner not found in list");
907  return FALSE;
908  }
909 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define gnc_leave_return_val_if_fail(test, val)
Definition: qoflog.h:283
int gncOwnerGCompareFunc(const GncOwner *a, const GncOwner *b)
Definition: gncOwner.c:389
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 861 of file gnc-tree-model-owner.c.

863 {
864  g_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), NULL);
865  g_return_val_if_fail (iter != NULL, NULL);
866  g_return_val_if_fail (iter->user_data != NULL, NULL);
867  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
868 
869  return (GncOwner *) iter->user_data;
870 }
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 917 of file gnc-tree-model-owner.c.

919 {
920  GtkTreeIter tree_iter;
921  GtkTreePath *tree_path;
922 
923  ENTER("model %p, owner %p", model, owner);
924  gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), NULL);
925  gnc_leave_return_val_if_fail (owner != NULL, NULL);
926 
927  if (!gnc_tree_model_owner_get_iter_from_owner (model, owner,
928  &tree_iter))
929  {
930  LEAVE("no iter");
931  return NULL;
932  }
933 
934  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
935  if (tree_path)
936  {
937  gchar *path_string = gtk_tree_path_to_string(tree_path);
938  LEAVE("path (2) %s", path_string);
939  g_free(path_string);
940  }
941  else
942  {
943  LEAVE("no path");
944  }
945  return tree_path;
946 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define gnc_leave_return_val_if_fail(test, val)
Definition: qoflog.h:283
gboolean gnc_tree_model_owner_get_iter_from_owner(GncTreeModelOwner *model, GncOwner *owner, GtkTreeIter *iter)
#define LEAVE(format, args...)
Definition: qoflog.h:271
GType gnc_tree_model_owner_get_type ( void  )

Get the type of an owner tree plugin.

Returns
A GType.

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

137 {
138  static GType gnc_tree_model_owner_type = 0;
139 
140  if (gnc_tree_model_owner_type == 0)
141  {
142  static const GTypeInfo our_info =
143  {
144  sizeof (GncTreeModelOwnerClass), /* class_size */
145  NULL, /* base_init */
146  NULL, /* base_finalize */
147  (GClassInitFunc) gnc_tree_model_owner_class_init,
148  NULL, /* class_finalize */
149  NULL, /* class_data */
150  sizeof (GncTreeModelOwner), /* */
151  0, /* n_preallocs */
152  (GInstanceInitFunc) gnc_tree_model_owner_init
153  };
154 
155  static const GInterfaceInfo tree_model_info =
156  {
157  (GInterfaceInitFunc) gnc_tree_model_owner_tree_model_init,
158  NULL,
159  NULL
160  };
161 
162  gnc_tree_model_owner_type = g_type_register_static (GNC_TYPE_TREE_MODEL,
163  GNC_TREE_MODEL_OWNER_NAME,
164  &our_info, 0);
165 
166  g_type_add_interface_static (gnc_tree_model_owner_type,
167  GTK_TYPE_TREE_MODEL,
168  &tree_model_info);
169  }
170 
171  return gnc_tree_model_owner_type;
172 }
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 274 of file gnc-tree-model-owner.c.

275 {
276  GncTreeModelOwner *model;
278  const GList *item;
279 
280  ENTER("owner_type %d", owner_type);
281  item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_OWNER_NAME);
282  for ( ; item; item = g_list_next(item))
283  {
284  model = (GncTreeModelOwner *)item->data;
285  priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
286  if (priv->owner_type == owner_type)
287  {
288  g_object_ref(G_OBJECT(model));
289  LEAVE("returning existing model %p", model);
290  return GTK_TREE_MODEL(model);
291  }
292  }
293 
294  model = g_object_new (GNC_TYPE_TREE_MODEL_OWNER,
295  NULL);
296 
297  priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
298  priv->book = gnc_get_current_book();
299  priv->owner_type = owner_type;
300  priv->owner_list = gncBusinessGetOwnerList (priv->book, gncOwnerTypeToQofIdType(owner_type), TRUE);
301 
302  priv->event_handler_id = qof_event_register_handler
303  ((QofEventHandler)gnc_tree_model_owner_event_handler, model);
304 
305  LEAVE("model %p", model);
306  return GTK_TREE_MODEL (model);
307 }
OwnerList * gncBusinessGetOwnerList(QofBook *book, QofIdTypeConst type_name, gboolean all_including_inactive)
const GList * gnc_gobject_tracking_get_list(const gchar *name)
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...)
Definition: qoflog.h:261
gint qof_event_register_handler(QofEventHandler handler, gpointer handler_data)
Register a handler for events.
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Definition: gncOwner.c:213
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 335 of file gnc-tree-model-price.c.

337 {
338  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
339  g_return_val_if_fail (iter != NULL, NULL);
340  g_return_val_if_fail (iter->user_data != NULL, NULL);
341  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
342 
343  if (iter->user_data != ITER_IS_COMMODITY)
344  return NULL;
345  return (gnc_commodity *)iter->user_data2;
346 }
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 1269 of file gnc-tree-model-price.c.

1272 {
1273  gnc_commodity_namespace *name_space;
1274  GList *list;
1275  gint n;
1276 
1277  ENTER("model %p, commodity %p, iter %p", model, commodity, iter);
1278  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1279  g_return_val_if_fail ((commodity != NULL), FALSE);
1280  g_return_val_if_fail ((iter != NULL), FALSE);
1281 
1282  name_space = gnc_commodity_get_namespace_ds(commodity);
1283  if (name_space == NULL)
1284  {
1285  LEAVE("no namespace");
1286  return FALSE;
1287  }
1288 
1289  list = gnc_commodity_namespace_get_commodity_list(name_space);
1290  if (list == NULL)
1291  {
1292  LEAVE("empty list");
1293  return FALSE;
1294  }
1295 
1296  n = g_list_index(list, commodity);
1297  if (n == -1)
1298  {
1299  LEAVE("not in list");
1300  return FALSE;
1301  }
1302 
1303  iter->stamp = model->stamp;
1304  iter->user_data = ITER_IS_COMMODITY;
1305  iter->user_data2 = commodity;
1306  iter->user_data3 = GINT_TO_POINTER(n);
1307  LEAVE("iter %s", iter_to_string(model, iter));
1308  return TRUE;
1309 }
#define ENTER(format, args...)
Definition: qoflog.h:261
GList * gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
gnc_commodity_namespace * gnc_commodity_get_namespace_ds(const gnc_commodity *cm)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1317 of file gnc-tree-model-price.c.

1320 {
1322  gnc_commodity_table *ct;
1323  GList *list;
1324  gint n;
1325 
1326  ENTER("model %p, namespace %p, iter %p", model, name_space, iter);
1327  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1328  g_return_val_if_fail ((name_space != NULL), FALSE);
1329  g_return_val_if_fail ((iter != NULL), FALSE);
1330 
1331  priv = GNC_TREE_MODEL_PRICE_GET_PRIVATE(model);
1332  ct = qof_book_get_data (priv->book, GNC_COMMODITY_TABLE);
1334  if (list == NULL)
1335  return FALSE;
1336 
1337  n = g_list_index(list, name_space);
1338  if (n == -1)
1339  return FALSE;
1340 
1341  iter->stamp = model->stamp;
1342  iter->user_data = ITER_IS_NAMESPACE;
1343  iter->user_data2 = name_space;
1344  iter->user_data3 = GINT_TO_POINTER(n);
1345  LEAVE("iter %s", iter_to_string(model, iter));
1346  return TRUE;
1347 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
gpointer qof_book_get_data(const QofBook *book, const gchar *key)
GList * gnc_commodity_table_get_namespaces_list(const gnc_commodity_table *table)
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 1181 of file gnc-tree-model-price.c.

1184 {
1186  gnc_commodity *commodity;
1187  GList *list;
1188  gint n;
1189 
1190  ENTER("model %p, price %p, iter %p", model, price, iter);
1191  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
1192  g_return_val_if_fail ((price != NULL), FALSE);
1193  g_return_val_if_fail ((iter != NULL), FALSE);
1194 
1195  priv = GNC_TREE_MODEL_PRICE_GET_PRIVATE(model);
1196  commodity = gnc_price_get_commodity(price);
1197  if (commodity == NULL)
1198  {
1199  LEAVE("no commodity");
1200  return FALSE;
1201  }
1202 
1203  list = gnc_pricedb_get_prices(priv->price_db, commodity, NULL);
1204  if (list == NULL)
1205  {
1206  LEAVE("empty list");
1207  return FALSE;
1208  }
1209 
1210  n = g_list_index(list, price);
1211  if (n == -1)
1212  {
1213  gnc_price_list_destroy(list);
1214  LEAVE("not in list");
1215  return FALSE;
1216  }
1217 
1218  iter->stamp = model->stamp;
1219  iter->user_data = ITER_IS_PRICE;
1220  iter->user_data2 = price;
1221  iter->user_data3 = GINT_TO_POINTER(n);
1222  gnc_price_list_destroy(list);
1223  LEAVE("iter %s", iter_to_string(model, iter));
1224  return TRUE;
1225 }
void gnc_price_list_destroy(PriceList *prices)
Definition: gnc-pricedb.c:701
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
PriceList * gnc_pricedb_get_prices(GNCPriceDB *db, const gnc_commodity *commodity, const gnc_commodity *currency)
Definition: gnc-pricedb.c:1479
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 321 of file gnc-tree-model-price.c.

323 {
324  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
325  g_return_val_if_fail (iter != NULL, NULL);
326  g_return_val_if_fail (iter->user_data != NULL, NULL);
327  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
328 
329  if (iter->user_data != ITER_IS_NAMESPACE)
330  return NULL;
331  return (gnc_commodity_namespace *)iter->user_data2;
332 }
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 1233 of file gnc-tree-model-price.c.

1235 {
1236  GtkTreeIter tree_iter;
1237  GtkTreePath *tree_path;
1238 
1239  ENTER("model %p, price %p", model, price);
1240  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
1241  g_return_val_if_fail (price != NULL, NULL);
1242 
1243  if (!gnc_tree_model_price_get_iter_from_price (model, price, &tree_iter))
1244  {
1245  LEAVE("no iter");
1246  return NULL;
1247  }
1248 
1249  tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
1250  if (tree_path)
1251  {
1252  gchar *path_string = gtk_tree_path_to_string(tree_path);
1253  LEAVE("path (2) %s", path_string);
1254  g_free(path_string);
1255  }
1256  else
1257  {
1258  LEAVE("no path");
1259  }
1260  return tree_path;
1261 }
gboolean gnc_tree_model_price_get_iter_from_price(GncTreeModelPrice *model, GNCPrice *price, GtkTreeIter *iter)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 349 of file gnc-tree-model-price.c.

351 {
352  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
353  g_return_val_if_fail (iter != NULL, NULL);
354  g_return_val_if_fail (iter->user_data != NULL, NULL);
355  g_return_val_if_fail (iter->stamp == model->stamp, NULL);
356 
357  if (iter->user_data != ITER_IS_PRICE)
358  return NULL;
359  return (GNCPrice *)iter->user_data2;
360 }
GType gnc_tree_model_price_get_type ( void  )

Get the type of a price tree plugin.

Returns
A GType.

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

142 {
143  static GType gnc_tree_model_price_type = 0;
144 
145  if (gnc_tree_model_price_type == 0)
146  {
147  static const GTypeInfo our_info =
148  {
149  sizeof (GncTreeModelPriceClass),
150  NULL,
151  NULL,
152  (GClassInitFunc) gnc_tree_model_price_class_init,
153  NULL,
154  NULL,
155  sizeof (GncTreeModelPrice),
156  0,
157  (GInstanceInitFunc) gnc_tree_model_price_init
158  };
159 
160  static const GInterfaceInfo tree_model_info =
161  {
162  (GInterfaceInitFunc) gnc_tree_model_price_tree_model_init,
163  NULL,
164  NULL
165  };
166 
167  gnc_tree_model_price_type = g_type_register_static (GNC_TYPE_TREE_MODEL,
168  GNC_TREE_MODEL_PRICE_NAME,
169  &our_info, 0);
170 
171  g_type_add_interface_static (gnc_tree_model_price_type,
172  GTK_TYPE_TREE_MODEL,
173  &tree_model_info);
174  }
175 
176  return gnc_tree_model_price_type;
177 }
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 297 of file gnc-tree-model-price.c.

299 {
300  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
301  g_return_val_if_fail (iter != NULL, FALSE);
302  g_return_val_if_fail (iter->user_data != NULL, FALSE);
303  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
304 
305  return (iter->user_data == ITER_IS_COMMODITY);
306 }
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 285 of file gnc-tree-model-price.c.

287 {
288  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
289  g_return_val_if_fail (iter != NULL, FALSE);
290  g_return_val_if_fail (iter->user_data != NULL, FALSE);
291  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
292 
293  return (iter->user_data == ITER_IS_NAMESPACE);
294 }
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 309 of file gnc-tree-model-price.c.

311 {
312  g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), FALSE);
313  g_return_val_if_fail (iter != NULL, FALSE);
314  g_return_val_if_fail (iter->user_data != NULL, FALSE);
315  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
316 
317  return (iter->user_data == ITER_IS_PRICE);
318 }
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 252 of file gnc-tree-model-price.c.

253 {
254  GncTreeModelPrice *model;
256  const GList *item;
257 
258  item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_PRICE_NAME);
259  for ( ; item; item = g_list_next(item))
260  {
261  model = (GncTreeModelPrice *)item->data;
262  priv = GNC_TREE_MODEL_PRICE_GET_PRIVATE(model);
263  if (priv->price_db == price_db)
264  {
265  g_object_ref(G_OBJECT(model));
266  LEAVE("returning existing model %p", model);
267  return GTK_TREE_MODEL(model);
268  }
269  }
270 
271  model = g_object_new (GNC_TYPE_TREE_MODEL_PRICE,
272  NULL);
273 
274  priv = GNC_TREE_MODEL_PRICE_GET_PRIVATE(model);
275  priv->book = book;
276  priv->price_db = price_db;
277 
278  priv->event_handler_id =
279  qof_event_register_handler (gnc_tree_model_price_event_handler, model);
280 
281  return GTK_TREE_MODEL (model);
282 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
gint qof_event_register_handler(QofEventHandler handler, gpointer handler_data)
Register a handler for events.
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1859 of file gnc-tree-view-account.c.

1865 {
1866  GtkCellRenderer *renderer;
1867  GtkTreeViewColumn *column;
1868 
1869  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (account_view), NULL);
1870 
1871  renderer = gtk_cell_renderer_text_new ();
1872  g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
1873 
1874  column = gtk_tree_view_column_new_with_attributes (column_title,
1875  renderer, NULL);
1876  if (col_edited_cb)
1877  {
1878  gtva_setup_column_renderer_edited_cb(account_view, column,
1879  renderer, col_edited_cb);
1880  }
1881  gtk_tree_view_column_set_cell_data_func (column, renderer,
1882  col_source_helper,
1883  col_source_cb, NULL);
1884  gnc_tree_view_append_column (GNC_TREE_VIEW(account_view), column);
1885  return column;
1886 }
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *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 1763 of file gnc-tree-view-account.c.

1766 {
1767  GtkCellRenderer *renderer;
1768  GtkTreeViewColumn *column;
1769 
1770  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1771  g_return_val_if_fail (propname != NULL, NULL);
1772 
1773  column = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), column_title,
1774  propname, NULL, "Sample text",
1775  -1, -1, NULL);
1776 
1777  /* This new kvp column has only had one renderer added to it so
1778  * far. Find that renderer. */
1779  renderer = gnc_tree_view_column_get_renderer(column);
1780  g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
1781 
1782  gtk_tree_view_column_set_cell_data_func (column, renderer,
1783  account_cell_property_data_func,
1784  g_strdup(propname), g_free);
1785  return column;
1786 }
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
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 1040 of file gnc-tree-view-account.c.

1042 {
1043  GtkTreeModel *s_model;
1044  GtkTreeIter s_iter;
1045  gint num_children;
1046 
1047  ENTER("view %p, account %p (%s)", view, account, xaccAccountGetName(account));
1048 
1049  if (account == NULL)
1050  {
1051  LEAVE("no account");
1052  return 0;
1053  }
1054 
1055  if (!gnc_tree_view_account_get_iter_from_account (view, account, &s_iter))
1056  {
1057  LEAVE("view_get_iter_from_account failed");
1058  return 0;
1059  }
1060 
1061  /* Any children? */
1062  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1063  num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
1064  LEAVE("%d children", num_children);
1065  return num_children;
1066 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1630 of file gnc-tree-view-account.c.

1632 {
1633  GtkTreePath *path;
1634 
1635  g_return_if_fail(view != NULL);
1636  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1637  ENTER("view %p, account %p", view, account);
1638 
1639  path = gnc_tree_view_account_get_path_from_account(view, account);
1640  if (path)
1641  {
1642  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1643  gtk_tree_path_free(path);
1644  }
1645  LEAVE(" ");
1646 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1270 of file gnc-tree-view-account.c.

1272 {
1273  GtkTreeModel *model, *f_model;
1274  GtkTreeIter iter, f_iter;
1275  Account *account;
1276 
1277  g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1278  g_return_val_if_fail (s_iter != NULL, NULL);
1279 
1280  ENTER("model %p, iter %p", s_model, s_iter);
1281 
1282  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1283  &f_iter,
1284  s_iter);
1285  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1286  gtk_tree_model_filter_convert_iter_to_child_iter (
1287  GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1288  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1290  GNC_TREE_MODEL_ACCOUNT(model), &iter);
1291  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1292  return account;
1293 }
Account * gnc_tree_model_account_get_account(GncTreeModelAccount *model, GtkTreeIter *iter)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1224 of file gnc-tree-view-account.c.

1226 {
1227  GtkTreeModel *model, *f_model, *s_model;
1228  GtkTreePath *path, *f_path;
1229  GtkTreeIter iter;
1230  Account *account;
1231 
1232  ENTER("view %p", view);
1233  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1234  g_return_val_if_fail (s_path != NULL, NULL);
1235 
1236  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1237  f_path = gtk_tree_model_sort_convert_path_to_child_path (
1238  GTK_TREE_MODEL_SORT (s_model), s_path);
1239  if (!f_path)
1240  {
1241  LEAVE("no filter path");
1242  return NULL;
1243  }
1244 
1245  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1246  path = gtk_tree_model_filter_convert_path_to_child_path (
1247  GTK_TREE_MODEL_FILTER (f_model), f_path);
1248  gtk_tree_path_free(f_path);
1249  if (!path)
1250  {
1251  LEAVE("no path");
1252  return NULL;
1253  }
1254 
1255  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1256  if (!gtk_tree_model_get_iter (model, &iter, path))
1257  {
1258  LEAVE("no iter");
1259  return NULL;
1260  }
1261 
1262  account = iter.user_data;
1263  gtk_tree_path_free(path);
1264  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1265  return account;
1266 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1653 of file gnc-tree-view-account.c.

1654 {
1655  GtkTreePath *s_path;
1656  Account *account;
1657 
1658  ENTER("view %p", view);
1659  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1660 
1661  gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1662  if (!s_path)
1663  {
1664  LEAVE("no account");
1665  return NULL;
1666  }
1667 
1668  account = gnc_tree_view_account_get_account_from_path (view, s_path);
1669  gtk_tree_path_free(s_path);
1670  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1671  return account;
1672 }
#define ENTER(format, args...)
Definition: qoflog.h:261
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1301 of file gnc-tree-view-account.c.

1302 {
1303  GtkTreeSelection *selection;
1304  GtkTreeModel *f_model, *s_model;
1305  GtkTreeIter iter, f_iter, s_iter;
1306  Account *account;
1307  GtkSelectionMode mode;
1308 
1309  ENTER("view %p", view);
1310  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1311 
1312  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1313  mode = gtk_tree_selection_get_mode(selection);
1314  if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
1315  {
1316  return NULL;
1317  }
1318  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
1319  {
1320  LEAVE("no account, get_selected failed");
1321  return FALSE;
1322  }
1323 
1324  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1325  &f_iter, &s_iter);
1326 
1327  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1328  gtk_tree_model_filter_convert_iter_to_child_iter (
1329  GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
1330 
1331  account = iter.user_data;
1332  LEAVE("account %p (%s)", account, xaccAccountGetName (account));
1333  return account;
1334 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1459 of file gnc-tree-view-account.c.

1460 {
1461  GtkTreeSelection *selection;
1463 
1464  g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1465 
1466  info.return_list = NULL;
1467  info.priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
1468  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1469  gtk_tree_selection_selected_foreach(selection, get_selected_accounts_helper, &info);
1470  return info.return_list;
1471 }
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 1078 of file gnc-tree-view-account.c.

1080 {
1082 
1083  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view));
1084  g_return_if_fail(avi != NULL);
1085 
1086  priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(account_view);
1087 
1088  *avi = priv->avi;
1089 }
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 945 of file gnc-tree-view-account.c.

946 {
947  Account *root;
948 
949  root = gnc_book_get_root_account (gnc_get_current_book ());
950  return gnc_tree_view_account_new_with_root (root, show_root);
951 }
GtkTreeView * gnc_tree_view_account_new_with_root(Account *root, gboolean show_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 673 of file gnc-tree-view-account.c.

674 {
675  GncTreeView *view;
676  GtkTreeModel *model, *f_model, *s_model;
677  GtkTreePath *virtual_root_path = NULL;
678  const gchar *sample_type, *sample_commodity;
680  GtkTreeViewColumn *tax_info_column, *acc_color_column;
681  GtkCellRenderer *renderer;
682 
683  ENTER(" ");
684  /* Create our view */
685  view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT,
686  "name", "account_tree", NULL);
687 
688  priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(GNC_TREE_VIEW_ACCOUNT (view));
689 
690  /* Get the show_account_color value from gsettings */
691  priv->show_account_color = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_COLOR);
692 
693  /* Create/get a pointer to the existing model for this set of books. */
694  model = gnc_tree_model_account_new (root);
695 
696  /* Set up the view private filter layer on the common model. */
697  if (!show_root)
698  virtual_root_path = gtk_tree_path_new_first ();
699  f_model = gtk_tree_model_filter_new (model, virtual_root_path);
700  /* A GncTreeModelAccount is based on a GncTreeModel, which is a
701  * GObject that provides a GtkTreeModel interface. */
702  g_object_unref(G_OBJECT(model));
703  if (virtual_root_path)
704  gtk_tree_path_free(virtual_root_path);
705 
706  /* Set up the view private sort layer on the common model. */
707  s_model = gtk_tree_model_sort_new_with_model(f_model);
708  g_object_unref(G_OBJECT(f_model));
709  gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
710  g_object_unref(G_OBJECT(s_model));
711 
712  /* Set default visibilities */
713  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
714 
716  sample_commodity = gnc_commodity_get_fullname(gnc_default_currency());
717 
718  priv->name_column
719  = gnc_tree_view_add_text_column(view, _("Account Name"), "name",
720  GNC_STOCK_ACCOUNT, "Expenses:Entertainment",
721  GNC_TREE_MODEL_ACCOUNT_COL_NAME,
722  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
723  sort_by_string);
724 
725  renderer = gnc_tree_view_column_get_renderer(priv->name_column);
726 
727  gtk_tree_view_column_set_cell_data_func(priv->name_column,
728  renderer,
729  acc_color_data_func,
730  GTK_TREE_VIEW(view),
731  NULL);
732 
733  gnc_tree_view_add_text_column(view, _("Type"), "type", NULL, sample_type,
734  GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
735  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
736  sort_by_string);
737 
738  gnc_tree_view_add_text_column(view, _("Commodity"), "commodity", NULL,
739  sample_commodity,
740  GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
741  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
742  sort_by_string);
743  priv->code_column
744  = gnc_tree_view_add_text_column(view, _("Account Code"), "account-code", NULL,
745  "1-123-1234",
746  GNC_TREE_MODEL_ACCOUNT_COL_CODE,
747  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
748  sort_by_code);
749  priv->desc_column
750  = gnc_tree_view_add_text_column(view, _("Description"), "description", NULL,
751  "Sample account description.",
752  GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
753  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
754  sort_by_string);
755 
756  gnc_tree_view_add_numeric_column(view, _("Last Num"), "lastnum", "12345",
757  GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
758  GNC_TREE_VIEW_COLUMN_COLOR_NONE,
759  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
760  sort_by_string);
761 
762  gnc_tree_view_add_numeric_column(view, _("Present"), "present",
763  SAMPLE_ACCOUNT_VALUE,
764  GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
765  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
766  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
767  sort_by_present_value);
768  priv->present_report_column
769  = gnc_tree_view_add_numeric_column(view, _("Present (Report)"), "present_report",
770  SAMPLE_ACCOUNT_VALUE,
771  GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
772  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
773  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
774  sort_by_present_value);
775 
776  gnc_tree_view_add_numeric_column(view, _("Balance"), "balance",
777  SAMPLE_ACCOUNT_VALUE,
778  GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
779  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
780  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
781  sort_by_balance_value);
782  priv->balance_report_column
783  = gnc_tree_view_add_numeric_column(view, _("Balance (Report)"), "balance_report",
784  SAMPLE_ACCOUNT_VALUE,
785  GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
786  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
787  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
788  sort_by_balance_value);
789 
790  gnc_tree_view_add_numeric_column(view, _("Balance (Period)"), "balance-period",
791  SAMPLE_ACCOUNT_VALUE,
792  GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD,
793  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
794  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
795  sort_by_balance_period_value);
796 
797  gnc_tree_view_add_numeric_column(view, _("Cleared"), "cleared",
798  SAMPLE_ACCOUNT_VALUE,
799  GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
800  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
801  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
802  sort_by_cleared_value);
803  priv->cleared_report_column
804  = gnc_tree_view_add_numeric_column(view, _("Cleared (Report)"), "cleared_report",
805  SAMPLE_ACCOUNT_VALUE,
806  GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
807  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
808  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
809  sort_by_cleared_value);
810 
811  gnc_tree_view_add_numeric_column(view, _("Reconciled"), "reconciled",
812  SAMPLE_ACCOUNT_VALUE,
813  GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
814  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
815  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
816  sort_by_reconciled_value);
817  priv->reconciled_report_column
818  = gnc_tree_view_add_numeric_column(view, _("Reconciled (Report)"), "reconciled_report",
819  SAMPLE_ACCOUNT_VALUE,
820  GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
821  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
822  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
823  sort_by_reconciled_value);
824 
825  gnc_tree_view_add_text_column(view, _("Last Reconcile Date"), "last-recon-date", NULL,
826  "Last Reconcile Date",
827  GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
828  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
829  sort_by_string);
830 
831  gnc_tree_view_add_numeric_column(view, _("Future Minimum"), "future_min",
832  SAMPLE_ACCOUNT_VALUE,
833  GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
834  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
835  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
836  sort_by_future_min_value);
837  priv->future_min_report_column
838  = gnc_tree_view_add_numeric_column(view, _("Future Minimum (Report)"), "future_min_report",
839  SAMPLE_ACCOUNT_VALUE,
840  GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
841  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
842  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
843  sort_by_future_min_value);
844 
845  gnc_tree_view_add_numeric_column(view, _("Total"), "total",
846  SAMPLE_ACCOUNT_VALUE,
847  GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
848  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
849  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
850  sort_by_total_value);
851  priv->total_report_column
852  = gnc_tree_view_add_numeric_column(view, _("Total (Report)"), "total_report",
853  SAMPLE_ACCOUNT_VALUE,
854  GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
855  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
856  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
857  sort_by_total_value);
858 
859  gnc_tree_view_add_numeric_column(view, _("Total (Period)"), "total-period",
860  SAMPLE_ACCOUNT_VALUE,
861  GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
862  GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
863  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
864  sort_by_total_period_value);
865 
866  /* Translators: The C is the column title and stands for Color, this should be one character */
867  acc_color_column
868  = gnc_tree_view_add_text_column(view, _("C"), "account-color", NULL,
869  "xx",
870  GNC_TREE_VIEW_COLUMN_DATA_NONE,
871  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
872  NULL);
873 
874  renderer = gnc_tree_view_column_get_renderer(acc_color_column);
875 
876  /* Add the full title to the object for menu creation */
877  g_object_set_data_full(G_OBJECT(acc_color_column), REAL_TITLE,
878  g_strdup(_("Account Color")), g_free);
879 
880  gtk_tree_view_column_set_cell_data_func(acc_color_column,
881  renderer,
882  acc_color_data_func,
883  GTK_TREE_VIEW(view),
884  NULL);
885  priv->notes_column
886  = gnc_tree_view_add_text_column(view, _("Notes"), "notes", NULL,
887  "Sample account notes.",
888  GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
889  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
890  sort_by_string);
891  tax_info_column
892  = gnc_tree_view_add_text_column(view, _("Tax Info"), "tax-info", NULL,
893  "Sample tax info.",
894  GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
895  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
896  sort_by_string);
897 
898  renderer = gnc_tree_view_column_get_renderer(tax_info_column);
899  gtk_tree_view_column_set_cell_data_func(tax_info_column,
900  renderer,
901  tax_info_data_func,
902  GTK_TREE_VIEW(view),
903  NULL);
904 
905  gnc_tree_view_add_toggle_column(view, _("Placeholder"),
906  /* Translators: This string has a context prefix; the translation
907  must only contain the part after the | character. */
908  Q_("Column letter for 'Placeholder'|P"),
909  "placeholder",
910  GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
911  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
912  sort_by_placeholder,
913  gnc_tree_view_account_placeholder_toggled);
914 
915  /* Update column titles to use the currency name. */
916  gtva_update_column_names(view);
917 
918  /* By default only the first column is visible. */
920  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
921  gnc_tree_view_account_filter_helper,
922  view,
923  NULL);
924 
925  /* Default the sorting to account name */
926  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
927  GNC_TREE_MODEL_ACCOUNT_COL_NAME,
928  GTK_SORT_ASCENDING);
929 
930  /* Set account find-as-you-type search function */
931  gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(view), gnc_tree_view_search_compare, NULL, NULL);
932 
933  gtk_widget_show(GTK_WIDGET(view));
934  LEAVE("%p", view);
935  return GTK_TREE_VIEW(view);
936 }
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
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)
#define ENTER(format, args...)
Definition: qoflog.h:261
gnc_commodity * gnc_default_currency(void)
Definition: gnc-ui-util.c:939
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)
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
GtkTreeModel * gnc_tree_model_account_new(Account *root)
void gnc_tree_view_configure_columns(GncTreeView *view)
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetTypeStr(GNCAccountType type)
Definition: Account.c:4137
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 1190 of file gnc-tree-view-account.c.

1191 {
1192  GtkTreeModel *f_model, *s_model;
1193 
1194  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1195 
1196  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1197  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1198  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
1199 }
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 1558 of file gnc-tree-view-account.c.

1560 {
1561  GtkTreeModel *s_model;
1562  GtkTreeSelection *selection;
1563  GtkTreePath *sp_account, *sp_start, *sp_end;
1564  GtkTreeIter si_account, si_start, si_end;
1565  gboolean have_start, have_end;
1566  gint num_children;
1567 
1568  ENTER("view %p, account %p (%s)", view, account, xaccAccountGetName(account));
1569 
1570  g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1571 
1572  if (account == NULL)
1573  {
1574  LEAVE("no account");
1575  return;
1576  }
1577 
1578  if (!gnc_tree_view_account_get_iter_from_account (view, account, &si_account))
1579  {
1580  LEAVE("view_get_iter_from_account failed");
1581  return;
1582  }
1583 
1584  /* Any children? */
1585  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1586  num_children = gtk_tree_model_iter_n_children(s_model, &si_account);
1587  if (num_children == 0)
1588  {
1589  LEAVE("no children");
1590  return;
1591  }
1592 
1593  /* Expand the tree. Required for selection to work */
1594  sp_account = gtk_tree_model_get_path (s_model, &si_account);
1595  gtk_tree_view_expand_row (GTK_TREE_VIEW(view), sp_account, TRUE);
1596 
1597  /* compute start/end paths */
1598  have_start = gtk_tree_model_iter_nth_child(s_model, &si_start, &si_account, 0);
1599  si_end = si_account;
1600  while (num_children)
1601  {
1602  GtkTreeIter tmp_iter = si_end;
1603  have_end = gtk_tree_model_iter_nth_child(s_model, &si_end, &tmp_iter,
1604  num_children - 1);
1605  if (have_end)
1606  num_children = gtk_tree_model_iter_n_children(s_model, &si_end);
1607  else
1608  num_children = 0;
1609  }
1610 
1611  if (have_start && have_end)
1612  {
1613  sp_start = gtk_tree_model_get_path (s_model, &si_start);
1614  sp_end = gtk_tree_model_get_path (s_model, &si_end);
1615 
1616  /* select everything between */
1617  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1618  gtk_tree_selection_select_range (selection, sp_start, sp_end);
1619 
1620  /* clean up */
1621  gtk_tree_path_free(sp_start);
1622  gtk_tree_path_free(sp_end);
1623  }
1624  gtk_tree_path_free(sp_account);
1625  LEAVE(" ");
1626  return;
1627 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 1161 of file gnc-tree-view-account.c.

1165 {
1167 
1168  ENTER("view %p, filter func %p, data %p, destroy %p",
1169  view, func, data, destroy);
1170 
1171  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1172 
1173  priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
1174  if (priv->filter_destroy)
1175  {
1176  priv->filter_destroy(priv->filter_data);
1177  }
1178  priv->filter_destroy = destroy;
1179  priv->filter_data = data;
1180  priv->filter_fn = func;
1181 
1183  LEAVE(" ");
1184 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 entitre 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 1341 of file gnc-tree-view-account.c.

1343 {
1344  GtkTreeModel *model, *f_model, *s_model;
1345  GtkTreePath *path, *f_path, *s_path, *parent_path;
1346  GtkTreeSelection *selection;
1347 
1348  ENTER("view %p, account %p (%s)", view,
1349  account, xaccAccountGetName (account));
1350  g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1351 
1352  /* Clear any existing selection. */
1353  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1354  gtk_tree_selection_unselect_all (selection);
1355 
1356  if (account == NULL)
1357  return;
1358 
1359  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1360  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1361  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1362 
1364  GNC_TREE_MODEL_ACCOUNT(model), account);
1365  if (path == NULL)
1366  {
1367  LEAVE("no path");
1368  return;
1369  }
1370  debug_path(DEBUG, path);
1371 
1372  f_path = gtk_tree_model_filter_convert_child_path_to_path (
1373  GTK_TREE_MODEL_FILTER (f_model), path);
1374  gtk_tree_path_free(path);
1375  if (f_path == NULL)
1376  {
1377  LEAVE("no filter path");
1378  return;
1379  }
1380  debug_path(DEBUG, f_path);
1381 
1382  s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1383  f_path);
1384  gtk_tree_path_free(f_path);
1385  if (s_path == NULL)
1386  {
1387  LEAVE("no sort path");
1388  return;
1389  }
1390 
1391  /* gtk_tree_view requires that a row be visible before it can be selected */
1392  parent_path = gtk_tree_path_copy (s_path);
1393  if (gtk_tree_path_up (parent_path))
1394  {
1395  /* This function is misnamed. It expands the actual item
1396  * specified, not the path to the item specified. I.E. It expands
1397  * one level too many, thus the get of the parent. */
1398  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1399  }
1400  gtk_tree_path_free(parent_path);
1401 
1402  gtk_tree_selection_select_path (selection, s_path);
1403 
1404  /* give gtk+ a chance to resize the tree view first by handling pending
1405  * configure events */
1406  while (gtk_events_pending ())
1407  gtk_main_iteration ();
1408  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1409  debug_path(LEAVE, s_path);
1410  gtk_tree_path_free(s_path);
1411 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define ENTER(format, args...)
Definition: qoflog.h:261
GtkTreePath * gnc_tree_model_account_get_path_from_account(GncTreeModelAccount *model, Account *account)
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031
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 entitre 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 1478 of file gnc-tree-view-account.c.

1481 {
1482  GtkTreeModel *model, *f_model, *s_model;
1483  GtkTreePath *path, *f_path, *s_path, *parent_path;
1484  GtkTreeSelection *selection;
1485  GList *element;
1486  Account *account;
1487 
1488  g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1489 
1490  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1491  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1492  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1493 
1494  /* Clear any existing selection. */
1495  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1496  gtk_tree_selection_unselect_all (selection);
1497  gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
1498 
1499  /* Now go select what the user requested. */
1500  for (element = account_list; element; )
1501  {
1502  account = element->data;
1503  element = g_list_next(element);
1504 
1505  if (account == NULL)
1506  {
1507  /*
1508  * Oops. Someone must have deleted this account and not cleaned
1509  * up all references to it.
1510  */
1511  continue;
1512  }
1513 
1514  path = gnc_tree_model_account_get_path_from_account (GNC_TREE_MODEL_ACCOUNT(model), account);
1515  if (path == NULL)
1516  {
1517  /*
1518  * Oops. Someone must have deleted this account and not cleaned
1519  * up all references to it.
1520  */
1521  continue;
1522  }
1523 
1524  f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
1525  path);
1526  gtk_tree_path_free(path);
1527  if (f_path == NULL)
1528  continue;
1529 
1530  s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1531  f_path);
1532  gtk_tree_path_free(f_path);
1533  if (s_path == NULL)
1534  continue;
1535 
1536  /* gtk_tree_view requires that a row be visible before it can be selected */
1537  parent_path = gtk_tree_path_copy (s_path);
1538  if (gtk_tree_path_up (parent_path))
1539  {
1540  /* This function is misnamed. It expands the actual item
1541  * specified, not the path to the item specified. I.E. It
1542  * expands one level too many, thus the get of the parent. */
1543  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1544  }
1545  gtk_tree_path_free(parent_path);
1546 
1547  gtk_tree_selection_select_path (selection, s_path);
1548  if (show_last && (element == NULL))
1549  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1550  gtk_tree_path_free(s_path);
1551  }
1552 }
GtkTreePath * gnc_tree_model_account_get_path_from_account(GncTreeModelAccount *model, Account *account)
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 1106 of file gnc-tree-view-account.c.

1108 {
1110  gint i;
1111  guint sel_bits = 0;
1112 
1113  ENTER("%p", account_view);
1114  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view));
1115  g_return_if_fail(avi != NULL);
1116 
1117  priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(account_view);
1118  priv->avi = *avi;
1119 
1120  for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
1121  {
1122  sel_bits |= avi->include_type[i] ? (1 << i) : 0;
1123  }
1124 
1126  account_view, gnc_tree_view_account_filter_by_view_info,
1127  &priv->avi, NULL);
1128 
1129  LEAVE(" ");
1130 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_set_filter(GncTreeViewAccount *view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 avalible 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_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_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 645 of file gnc-tree-view-commodity.c.

646 {
647  GtkTreeSelection *selection;
648  GtkTreeModel *model, *f_model, *s_model;
649  GtkTreeIter iter, f_iter, s_iter;
650  gnc_commodity *commodity;
651 
652  g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY (view), NULL);
653 
654  ENTER("view %p", view);
655 
656  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
657  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
658  {
659  LEAVE("no commodity, get_selected failed");
660  return FALSE;
661  }
662 
663  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
664  &f_iter, &s_iter);
665 
666  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
667  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
668  &iter, &f_iter);
669 
670  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
671  commodity = gnc_tree_model_commodity_get_commodity (GNC_TREE_MODEL_COMMODITY(model),
672  &iter);
673  LEAVE("commodity %p (%s)", commodity,
674  commodity ? gnc_commodity_get_mnemonic(commodity) : "");
675  return commodity;
676 }
gnc_commodity * gnc_tree_model_commodity_get_commodity(GncTreeModelCommodity *model, GtkTreeIter *iter)
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 350 of file gnc-tree-view-commodity.c.

353 {
354  GncTreeView *view;
355  GtkTreeModel *model, *f_model, *s_model;
356  GtkTreeViewColumn *col;
358  va_list var_args;
359 
360  ENTER(" ");
361  /* Create/get a pointer to the existing model for this set of books. */
362  ct = gnc_commodity_table_get_table (book);
363  model = gnc_tree_model_commodity_new (book, ct);
364 
365  /* Set up the view private filter on the common model. */
366  f_model = gtk_tree_model_filter_new (model, NULL);
367  g_object_unref(G_OBJECT(model));
368  s_model = gtk_tree_model_sort_new_with_model (f_model);
369  g_object_unref(G_OBJECT(f_model));
370 
371  /* Create our view */
372  view = g_object_new (GNC_TYPE_TREE_VIEW_COMMODITY,
373  "name", "commodity_tree", NULL);
374  gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
375  g_object_unref(G_OBJECT(s_model));
376 
377  DEBUG("model ref count is %d", G_OBJECT(model)->ref_count);
378  DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
379  DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
380 
381  /* Set default visibilities */
382  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
383 
385  view, _("Namespace"), "namespace", NULL, "NASDAQ",
386  GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
387  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
388  sort_by_commodity_string);
390  view, _("Symbol"), "symbol", NULL, "ACMEACME",
391  GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC,
392  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
393  sort_by_commodity_string);
394  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
396  view, _("Name"), "name", NULL, "Acme Corporation, Inc.",
397  GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
398  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
399  sort_by_commodity_string);
400  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
402  view, _("Print Name"), "printname", NULL,
403  "ACMEACME (Acme Corporation, Inc.)",
404  GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
405  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
406  sort_by_commodity_string);
408  view, _("Display symbol"), "user_symbol", NULL, "ACME",
409  GNC_TREE_MODEL_COMMODITY_COL_USER_SYMBOL,
410  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
411  sort_by_commodity_string);
412  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
414  view, _("Unique Name"), "uniquename", NULL,
415  "NASDAQ::ACMEACME", GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
416  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
417  sort_by_commodity_string);
419  /* Translators: Again replace CUSIP by the name of your
420  National Securities Identifying Number. */
421  view, _("ISIN/CUSIP"), "cusip_code", NULL, "QWERTYUIOP",
422  GNC_TREE_MODEL_COMMODITY_COL_CUSIP,
423  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
424  sort_by_commodity_string);
425  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
427  view, _("Fraction"), "fraction", "10000",
428  GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
429  GNC_TREE_VIEW_COLUMN_COLOR_NONE,
430  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
431  sort_by_fraction);
432  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
434  view, _("Get Quotes"),
435  /* Translators: This string has a context prefix; the translation
436  must only contain the part after the | character. */
437  Q_("Column letter for 'Get Quotes'|Q"), "quote_flag",
438  GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG,
439  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
440  sort_by_quote_flag,
441  NULL);
443  view, _("Source"), "quote_source", NULL, "yahoo",
444  GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
445  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
446  sort_by_commodity_string);
448  view, _("Timezone"), "quote_timezone", NULL, "America/New_York",
449  GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
450  GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
451  sort_by_commodity_string);
452  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
453 
455 
456  /* Set properties */
457  va_start (var_args, first_property_name);
458  g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
459  va_end (var_args);
460 
461  /* Sort on the name column by default. This allows for a consistent
462  * sort if commodities are briefly removed and re-added. */
463  if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
464  NULL, NULL))
465  {
466  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
467  GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
468  GTK_SORT_ASCENDING);
469  }
470 
471  gtk_widget_show(GTK_WIDGET(view));
472  LEAVE(" %p", view);
473  return GTK_TREE_VIEW(view);
474 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
#define DEBUG(format, args...)
Definition: qoflog.h:255
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)
#define ENTER(format, args...)
Definition: qoflog.h:261
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)
void gnc_tree_view_configure_columns(GncTreeView *view)
GtkTreeModel * gnc_tree_model_commodity_new(QofBook *book, gnc_commodity_table *ct)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 622 of file gnc-tree-view-commodity.c.

623 {
624  GtkTreeModel *f_model, *s_model;
625 
626  g_return_if_fail(GNC_IS_TREE_VIEW_COMMODITY(view));
627 
628  ENTER("view %p", view);
629  s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
630  f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
631  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
632  LEAVE(" ");
633 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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.
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 wil 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 584 of file gnc-tree-view-commodity.c.

589 {
590  GtkTreeModel *f_model, *s_model;
591  filter_user_data *fd = data;
592 
593  g_return_if_fail(GNC_IS_TREE_VIEW_COMMODITY(view));
594  g_return_if_fail((ns_func != NULL) || (cm_func != NULL));
595 
596  ENTER("view %p, ns func %p, cm func %p, data %p, destroy %p",
597  view, ns_func, cm_func, data, destroy);
598 
599  fd = g_malloc(sizeof(filter_user_data));
600  fd->user_ns_fn = ns_func;
601  fd->user_cm_fn = cm_func;
602  fd->user_data = data;
603  fd->user_destroy = destroy;
604 
605  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
606  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
607  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
608  gnc_tree_view_commodity_filter_helper,
609  fd,
610  gnc_tree_view_commodity_filter_destroy);
611 
612  /* Whack any existing levels. The top two levels have been created
613  * before this routine can be called. */
614  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
615  LEAVE(" ");
616 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 726 of file gnc-tree-view-owner.c.

728 {
729  GtkTreeModel *model, *f_model;
730  GtkTreeIter iter, f_iter;
731  GncOwner *owner;
732 
733  g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
734  g_return_val_if_fail (s_iter != NULL, NULL);
735 
736  ENTER("model %p, iter %p", s_model, s_iter);
737 
738  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
739  &f_iter,
740  s_iter);
741  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
742  gtk_tree_model_filter_convert_iter_to_child_iter (
743  GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
744  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
746  GNC_TREE_MODEL_OWNER(model), &iter);
747  LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
748  return owner;
749 }
#define ENTER(format, args...)
Definition: qoflog.h:261
GncOwner * gnc_tree_model_owner_get_owner(GncTreeModelOwner *model, GtkTreeIter *iter)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 680 of file gnc-tree-view-owner.c.

682 {
683  GtkTreeModel *model, *f_model, *s_model;
684  GtkTreePath *path, *f_path;
685  GtkTreeIter iter;
686  GncOwner *owner;
687 
688  ENTER("view %p", view);
689  g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
690  g_return_val_if_fail (s_path != NULL, NULL);
691 
692  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
693  f_path = gtk_tree_model_sort_convert_path_to_child_path (
694  GTK_TREE_MODEL_SORT (s_model), s_path);
695  if (!f_path)
696  {
697  LEAVE("no filter path");
698  return NULL;
699  }
700 
701  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
702  path = gtk_tree_model_filter_convert_path_to_child_path (
703  GTK_TREE_MODEL_FILTER (f_model), f_path);
704  gtk_tree_path_free(f_path);
705  if (!path)
706  {
707  LEAVE("no path");
708  return NULL;
709  }
710 
711  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
712  if (!gtk_tree_model_get_iter (model, &iter, path))
713  {
714  LEAVE("no iter");
715  return NULL;
716  }
717 
718  owner = iter.user_data;
719  gtk_tree_path_free(path);
720  LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
721  return owner;
722 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 757 of file gnc-tree-view-owner.c.

758 {
759  GtkTreeSelection *selection;
760  GtkTreeModel *f_model, *s_model;
761  GtkTreeIter iter, f_iter, s_iter;
762  GncOwner *owner;
763  GtkSelectionMode mode;
764 
765  ENTER("view %p", view);
766  g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
767 
768  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
769  mode = gtk_tree_selection_get_mode(selection);
770  if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
771  {
772  return NULL;
773  }
774  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
775  {
776  LEAVE("no owner, get_selected failed");
777  return FALSE;
778  }
779 
780  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
781  &f_iter, &s_iter);
782 
783  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
784  gtk_tree_model_filter_convert_iter_to_child_iter (
785  GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
786 
787  owner = iter.user_data;
788  LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
789  return owner;
790 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 362 of file gnc-tree-view-owner.c.

363 {
364  GncTreeView *view;
365  GtkTreeModel *model, *f_model, *s_model;
366  const gchar *sample_type, *sample_currency;
368 
369  ENTER(" ");
370  /* Create our view */
371  view = g_object_new (GNC_TYPE_TREE_VIEW_OWNER,
372  "name", "owner_tree", NULL);
373 
374  priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(GNC_TREE_VIEW_OWNER (view));
375 
376  /* Create/get a pointer to the existing model for this set of books. */
377  model = gnc_tree_model_owner_new (owner_type);
378 
379  /* Set up the view private filter layer on the common model. */
380  f_model = gtk_tree_model_filter_new (model, NULL);
381  /* A GncTreeModelOwner is based on a GncTreeModel, which is a
382  * GObject that provides a GtkTreeModel interface. */
383  g_object_unref(G_OBJECT(model));
384 
385  /* Set up the view private sort layer on the common model. */
386  s_model = gtk_tree_model_sort_new_with_model(f_model);
387  g_object_unref(G_OBJECT(f_model));
388  gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
389  g_object_unref(G_OBJECT(s_model));
390 
391  /* Set default visibilities */
392  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
393 
394  sample_type = gncOwnerTypeToQofIdType (GNC_OWNER_CUSTOMER);
396 
397  priv->name_column
398  = gnc_tree_view_add_text_column(view, _("Owner Name"), GNC_OWNER_TREE_NAME_COL,
399  NULL, "GnuCash Inc.",
400  GNC_TREE_MODEL_OWNER_COL_NAME,
401  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
402  sort_by_string);
403  gnc_tree_view_add_text_column(view, _("Type"), GNC_OWNER_TREE_TYPE_COL,
404  NULL, sample_type,
405  GNC_TREE_MODEL_OWNER_COL_TYPE,
406  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
407  sort_by_string);
408  priv->id_column
409  = gnc_tree_view_add_text_column(view, _("Owner ID"), GNC_OWNER_TREE_ID_COL,
410  NULL, "1-123-1234",
411  GNC_TREE_MODEL_OWNER_COL_ID,
412  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
413  sort_by_string);
414  gnc_tree_view_add_text_column(view, _("Currency"), GNC_OWNER_TREE_CURRENCY_COL,
415  NULL, sample_currency,
416  GNC_TREE_MODEL_OWNER_COL_CURRENCY,
417  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
418  sort_by_string);
419  gnc_tree_view_add_text_column(view, _("Address Name"), GNC_OWNER_TREE_ADDRESS_NAME_COL,
420  NULL, "GnuCash Inc.",
421  GNC_TREE_MODEL_OWNER_COL_ADDRESS_NAME,
422  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
423  sort_by_string);
424  gnc_tree_view_add_text_column(view, _("Address 1"), GNC_OWNER_TREE_ADDRESS_1_COL,
425  NULL, "Free Software Foundation",
426  GNC_TREE_MODEL_OWNER_COL_ADDRESS_1,
427  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
428  sort_by_string);
429  gnc_tree_view_add_text_column(view, _("Address 2"), GNC_OWNER_TREE_ADDRESS_2_COL,
430  NULL, "51 Franklin Street, Fifth Floor",
431  GNC_TREE_MODEL_OWNER_COL_ADDRESS_2,
432  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
433  sort_by_string);
434  gnc_tree_view_add_text_column(view, _("Address 3"), GNC_OWNER_TREE_ADDRESS_3_COL,
435  NULL, "Boston, MA 02110-1301",
436  GNC_TREE_MODEL_OWNER_COL_ADDRESS_3,
437  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
438  sort_by_string);
439  gnc_tree_view_add_text_column(view, _("Address 4"), GNC_OWNER_TREE_ADDRESS_4_COL,
440  NULL, "USA",
441  GNC_TREE_MODEL_OWNER_COL_ADDRESS_4,
442  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
443  sort_by_string);
444  gnc_tree_view_add_text_column(view, _("Phone"), GNC_OWNER_TREE_PHONE_COL,
445  NULL, "+1-617-542-5942",
446  GNC_TREE_MODEL_OWNER_COL_PHONE,
447  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
448  sort_by_string);
449  gnc_tree_view_add_text_column(view, _("Fax"), GNC_OWNER_TREE_FAX_COL,
450  NULL, "+1-617-542-2652",
451  GNC_TREE_MODEL_OWNER_COL_FAX,
452  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
453  sort_by_string);
454  gnc_tree_view_add_text_column(view, _("E-mail"), GNC_OWNER_TREE_EMAIL_COL,
455  NULL, "[email protected]",
456  GNC_TREE_MODEL_OWNER_COL_EMAIL,
457  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
458  sort_by_string);
459  gnc_tree_view_add_numeric_column(view, _("Balance"), GNC_OWNER_TREE_BALANCE_COL,
460  SAMPLE_OWNER_VALUE,
461  GNC_TREE_MODEL_OWNER_COL_BALANCE,
462  GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE,
463  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
464  sort_by_balance_value);
465 
466  priv->balance_report_column
467  = gnc_tree_view_add_numeric_column(view, _("Balance"), GNC_OWNER_TREE_BALANCE_REPORT_COL,
468  SAMPLE_OWNER_VALUE,
469  GNC_TREE_MODEL_OWNER_COL_BALANCE_REPORT,
470  GNC_TREE_MODEL_OWNER_COL_COLOR_BALANCE,
471  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
472  sort_by_balance_value);
473 
474  priv->notes_column
475  = gnc_tree_view_add_text_column(view, _("Notes"), GNC_OWNER_TREE_NOTES_COL, NULL,
476  "Sample owner notes.",
477  GNC_TREE_MODEL_OWNER_COL_NOTES,
478  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
479  sort_by_string);
480  gnc_tree_view_add_toggle_column (view, _("Active"),
481  /* Translators: This string has a context prefix; the translation
482  must only contain the part after the | character. */
483  Q_("Column letter for 'Active'|A"),
484  GNC_OWNER_TREE_ACTIVE_COL,
485  GNC_TREE_MODEL_OWNER_COL_ACTIVE,
486  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
487  sort_by_boolean,
488  gnc_tree_view_owner_active_toggled);
489 
490  /* Update column titles to use the currency name. */
491  gtvo_update_column_names(view);
492 
493  /* By default only the first column is visible. */
495  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
496  gnc_tree_view_owner_filter_helper,
497  view,
498  NULL);
499 
500  /* Default the sorting to owner name */
501  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
502  GNC_TREE_MODEL_OWNER_COL_NAME,
503  GTK_SORT_ASCENDING);
504 
505  gtk_widget_show(GTK_WIDGET(view));
506  LEAVE("%p", view);
507  return GTK_TREE_VIEW(view);
508 }
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
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)
#define ENTER(format, args...)
Definition: qoflog.h:261
gnc_commodity * gnc_default_currency(void)
Definition: gnc-ui-util.c:939
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)
GtkTreeModel * gnc_tree_model_owner_new(GncOwnerType owner_type)
void gnc_tree_view_configure_columns(GncTreeView *view)
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Definition: gncOwner.c:213
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 660 of file gnc-tree-view-owner.c.

661 {
662  GtkTreeModel *f_model, *s_model;
663 
664  g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(view));
665 
666  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
667  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
668  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
669 }
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 631 of file gnc-tree-view-owner.c.

635 {
637 
638  ENTER("view %p, filter func %p, data %p, destroy %p",
639  view, func, data, destroy);
640 
641  g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(view));
642 
643  priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(view);
644  if (priv->filter_destroy)
645  {
646  priv->filter_destroy(priv->filter_data);
647  }
648  priv->filter_destroy = destroy;
649  priv->filter_data = data;
650  priv->filter_fn = func;
651 
653  LEAVE(" ");
654 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 entitre 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 797 of file gnc-tree-view-owner.c.

799 {
800  GtkTreeModel *model, *f_model, *s_model;
801  GtkTreePath *path, *f_path, *s_path;
802  GtkTreeSelection *selection;
803 
804  ENTER("view %p, owner %p (%s)", view,
805  owner, gncOwnerGetName (owner));
806  g_return_if_fail (GNC_IS_TREE_VIEW_OWNER (view));
807 
808  /* Clear any existing selection. */
809  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
810  gtk_tree_selection_unselect_all (selection);
811 
812  if (owner == NULL)
813  return;
814 
815  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
816  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
817  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
818 
820  GNC_TREE_MODEL_OWNER(model), owner);
821  if (path == NULL)
822  {
823  LEAVE("no path");
824  return;
825  }
826  debug_path(DEBUG, path);
827 
828  f_path = gtk_tree_model_filter_convert_child_path_to_path (
829  GTK_TREE_MODEL_FILTER (f_model), path);
830  gtk_tree_path_free(path);
831  if (f_path == NULL)
832  {
833  LEAVE("no filter path");
834  return;
835  }
836  debug_path(DEBUG, f_path);
837 
838  s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
839  f_path);
840  gtk_tree_path_free(f_path);
841  if (s_path == NULL)
842  {
843  LEAVE("no sort path");
844  return;
845  }
846 
847  gtk_tree_selection_select_path (selection, s_path);
848 
849  /* give gtk+ a chance to resize the tree view first by handling pending
850  * configure events */
851  while (gtk_events_pending ())
852  gtk_main_iteration ();
853  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
854  debug_path(LEAVE, s_path);
855  gtk_tree_path_free(s_path);
856 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define ENTER(format, args...)
Definition: qoflog.h:261
GtkTreePath * gnc_tree_model_owner_get_path_from_owner(GncTreeModelOwner *model, GncOwner *owner)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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.
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 657 of file gnc-tree-view-price.c.

658 {
659  GtkTreeSelection *selection;
660  GtkTreeModel *model, *f_model, *s_model;
661  GtkTreeIter iter, f_iter, s_iter;
662  GNCPrice *price;
663 
664  ENTER("view %p", view);
665  g_return_val_if_fail (GNC_IS_TREE_VIEW_PRICE (view), NULL);
666 
667  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
668  if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
669  {
670  LEAVE("no price, get_selected failed");
671  return FALSE;
672  }
673 
674  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
675  &f_iter, &s_iter);
676 
677  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
678  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
679  &iter, &f_iter);
680 
681  model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
682  price = gnc_tree_model_price_get_price (GNC_TREE_MODEL_PRICE(model),
683  &iter);
684  LEAVE("price %p", price);
685  return price;
686 }
GNCPrice * gnc_tree_model_price_get_price(GncTreeModelPrice *model, GtkTreeIter *iter)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 795 of file gnc-tree-view-price.c.

796 {
797  GtkTreeSelection *selection;
798  GList *return_list = NULL;
799 
800  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
801  gtk_tree_selection_selected_foreach(selection, get_selected_prices_helper, &return_list);
802  return return_list;
803 }
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 389 of file gnc-tree-view-price.c.

392 {
393  GncTreeView *view;
394  GtkTreeModel *model, *f_model, *s_model;
395  GtkTreeViewColumn *col;
396  GNCPriceDB *price_db;
397  va_list var_args;
398  const gchar *sample_text;
399  gchar *sample_text2;
400 
401  ENTER(" ");
402  /* Create/get a pointer to the existing model for this set of books. */
403  price_db = gnc_pricedb_get_db(book);
404  model = gnc_tree_model_price_new (book, price_db);
405 
406  /* Set up the view private filter on the common model. */
407  f_model = gtk_tree_model_filter_new (model, NULL);
408  g_object_unref(G_OBJECT(model));
409  s_model = gtk_tree_model_sort_new_with_model (f_model);
410  g_object_unref(G_OBJECT(f_model));
411 
412  /* Create our view */
413  view = g_object_new (GNC_TYPE_TREE_VIEW_PRICE,
414  "name", "price_tree", NULL);
415  gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
416  g_object_unref(G_OBJECT(s_model));
417 
418  DEBUG("model ref count is %d", G_OBJECT(model)->ref_count);
419  DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
420  DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
421 
423  sample_text2 = g_strdup_printf("%s%s", sample_text, sample_text);
425  view, _("Security"), "security", NULL, sample_text2,
426  GNC_TREE_MODEL_PRICE_COL_COMMODITY,
427  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
428  sort_by_name);
429  g_free(sample_text2);
431  view, _("Currency"), "currency", NULL, sample_text,
432  GNC_TREE_MODEL_PRICE_COL_CURRENCY,
433  GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
434  sort_by_name);
435  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
437  view, _("Date"), "date", NULL, "2005-05-20",
438  GNC_TREE_MODEL_PRICE_COL_DATE,
439  GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
440  sort_by_date);
441  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
443  view, _("Source"), "source", NULL, "Finance::Quote",
444  GNC_TREE_MODEL_PRICE_COL_SOURCE,
445  GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
446  sort_by_source);
447  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
449  view, _("Type"), "type", NULL, "last",
450  GNC_TREE_MODEL_PRICE_COL_TYPE,
451  GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
452  sort_by_type);
453  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
455  view, _("Price"), "price", "100.00000",
456  GNC_TREE_MODEL_PRICE_COL_VALUE,
457  GNC_TREE_VIEW_COLUMN_COLOR_NONE,
458  GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
459  sort_by_value);
460  g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
461 
463 
464  /* Set properties */
465  va_start (var_args, first_property_name);
466  g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
467  va_end (var_args);
468 
469  /* Sort on the commodity column by default. This allows for a consistent
470  * sort if commodities are removed and re-added from the model. */
471  if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
472  NULL, NULL))
473  {
474  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
475  GNC_TREE_MODEL_PRICE_COL_COMMODITY,
476  GTK_SORT_ASCENDING);
477  }
478 
479  gtk_widget_show(GTK_WIDGET(view));
480  LEAVE(" %p", view);
481  return GTK_TREE_VIEW(view);
482 }
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *stock_icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
#define DEBUG(format, args...)
Definition: qoflog.h:255
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)
#define ENTER(format, args...)
Definition: qoflog.h:261
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Definition: gnc-pricedb.c:872
gnc_commodity * gnc_default_currency(void)
Definition: gnc-ui-util.c:939
void gnc_tree_view_configure_columns(GncTreeView *view)
const char * gnc_commodity_get_printname(const gnc_commodity *cm)
GtkTreeModel * gnc_tree_model_price_new(QofBook *book, GNCPriceDB *price_db)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 entitre 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 693 of file gnc-tree-view-price.c.

695 {
696  GtkTreeModel *model, *f_model, *s_model;
697  GtkTreePath *path, *f_path, *s_path, *parent_path;
698  GtkTreeSelection *selection;
699 
700  ENTER("view %p, price %p", view, price);
701 
702  /* Clear any existing selection. */
703  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
704  gtk_tree_selection_unselect_all (selection);
705 
706  if (price == NULL)
707  return;
708 
709  s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
710  f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
711  model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
712 
713  path = gnc_tree_model_price_get_path_from_price (GNC_TREE_MODEL_PRICE(model), price);
714  if (path == NULL)
715  {
716  LEAVE("get_path_from_price failed");
717  return;
718  }
719  debug_path(DEBUG, path);
720 
721  f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
722  path);
723  gtk_tree_path_free(path);
724  if (f_path == NULL)
725  {
726  LEAVE("no filter path");
727  return;
728  }
729  debug_path(DEBUG, f_path);
730 
731  s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
732  f_path);
733  gtk_tree_path_free(f_path);
734  if (s_path == NULL)
735  {
736  LEAVE("no sort path");
737  return;
738  }
739 
740  /* gtk_tree_view requires that a row be visible before it can be selected */
741  parent_path = gtk_tree_path_copy (s_path);
742  if (gtk_tree_path_up (parent_path))
743  {
744  /* This function is misnamed. It expands the actual item
745  * specified, not the path to the item specified. I.E. It expands
746  * one level too many, thus the get of the parent. */
747  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
748  }
749  gtk_tree_path_free(parent_path);
750 
751  gtk_tree_selection_select_path (selection, s_path);
752  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
753  debug_path(LEAVE, s_path);
754  gtk_tree_path_free(s_path);
755 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
#define ENTER(format, args...)
Definition: qoflog.h:261
GtkTreePath * gnc_tree_model_price_get_path_from_price(GncTreeModelPrice *model, GNCPrice *price)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 2011 of file gnc-tree-view-account.c.

2013 {
2014  g_return_if_fail(GTK_IS_BUTTON(button));
2015 
2016  ENTER("button %p", button);
2017  fd->visible_types = 0;
2018  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2019  gnc_tree_view_account_refilter(fd->tree_view);
2020  LEAVE("types 0x%x", fd->visible_types);
2021 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 2125 of file gnc-tree-view-account.c.

2128 {
2129  gpointer gptemp;
2130 
2131  g_return_if_fail(GTK_IS_DIALOG(dialog));
2132 
2133  ENTER("dialog %p, response %d", dialog, response);
2134 
2135  if (response != GTK_RESPONSE_OK)
2136  {
2137  fd->visible_types = fd->original_visible_types;
2138  fd->show_hidden = fd->original_show_hidden;
2139  fd->show_zero_total = fd->original_show_zero_total;
2140  fd->show_unused = fd->original_show_unused;
2141  gnc_tree_view_account_refilter(fd->tree_view);
2142  }
2143 
2144  /* Clean up and delete dialog */
2145  gptemp = (gpointer *)fd->dialog;
2146  g_atomic_pointer_compare_and_exchange(&gptemp,
2147  dialog, NULL);
2148  fd->dialog = gptemp;
2149  gtk_widget_destroy(dialog);
2150  LEAVE("types 0x%x", fd->visible_types);
2151 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 2030 of file gnc-tree-view-account.c.

2032 {
2033  g_return_if_fail(GTK_IS_BUTTON(button));
2034 
2035  ENTER("button %p", button);
2036  fd->visible_types = -1;
2037  gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2038  gnc_tree_view_account_refilter(fd->tree_view);
2039  LEAVE("types 0x%x", fd->visible_types);
2040 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 2050 of file gnc-tree-view-account.c.

2052 {
2053  ENTER("button %p", button);
2054  gppat_filter_select_all_cb(button, fd);
2055  LEAVE(" ");
2056 }
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1953 of file gnc-tree-view-account.c.

1955 {
1956  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1957 
1958  ENTER("button %p", button);
1959  fd->show_hidden = gtk_toggle_button_get_active(button);
1960  gnc_tree_view_account_refilter(fd->tree_view);
1961  LEAVE("show_hidden %d", fd->show_hidden);
1962 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1991 of file gnc-tree-view-account.c.

1993 {
1994  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1995 
1996  ENTER("button %p", button);
1997  fd->show_unused = gtk_toggle_button_get_active(button);
1998  gnc_tree_view_account_refilter(fd->tree_view);
1999  LEAVE("show_unused %d", fd->show_unused);
2000 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1972 of file gnc-tree-view-account.c.

1974 {
1975  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1976 
1977  ENTER("button %p", button);
1978  fd->show_zero_total = gtk_toggle_button_get_active(button);
1979  gnc_tree_view_account_refilter(fd->tree_view);
1980  LEAVE("show_zero %d", fd->show_zero_total);
1981 }
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1129 of file gnc-tree-view-owner.c.

1132 {
1133  gpointer gptemp;
1134 
1135  g_return_if_fail(GTK_IS_DIALOG(dialog));
1136 
1137  ENTER("dialog %p, response %d", dialog, response);
1138 
1139  if (response != GTK_RESPONSE_OK)
1140  {
1141  fd->show_inactive = fd->original_show_inactive;
1142  fd->show_zero_total = fd->original_show_zero_total;
1143  gnc_tree_view_owner_refilter(fd->tree_view);
1144  }
1145 
1146  /* Clean up and delete dialog */
1147  gptemp = (gpointer *)fd->dialog;
1148  g_atomic_pointer_compare_and_exchange(&gptemp,
1149  dialog, NULL);
1150  fd->dialog = gptemp;
1151  gtk_widget_destroy(dialog);
1152  LEAVE("");
1153 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1090 of file gnc-tree-view-owner.c.

1092 {
1093  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1094 
1095  ENTER("button %p", button);
1096  fd->show_inactive = !gtk_toggle_button_get_active(button);
1097  gnc_tree_view_owner_refilter(fd->tree_view);
1098  LEAVE("show_inactive %d", fd->show_inactive);
1099 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 1108 of file gnc-tree-view-owner.c.

1110 {
1111  g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
1112 
1113  ENTER("button %p", button);
1114  fd->show_zero_total = gtk_toggle_button_get_active(button);
1115  gnc_tree_view_owner_refilter(fd->tree_view);
1116  LEAVE("show_zero %d", fd->show_zero_total);
1117 }
void gnc_tree_view_owner_refilter(GncTreeViewOwner *view)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271