GnuCash 7574033+
Loading...
Searching...
No Matches
Budgets

Files

file  gnc-budget.h
 GnuCash Budgets.
file  gnc-tree-model-budget.h
 provides some utilities for working with the list of budgets in a book.
file  gnc-budget-view.c
 File to define budget views for gnucash (the actual display of the budget, along with some calculations and event handlers).
file  gnc-budget-view.h
file  gnc-plugin-page-budget.h

Data Structures

struct  GncBudgetView
struct  GncBudgetViewClass
struct  GncBudgetViewPrivate
 the private budget view structure More...
struct  BudgetAccumulationInfo
 Action for when a selection in a gnc budget view is changed. More...
struct  GncPluginPageBudget
struct  GncPluginPageBudgetClass

Macros

#define GNC_TYPE_BUDGET   (gnc_budget_get_type ())
#define GNC_BUDGET(o)
#define GNC_BUDGET_CLASS(k)
#define GNC_IS_BUDGET(o)
#define GNC_IS_BUDGET_CLASS(k)
#define GNC_BUDGET_GET_CLASS(o)
#define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS   3
#define GNC_BUDGET_NOTES_PATH   "notes"
#define gnc_budget_return_guid(X)
#define gnc_budget_lookup_direct(g, b)
#define PLUGIN_PAGE_BUDGET_CM_CLASS   "budget-view"
#define STATE_SECTION_PREFIX   "Budget"
#define GNC_BUDGET_VIEW_GET_PRIVATE(o)
#define BUDGET_GUID   "Budget GncGUID"
#define GNC_TYPE_BUDGET_VIEW   (gnc_budget_view_get_type ())
#define GNC_BUDGET_VIEW(obj)
#define GNC_BUDGET_VIEW_CLASS(klass)
#define GNC_IS_BUDGET_VIEW(obj)
#define GNC_IS_BUDGET_VIEW_CLASS(klass)
#define GNC_BUDGET_VIEW_GET_CLASS(obj)
#define GNC_BUDGET_VIEW_NAME   "GncBudgetView"
#define GNC_TYPE_PLUGIN_PAGE_BUDGET   (gnc_plugin_page_budget_get_type ())
#define GNC_PLUGIN_PAGE_BUDGET(obj)
#define GNC_PLUGIN_PAGE_BUDGET_CLASS(klass)
#define GNC_IS_PLUGIN_PAGE_BUDGET(obj)
#define GNC_IS_PLUGIN_PAGE_BUDGET_CLASS(klass)
#define GNC_PLUGIN_PAGE_BUDGET_GET_CLASS(obj)
#define GNC_PLUGIN_PAGE_BUDGET_NAME   "GncPluginPageBudget"

Enumerations

enum  { BUDGET_GUID_COLUMN , BUDGET_NAME_COLUMN , BUDGET_DESCRIPTION_COLUMN , BUDGET_LIST_NUM_COLS }
enum  { TOTALS_TYPE_INCOME , TOTALS_TYPE_EXPENSES , TOTALS_TYPE_ASSET_LIAB_EQ , TOTALS_TYPE_REMAINDER }

Functions

GType gnc_budget_get_type (void)
gboolean gnc_budget_register (void)
GncBudget * gnc_budget_new (QofBook *book)
 Creates and initializes a Budget.
void gnc_budget_destroy (GncBudget *budget)
 Deletes the given budget object.
void gnc_budget_begin_edit (GncBudget *bgt)
void gnc_budget_commit_edit (GncBudget *bgt)
GncBudget * gnc_budget_clone (const GncBudget *budget)
 Clones a budget creating a copy.
const GncGUID * gnc_budget_get_guid (const GncBudget *budget)
void gnc_budget_set_name (GncBudget *budget, const gchar *name)
 Set/Get the name of the Budget.
const gchar * gnc_budget_get_name (const GncBudget *budget)
void gnc_budget_set_description (GncBudget *budget, const gchar *description)
 Set/Get the description of the Budget.
const gchar * gnc_budget_get_description (const GncBudget *budget)
void gnc_budget_set_num_periods (GncBudget *budget, guint num_periods)
 Set/Get the number of periods in the Budget.
guint gnc_budget_get_num_periods (const GncBudget *budget)
void gnc_budget_set_recurrence (GncBudget *budget, const Recurrence *r)
const Recurrence * gnc_budget_get_recurrence (const GncBudget *budget)
time64 gnc_budget_get_period_start_date (const GncBudget *budget, guint period_num)
 Get the starting date of the Budget period.
time64 gnc_budget_get_period_end_date (const GncBudget *budget, guint period_num)
 Get the ending date of the Budget period.
void gnc_budget_set_account_period_value (GncBudget *budget, const Account *account, guint period_num, gnc_numeric val)
void gnc_budget_unset_account_period_value (GncBudget *budget, const Account *account, guint period_num)
gboolean gnc_budget_is_account_period_value_set (const GncBudget *budget, const Account *account, guint period_num)
gnc_numeric gnc_budget_get_account_period_value (const GncBudget *budget, const Account *account, guint period_num)
gnc_numeric gnc_budget_get_account_period_actual_value (const GncBudget *budget, Account *account, guint period_num)
void gnc_budget_set_account_period_note (GncBudget *budget, const Account *account, guint period_num, const gchar *note)
const gchar * gnc_budget_get_account_period_note (const GncBudget *budget, const Account *account, guint period_num)
GncBudget * gnc_budget_get_default (QofBook *book)
GncBudget * gnc_budget_lookup (const GncGUID *guid, const QofBook *book)
GtkTreeModel * gnc_tree_model_budget_new (QofBook *book)
void gnc_tree_view_budget_set_model (GtkTreeView *tv, GtkTreeModel *tm)
GncBudget * gnc_tree_model_budget_get_budget (GtkTreeModel *tm, GtkTreeIter *iter)
gboolean gnc_tree_model_budget_get_iter_for_budget (GtkTreeModel *tm, GtkTreeIter *iter, GncBudget *bgt)
GncBudgetView * gnc_budget_view_new (GncBudget *budget, AccountFilterDialog *fd)
 Create new gnc budget view.
void gnc_budget_view_set_show_account_code (GncBudgetView *budget_view, gboolean show_account_code)
gboolean gnc_budget_view_get_show_account_code (GncBudgetView *budget_view)
void gnc_budget_view_set_show_account_description (GncBudgetView *budget_view, gboolean show_account_desc)
gboolean gnc_budget_view_get_show_account_description (GncBudgetView *budget_view)
GtkTreeSelection * gnc_budget_view_get_selection (GncBudgetView *budget_view)
 returns the current selection in the gnc budget view.
Account * gnc_budget_view_get_account_from_path (GncBudgetView *budget_view, GtkTreePath *path)
GtkWidget * gnc_budget_view_get_account_tree_view (GncBudgetView *budget_view)
GList * gnc_budget_view_get_selected_accounts (GncBudgetView *budget_view)
void gnc_budget_view_save (GncBudgetView *budget_view, GKeyFile *key_file, const gchar *group_name)
gboolean gnc_budget_view_restore (GncBudgetView *budget_view, GKeyFile *key_file, const gchar *group_name)
void gnc_budget_view_delete_budget (GncBudgetView *budget_view)
void gnc_budget_view_save_account_filter (GncBudgetView *budget_view)
void gnc_budget_view_refresh (GncBudgetView *budget_view)
 refreshes the current budget view
GType gnc_budget_view_get_type (void)
GType gnc_plugin_page_budget_get_type (void)
GncPluginPage * gnc_plugin_page_budget_new (GncBudget *budget)
 Create a new "budget" plugin page.
void gnc_budget_gui_delete_budget (GncBudget *budget)

Variables

GtkBox GncBudgetView::w
GtkBoxClass GncBudgetViewClass::w
GtkTreeView * GncBudgetViewPrivate::tree_view
GtkTreeView * GncBudgetViewPrivate::totals_tree_view
GtkWidget * GncBudgetViewPrivate::totals_scroll_window
GtkAdjustment * GncBudgetViewPrivate::hadj
GncBudget * GncBudgetViewPrivate::budget
GncGUID GncBudgetViewPrivate::key
gboolean GncBudgetViewPrivate::use_red_color
GList * GncBudgetViewPrivate::period_col_list
GList * GncBudgetViewPrivate::totals_col_list
GtkTreeViewColumn * GncBudgetViewPrivate::total_col
AccountFilterDialog * GncBudgetViewPrivate::fd
Account * GncBudgetViewPrivate::rootAcct
gboolean GncBudgetViewPrivate::show_account_code
gboolean GncBudgetViewPrivate::show_account_desc
GtkCellRenderer * GncBudgetViewPrivate::temp_cr
GtkCellEditable * GncBudgetViewPrivate::temp_ce
gnc_numeric BudgetAccumulationInfo::total
GncBudget * BudgetAccumulationInfo::budget
guint BudgetAccumulationInfo::period_num
GNCPriceDB * BudgetAccumulationInfo::pdb
gnc_commodity * BudgetAccumulationInfo::total_currency

Detailed Description

gnc-budget_view.c – Budget display widget

Macro Definition Documentation

◆ BUDGET_GUID

#define BUDGET_GUID   "Budget GncGUID"

Definition at line 586 of file gnc-budget-view.c.

◆ GNC_BUDGET

#define GNC_BUDGET ( o)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))

Definition at line 84 of file gnc-budget.h.

84#define GNC_BUDGET(o) \
85 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))

◆ GNC_BUDGET_CLASS

#define GNC_BUDGET_CLASS ( k)
Value:
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))

Definition at line 86 of file gnc-budget.h.

86#define GNC_BUDGET_CLASS(k) \
87 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))

◆ GNC_BUDGET_GET_CLASS

#define GNC_BUDGET_GET_CLASS ( o)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))

Definition at line 92 of file gnc-budget.h.

92#define GNC_BUDGET_GET_CLASS(o) \
93 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))

◆ gnc_budget_lookup_direct

#define gnc_budget_lookup_direct ( g,
b )
Value:
gnc_budget_lookup(&(g),(b))

Definition at line 176 of file gnc-budget.h.

◆ GNC_BUDGET_MAX_NUM_PERIODS_DIGITS

#define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS   3

Definition at line 96 of file gnc-budget.h.

◆ GNC_BUDGET_NOTES_PATH

#define GNC_BUDGET_NOTES_PATH   "notes"

Definition at line 98 of file gnc-budget.h.

◆ gnc_budget_return_guid

#define gnc_budget_return_guid ( X)
Value:
(X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition guid.cpp:165
const GncGUID * qof_entity_get_guid(gconstpointer ent)

Definition at line 119 of file gnc-budget.h.

119#define gnc_budget_return_guid(X) \
120 (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))

◆ GNC_BUDGET_VIEW

#define GNC_BUDGET_VIEW ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetView))

Definition at line 44 of file gnc-budget-view.h.

◆ GNC_BUDGET_VIEW_CLASS

#define GNC_BUDGET_VIEW_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))

Definition at line 45 of file gnc-budget-view.h.

◆ GNC_BUDGET_VIEW_GET_CLASS

#define GNC_BUDGET_VIEW_GET_CLASS ( obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))

Definition at line 48 of file gnc-budget-view.h.

◆ GNC_BUDGET_VIEW_GET_PRIVATE

#define GNC_BUDGET_VIEW_GET_PRIVATE ( o)
Value:
((GncBudgetViewPrivate*)gnc_budget_view_get_instance_private((GncBudgetView*)o))
the private budget view structure

Definition at line 180 of file gnc-budget-view.c.

180#define GNC_BUDGET_VIEW_GET_PRIVATE(o) \
181 ((GncBudgetViewPrivate*)gnc_budget_view_get_instance_private((GncBudgetView*)o))

◆ GNC_BUDGET_VIEW_NAME

#define GNC_BUDGET_VIEW_NAME   "GncBudgetView"

Definition at line 50 of file gnc-budget-view.h.

◆ GNC_IS_BUDGET

#define GNC_IS_BUDGET ( o)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))

Definition at line 88 of file gnc-budget.h.

88#define GNC_IS_BUDGET(o) \
89 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))

◆ GNC_IS_BUDGET_CLASS

#define GNC_IS_BUDGET_CLASS ( k)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))

Definition at line 90 of file gnc-budget.h.

90#define GNC_IS_BUDGET_CLASS(k) \
91 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))

◆ GNC_IS_BUDGET_VIEW

#define GNC_IS_BUDGET_VIEW ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_BUDGET_VIEW))

Definition at line 46 of file gnc-budget-view.h.

◆ GNC_IS_BUDGET_VIEW_CLASS

#define GNC_IS_BUDGET_VIEW_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_BUDGET_VIEW))

Definition at line 47 of file gnc-budget-view.h.

◆ GNC_IS_PLUGIN_PAGE_BUDGET

#define GNC_IS_PLUGIN_PAGE_BUDGET ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET))

Definition at line 44 of file gnc-plugin-page-budget.h.

◆ GNC_IS_PLUGIN_PAGE_BUDGET_CLASS

#define GNC_IS_PLUGIN_PAGE_BUDGET_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET))

Definition at line 45 of file gnc-plugin-page-budget.h.

◆ GNC_PLUGIN_PAGE_BUDGET

#define GNC_PLUGIN_PAGE_BUDGET ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudget))

Definition at line 42 of file gnc-plugin-page-budget.h.

◆ GNC_PLUGIN_PAGE_BUDGET_CLASS

#define GNC_PLUGIN_PAGE_BUDGET_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))

Definition at line 43 of file gnc-plugin-page-budget.h.

◆ GNC_PLUGIN_PAGE_BUDGET_GET_CLASS

#define GNC_PLUGIN_PAGE_BUDGET_GET_CLASS ( obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))

Definition at line 46 of file gnc-plugin-page-budget.h.

◆ GNC_PLUGIN_PAGE_BUDGET_NAME

#define GNC_PLUGIN_PAGE_BUDGET_NAME   "GncPluginPageBudget"

Definition at line 48 of file gnc-plugin-page-budget.h.

◆ GNC_TYPE_BUDGET

#define GNC_TYPE_BUDGET   (gnc_budget_get_type ())

Definition at line 83 of file gnc-budget.h.

◆ GNC_TYPE_BUDGET_VIEW

#define GNC_TYPE_BUDGET_VIEW   (gnc_budget_view_get_type ())

Definition at line 43 of file gnc-budget-view.h.

◆ GNC_TYPE_PLUGIN_PAGE_BUDGET

#define GNC_TYPE_PLUGIN_PAGE_BUDGET   (gnc_plugin_page_budget_get_type ())

Definition at line 41 of file gnc-plugin-page-budget.h.

◆ PLUGIN_PAGE_BUDGET_CM_CLASS

#define PLUGIN_PAGE_BUDGET_CM_CLASS   "budget-view"

Definition at line 82 of file gnc-budget-view.c.

◆ STATE_SECTION_PREFIX

#define STATE_SECTION_PREFIX   "Budget"

Definition at line 83 of file gnc-budget-view.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Todo
This file is poorly named, since it covers both model and view.

Definition at line 42 of file gnc-tree-model-budget.h.

43{
44 BUDGET_GUID_COLUMN,
45 BUDGET_NAME_COLUMN,
46 BUDGET_DESCRIPTION_COLUMN,
47 BUDGET_LIST_NUM_COLS
48};

◆ anonymous enum

anonymous enum
Enumerator
TOTALS_TYPE_INCOME 

This total is Income type.

TOTALS_TYPE_EXPENSES 

This total is Expenses type.

TOTALS_TYPE_ASSET_LIAB_EQ 

This total is Asset/Liab/Equity type.

TOTALS_TYPE_REMAINDER 

This total is Remaining to Budget.

Definition at line 97 of file gnc-budget-view.c.

98{
103};
@ TOTALS_TYPE_REMAINDER
This total is Remaining to Budget.
@ TOTALS_TYPE_ASSET_LIAB_EQ
This total is Asset/Liab/Equity type.
@ TOTALS_TYPE_EXPENSES
This total is Expenses type.
@ TOTALS_TYPE_INCOME
This total is Income type.

Function Documentation

◆ gnc_budget_begin_edit()

void gnc_budget_begin_edit ( GncBudget * bgt)

Definition at line 291 of file gnc-budget.cpp.

292{
293 qof_begin_edit(QOF_INSTANCE(bgt));
294}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ gnc_budget_clone()

GncBudget * gnc_budget_clone ( const GncBudget * budget)

Clones a budget creating a copy.

Definition at line 355 of file gnc-budget.cpp.

356{
357 GncBudget* new_b;
358 Account* root;
359 CloneBudgetData_t clone_data;
360
361 g_return_val_if_fail(old_b != nullptr, nullptr);
362
363 ENTER(" ");
364
366 gnc_budget_begin_edit(new_b);
367 gnc_budget_set_name(new_b, gnc_budget_get_name(old_b));
368 gnc_budget_set_description(new_b, gnc_budget_get_description(old_b));
369 gnc_budget_set_recurrence(new_b, gnc_budget_get_recurrence(old_b));
370 gnc_budget_set_num_periods(new_b, gnc_budget_get_num_periods(old_b));
371
372 root = gnc_book_get_root_account(qof_instance_get_book(old_b));
373 clone_data.old_b = old_b;
374 clone_data.new_b = new_b;
375 clone_data.num_periods = gnc_budget_get_num_periods(new_b);
376 gnc_account_foreach_descendant(root, clone_budget_values_cb, &clone_data);
377
378 gnc_budget_commit_edit(new_b);
379
380 LEAVE(" ");
381
382 return new_b;
383}
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
Set/Get the number of periods in the Budget.
GncBudget * gnc_budget_new(QofBook *book)
Creates and initializes a Budget.
void gnc_budget_set_description(GncBudget *budget, const gchar *description)
Set/Get the description of the Budget.
void gnc_budget_set_name(GncBudget *budget, const gchar *name)
Set/Get the name of the Budget.
STRUCTS.
Data structure for containing info while cloning budget values.

◆ gnc_budget_commit_edit()

void gnc_budget_commit_edit ( GncBudget * bgt)

Definition at line 297 of file gnc-budget.cpp.

298{
299 if (!qof_commit_edit(QOF_INSTANCE(bgt))) return;
300 qof_commit_edit_part2(QOF_INSTANCE(bgt), commit_err,
301 noop, gnc_budget_free);
302}
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ gnc_budget_destroy()

void gnc_budget_destroy ( GncBudget * budget)

Deletes the given budget object.

Definition at line 321 of file gnc-budget.cpp.

322{
323 g_return_if_fail(GNC_IS_BUDGET(budget));
324 gnc_budget_begin_edit(budget);
325 qof_instance_set_dirty(&budget->inst);
326 qof_instance_set_destroying(budget, TRUE);
327 gnc_budget_commit_edit(budget);
328}

◆ gnc_budget_get_account_period_actual_value()

gnc_numeric gnc_budget_get_account_period_actual_value ( const GncBudget * budget,
Account * account,
guint period_num )

Definition at line 662 of file gnc-budget.cpp.

664{
665 // FIXME: maybe zero is not best error return val.
666 g_return_val_if_fail(GNC_IS_BUDGET(budget) && acc, gnc_numeric_zero());
667 return recurrenceGetAccountPeriodValue(&GET_PRIVATE(budget)->recurrence,
668 acc, period_num);
669}

◆ gnc_budget_get_account_period_note()

const gchar * gnc_budget_get_account_period_note ( const GncBudget * budget,
const Account * account,
guint period_num )

Definition at line 639 of file gnc-budget.cpp.

641{
642 g_return_val_if_fail (period_num < GET_PRIVATE(budget)->num_periods, nullptr);
643 auto& data = get_perioddata (budget, account, period_num);
644 return data.note.empty () ? nullptr : data.note.c_str();
645}

◆ gnc_budget_get_account_period_value()

gnc_numeric gnc_budget_get_account_period_value ( const GncBudget * budget,
const Account * account,
guint period_num )

Definition at line 588 of file gnc-budget.cpp.

591{
592 g_return_val_if_fail (period_num < GET_PRIVATE(budget)->num_periods,
593 gnc_numeric_zero());
594 auto& data = get_perioddata (budget, account, period_num);
595
596 return data.opt_value.has_value() ? data.opt_value.value() : gnc_numeric_zero();
597}

◆ gnc_budget_get_default()

GncBudget * gnc_budget_get_default ( QofBook * book)

Definition at line 721 of file gnc-budget.cpp.

722{
723 QofCollection *col;
724 GncBudget *bgt = nullptr;
725 GncGUID *default_budget_guid = nullptr;
726
727 g_return_val_if_fail(book, nullptr);
728
729 qof_instance_get (QOF_INSTANCE (book),
730 "default-budget", &default_budget_guid,
731 nullptr);
732 if (default_budget_guid)
733 {
734 col = qof_book_get_collection(book, GNC_ID_BUDGET);
735 bgt = (GncBudget *) qof_collection_lookup_entity(col,
736 default_budget_guid);
737 }
738
739 /* Revert to 2.2.x behavior if the book has no default budget. */
740
741 if ( bgt == nullptr )
742 {
743 col = qof_book_get_collection(book, GNC_ID_BUDGET);
744 if (qof_collection_count(col) > 0)
745 {
746 qof_collection_foreach(col, just_get_one, &bgt);
747 }
748 }
749
750 guid_free (default_budget_guid);
751 return bgt;
752}
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition qofbook.cpp:521
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
Definition qofid.cpp:209
guint qof_collection_count(const QofCollection *col)
return the number of entities in the collection.
Definition qofid.cpp:221
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
The type used to store guids in C.
Definition guid.h:75

◆ gnc_budget_get_description()

const gchar * gnc_budget_get_description ( const GncBudget * budget)

Definition at line 429 of file gnc-budget.cpp.

430{
431 g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
432 return GET_PRIVATE(budget)->description;
433}

◆ gnc_budget_get_guid()

const GncGUID * gnc_budget_get_guid ( const GncBudget * budget)

Definition at line 459 of file gnc-budget.cpp.

460{
461 g_return_val_if_fail(budget, nullptr);
462 g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
463 return qof_instance_get_guid(QOF_INSTANCE(budget));
464}
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.

◆ gnc_budget_get_name()

const gchar * gnc_budget_get_name ( const GncBudget * budget)

Definition at line 404 of file gnc-budget.cpp.

405{
406 g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
407 return GET_PRIVATE(budget)->name;
408}

◆ gnc_budget_get_num_periods()

guint gnc_budget_get_num_periods ( const GncBudget * budget)

Definition at line 488 of file gnc-budget.cpp.

489{
490 g_return_val_if_fail(GNC_IS_BUDGET(budget), 0);
491 return GET_PRIVATE(budget)->num_periods;
492}

◆ gnc_budget_get_period_end_date()

time64 gnc_budget_get_period_end_date ( const GncBudget * budget,
guint period_num )

Get the ending date of the Budget period.

Definition at line 655 of file gnc-budget.cpp.

656{
657 g_return_val_if_fail (GNC_IS_BUDGET(budget), 0);
658 return recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, TRUE);
659}

◆ gnc_budget_get_period_start_date()

time64 gnc_budget_get_period_start_date ( const GncBudget * budget,
guint period_num )

Get the starting date of the Budget period.

Definition at line 648 of file gnc-budget.cpp.

649{
650 g_return_val_if_fail (GNC_IS_BUDGET(budget), 0);
651 return recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, FALSE);
652}

◆ gnc_budget_get_recurrence()

const Recurrence * gnc_budget_get_recurrence ( const GncBudget * budget)

Definition at line 452 of file gnc-budget.cpp.

453{
454 g_return_val_if_fail(budget, nullptr);
455 return (&GET_PRIVATE(budget)->recurrence);
456}

◆ gnc_budget_gui_delete_budget()

void gnc_budget_gui_delete_budget ( GncBudget * budget)

Definition at line 928 of file gnc-plugin-page-budget.cpp.

929{
930 const char *name;
931
932 g_return_if_fail (GNC_IS_BUDGET(budget));
933 name = gnc_budget_get_name (budget);
934 if (!name)
935 name = _("Unnamed Budget");
936
937 if (gnc_verify_dialog (NULL, FALSE, _("Delete %s?"), name))
938 {
939 QofBook* book = gnc_get_current_book ();
940
941 gnc_suspend_gui_refresh ();
942 gnc_budget_destroy (budget);
943
944 if (qof_collection_count (qof_book_get_collection (book, GNC_ID_BUDGET)) == 0)
945 {
946 gnc_features_set_unused (book, GNC_FEATURE_BUDGET_UNREVERSED);
947 PWARN ("No budgets left. Removing feature BUDGET_UNREVERSED.");
948 }
949 // Views should close themselves because the CM will notify them.
950 gnc_resume_gui_refresh ();
951 }
952}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
void gnc_features_set_unused(QofBook *book, const gchar *feature)
Indicate that the current book does not use the given feature.
void gnc_budget_destroy(GncBudget *budget)
Deletes the given budget object.
QofBook reference.
Definition qofbook-p.hpp:47

◆ gnc_budget_is_account_period_value_set()

gboolean gnc_budget_is_account_period_value_set ( const GncBudget * budget,
const Account * account,
guint period_num )

Definition at line 579 of file gnc-budget.cpp.

582{
583 g_return_val_if_fail (period_num < GET_PRIVATE(budget)->num_periods, false);
584 return get_perioddata (budget, account, period_num).opt_value.has_value();
585}

◆ gnc_budget_lookup()

GncBudget * gnc_budget_lookup ( const GncGUID * guid,
const QofBook * book )

Definition at line 704 of file gnc-budget.cpp.

705{
706 QofCollection *col;
707
708 g_return_val_if_fail(guid, nullptr);
709 g_return_val_if_fail(book, nullptr);
710 col = qof_book_get_collection (book, GNC_ID_BUDGET);
711 return GNC_BUDGET(qof_collection_lookup_entity (col, guid));
712}

◆ gnc_budget_new()

GncBudget * gnc_budget_new ( QofBook * book)

Creates and initializes a Budget.

Definition at line 305 of file gnc-budget.cpp.

306{
307 g_return_val_if_fail(book, nullptr);
308
309 ENTER(" ");
310
311 auto budget { static_cast<GncBudget*>(g_object_new(GNC_TYPE_BUDGET, nullptr)) };
312 qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book);
313
314 qof_event_gen( &budget->inst, QOF_EVENT_CREATE , nullptr);
315
316 LEAVE(" ");
317 return budget;
318}
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.

◆ gnc_budget_register()

gboolean gnc_budget_register ( void )

Definition at line 815 of file gnc-budget.cpp.

816{
817 static QofParam params[] =
818 {
819 {
820 "name", QOF_TYPE_STRING,
821 (QofAccessFunc) gnc_budget_get_name,
823 },
824 {
825 "description", QOF_TYPE_STRING,
826 (QofAccessFunc) gnc_budget_get_description,
828 },
829 {
830 "recurrence_period_type", QOF_TYPE_INT32,
831 (QofAccessFunc) gnc_budget_get_rec_pt, nullptr
832 },
833 /* Signedness problem: Should be unsigned. */
834 {
835 "recurrence_multiplier", QOF_TYPE_INT32,
836 (QofAccessFunc) gnc_budget_get_rec_mult, nullptr
837 },
838 /* This is the same way that SchedXaction.c uses QOF_TYPE_DATE
839 but I don't think QOF actually supports a GDate, so I think
840 this is wrong. */
841 {
842 "recurrence_date", QOF_TYPE_DATE,
843 (QofAccessFunc) gnc_budget_get_rec_time, nullptr
844 },
845 /* Signedness problem: Should be unsigned. */
846 {
847 "num_periods", QOF_TYPE_INT32,
848 (QofAccessFunc) gnc_budget_get_num_periods,
850 },
851 {
852 QOF_PARAM_BOOK, QOF_ID_BOOK,
854 },
855 {
856 QOF_PARAM_GUID, QOF_TYPE_GUID,
858 },
859 { nullptr },
860 };
861
862 qof_class_register(GNC_ID_BUDGET, (QofSortFunc) nullptr, params);
863 return qof_object_register(&budget_object_def);
864}
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Definition qofclass.h:124
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
Definition qofclass.h:131
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
Definition qofclass.cpp:86
int(* QofSortFunc)(gconstpointer, gconstpointer)
This function is the default sort function for a particular object type.
Definition qofclass.h:169
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
#define QOF_PARAM_BOOK
"Known" Object Parameters – all objects must support these
Definition qofquery.h:108

◆ gnc_budget_set_account_period_note()

void gnc_budget_set_account_period_note ( GncBudget * budget,
const Account * account,
guint period_num,
const gchar * note )

Definition at line 600 of file gnc-budget.cpp.

602{
603 g_return_if_fail (budget != nullptr);
604 g_return_if_fail (account != nullptr);
605
606 /* Watch out for an off-by-one error here:
607 * period_num starts from 0 while num_periods starts from 1 */
608 if (period_num >= GET_PRIVATE(budget)->num_periods)
609 {
610 PWARN("Period %i does not exist", period_num);
611 return;
612 }
613
614 auto& perioddata = get_perioddata (budget, account, period_num);
615 auto budget_kvp { QOF_INSTANCE (budget)->kvp_data };
616 auto path = make_period_note_path (account, period_num);
617
618 gnc_budget_begin_edit(budget);
619 if (note == nullptr)
620 {
621 delete budget_kvp->set_path (path, nullptr);
622 perioddata.note.clear ();
623 }
624 else
625 {
626 KvpValue* v = new KvpValue (g_strdup (note));
627
628 delete budget_kvp->set_path (path, v);
629 perioddata.note = note;
630 }
631 qof_instance_set_dirty(&budget->inst);
632 gnc_budget_commit_edit(budget);
633
634 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
635
636}

◆ gnc_budget_set_account_period_value()

void gnc_budget_set_account_period_value ( GncBudget * budget,
const Account * account,
guint period_num,
gnc_numeric val )

Definition at line 541 of file gnc-budget.cpp.

543{
544 g_return_if_fail (budget != nullptr);
545 g_return_if_fail (account != nullptr);
546
547 /* Watch out for an off-by-one error here:
548 * period_num starts from 0 while num_periods starts from 1 */
549 if (period_num >= GET_PRIVATE(budget)->num_periods)
550 {
551 PWARN("Period %i does not exist", period_num);
552 return;
553 }
554
555 auto& perioddata = get_perioddata (budget, account, period_num);
556 auto budget_kvp { QOF_INSTANCE (budget)->kvp_data };
557 auto path = make_period_data_path (account, period_num);
558
559 gnc_budget_begin_edit(budget);
560 if (gnc_numeric_check(val))
561 {
562 delete budget_kvp->set_path (path, nullptr);
563 perioddata.opt_value.reset();
564 }
565 else
566 {
567 KvpValue* v = new KvpValue (val);
568 delete budget_kvp->set_path (path, v);
569 perioddata.opt_value = val;
570 }
571 qof_instance_set_dirty(&budget->inst);
572 gnc_budget_commit_edit(budget);
573
574 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
575
576}
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.

◆ gnc_budget_set_description()

void gnc_budget_set_description ( GncBudget * budget,
const gchar * description )

Set/Get the description of the Budget.

Definition at line 411 of file gnc-budget.cpp.

412{
413 GncBudgetPrivate* priv;
414
415 g_return_if_fail(GNC_IS_BUDGET(budget));
416 g_return_if_fail(description);
417
418 priv = GET_PRIVATE(budget);
419 if ( description == priv->description ) return;
420 gnc_budget_begin_edit(budget);
421 CACHE_REPLACE(priv->description, description);
422 qof_instance_set_dirty(&budget->inst);
423 gnc_budget_commit_edit(budget);
424
425 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
426}

◆ gnc_budget_set_name()

void gnc_budget_set_name ( GncBudget * budget,
const gchar * name )

Set/Get the name of the Budget.

Definition at line 386 of file gnc-budget.cpp.

387{
388 GncBudgetPrivate* priv;
389
390 g_return_if_fail(GNC_IS_BUDGET(budget) && name);
391
392 priv = GET_PRIVATE(budget);
393 if ( name == priv->name ) return;
394
395 gnc_budget_begin_edit(budget);
396 CACHE_REPLACE(priv->name, name);
397 qof_instance_set_dirty(&budget->inst);
398 gnc_budget_commit_edit(budget);
399
400 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
401}

◆ gnc_budget_set_num_periods()

void gnc_budget_set_num_periods ( GncBudget * budget,
guint num_periods )

Set/Get the number of periods in the Budget.

Definition at line 467 of file gnc-budget.cpp.

468{
469 GncBudgetPrivate* priv;
470
471 g_return_if_fail(GNC_IS_BUDGET(budget));
472 g_return_if_fail(num_periods > 0);
473
474 priv = GET_PRIVATE(budget);
475 if ( priv->num_periods == num_periods ) return;
476
477 gnc_budget_begin_edit(budget);
478 priv->num_periods = num_periods;
479 std::for_each (priv->acct_map.begin(), priv->acct_map.end(),
480 [num_periods](auto& it){ it.second.resize(num_periods); });
481 qof_instance_set_dirty(&budget->inst);
482 gnc_budget_commit_edit(budget);
483
484 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
485}

◆ gnc_budget_set_recurrence()

void gnc_budget_set_recurrence ( GncBudget * budget,
const Recurrence * r )

Definition at line 436 of file gnc-budget.cpp.

437{
438 GncBudgetPrivate* priv;
439
440 g_return_if_fail(budget && r);
441 priv = GET_PRIVATE(budget);
442
443 gnc_budget_begin_edit(budget);
444 priv->recurrence = *r;
445 qof_instance_set_dirty(&budget->inst);
446 gnc_budget_commit_edit(budget);
447
448 qof_event_gen(&budget->inst, QOF_EVENT_MODIFY, nullptr);
449}

◆ gnc_budget_unset_account_period_value()

void gnc_budget_unset_account_period_value ( GncBudget * budget,
const Account * account,
guint period_num )

Definition at line 517 of file gnc-budget.cpp.

519{
520 g_return_if_fail (budget != nullptr);
521 g_return_if_fail (account != nullptr);
522 g_return_if_fail (period_num < GET_PRIVATE(budget)->num_periods);
523
524 auto& data = get_perioddata (budget, account, period_num);
525 data.opt_value.reset();
526
527 gnc_budget_begin_edit(budget);
528 auto path = make_period_data_path (account, period_num);
529 auto budget_kvp { QOF_INSTANCE (budget)->kvp_data };
530 delete budget_kvp->set_path (path, nullptr);
531 qof_instance_set_dirty(&budget->inst);
532 gnc_budget_commit_edit(budget);
533
534 qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
535
536}

◆ gnc_budget_view_delete_budget()

void gnc_budget_view_delete_budget ( GncBudgetView * budget_view)

Definition at line 691 of file gnc-budget-view.c.

692{
694 gchar guidstr[GUID_ENCODING_LENGTH+1];
695
696 g_return_if_fail (budget_view != NULL);
697
698 ENTER("view %p", budget_view);
699
700 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
701
702 guid_to_string_buff (&priv->key, guidstr);
704 g_object_set (G_OBJECT(priv->tree_view), "state-section", NULL, NULL);
705
706 LEAVE(" ");
707}
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition guid.h:84
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Definition guid.cpp:208
gint gnc_state_drop_sections_for(const gchar *partial_name)
Drop all sections from the state file whose name contains partial_name.
Definition gnc-state.c:260

◆ gnc_budget_view_get_account_from_path()

Account * gnc_budget_view_get_account_from_path ( GncBudgetView * budget_view,
GtkTreePath * path )

Definition at line 329 of file gnc-budget-view.c.

330{
332
333 g_return_val_if_fail (GNC_IS_BUDGET_VIEW(budget_view), NULL);
334
335 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
336 return gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), path);
337}
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
This function returns the account associated with the specified path.

◆ gnc_budget_view_get_account_tree_view()

GtkWidget * gnc_budget_view_get_account_tree_view ( GncBudgetView * budget_view)

Definition at line 340 of file gnc-budget-view.c.

341{
343
344 g_return_val_if_fail (GNC_IS_BUDGET_VIEW(budget_view), NULL);
345
346 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
347 return GTK_WIDGET(priv->fd->tree_view);
348}

◆ gnc_budget_view_get_selected_accounts()

GList * gnc_budget_view_get_selected_accounts ( GncBudgetView * budget_view)

Definition at line 351 of file gnc-budget-view.c.

352{
354
355 g_return_val_if_fail (GNC_IS_BUDGET_VIEW(budget_view), NULL);
356
357 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
358 return gnc_tree_view_account_get_selected_accounts (GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
359}
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 v...

◆ gnc_budget_view_get_selection()

GtkTreeSelection * gnc_budget_view_get_selection ( GncBudgetView * budget_view)

returns the current selection in the gnc budget view.

Returns the current selection in the gnc budget view by using the macro GNC_BUDGET_VIEW_GET_PRIVATE.

Definition at line 318 of file gnc-budget-view.c.

319{
321
322 g_return_val_if_fail (GNC_IS_BUDGET_VIEW(budget_view), NULL);
323
324 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
325 return gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree_view));
326}

◆ gnc_budget_view_get_show_account_code()

gboolean gnc_budget_view_get_show_account_code ( GncBudgetView * budget_view)

Definition at line 255 of file gnc-budget-view.c.

256{
257 GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
258 return priv->show_account_code;
259}

◆ gnc_budget_view_get_show_account_description()

gboolean gnc_budget_view_get_show_account_description ( GncBudgetView * budget_view)

Definition at line 270 of file gnc-budget-view.c.

271{
272 GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
273 return priv->show_account_desc;
274}

◆ gnc_budget_view_new()

GncBudgetView * gnc_budget_view_new ( GncBudget * budget,
AccountFilterDialog * fd )

Create new gnc budget view.

Create a new "budget" display widget.

As the name suggests, this creates a new gnc budget view.

Returns
The newly created widget

Definition at line 188 of file gnc-budget-view.c.

189{
190 GncBudgetView *budget_view;
192
193 g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
194 ENTER(" ");
195
196 budget_view = g_object_new (GNC_TYPE_BUDGET_VIEW, NULL);
197
198 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
199 priv->budget = budget;
200 priv->key = *gnc_budget_get_guid (budget);
201 priv->fd = fd;
202 priv->total_col = NULL;
203 priv->show_account_code = FALSE;
204 priv->show_account_desc = FALSE;
205 gbv_create_widget (budget_view);
206
207 LEAVE("new budget view %p", budget_view);
208 return budget_view;
209}

◆ gnc_budget_view_refresh()

void gnc_budget_view_refresh ( GncBudgetView * budget_view)

refreshes the current budget view

The function will step through to only display the columns that are set as visible, and will add any needed columns (e.g. the totals column).

Definition at line 1477 of file gnc-budget-view.c.

1478{
1479 // Column identifiers
1480 enum {
1481 code_column = 1,
1482 description_column = 2,
1483 startPeriods_column = 3
1484 // The Totals column will be after the periods columns.
1485 };
1486
1488 gint num_periods;
1489 gint num_periods_visible;
1490 GtkTreeViewColumn *col, *code_col, *desc_col;
1491 GList *col_list;
1492 GList *totals_col_list;
1493 GdkRGBA *note_color, *note_color_selected;
1494 GtkStyleContext *stylectxt;
1495
1496 ENTER("view %p", budget_view);
1497
1498 g_return_if_fail (budget_view != NULL);
1499 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
1500
1501 stylectxt = gtk_widget_get_style_context (GTK_WIDGET(priv->tree_view));
1502 gtk_style_context_get (stylectxt, GTK_STATE_FLAG_SELECTED, "background-color", &note_color, NULL);
1503 gtk_style_context_get (stylectxt, GTK_STATE_FLAG_NORMAL, "background-color", &note_color_selected, NULL);
1504
1505 num_periods = gnc_budget_get_num_periods (priv->budget);
1506
1507 col_list = g_list_reverse (priv->period_col_list);
1508 totals_col_list = g_list_reverse (priv->totals_col_list);
1509 num_periods_visible = g_list_length (col_list);
1510
1511 /* Hide any unneeded extra columns */
1512 while (num_periods_visible > num_periods)
1513 {
1514 col = GTK_TREE_VIEW_COLUMN (col_list->data);
1515 gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1516 col_list = g_list_delete_link (col_list, col_list);
1517 num_periods_visible--;
1518
1519 col = GTK_TREE_VIEW_COLUMN(totals_col_list->data);
1520 gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1521 totals_col_list = g_list_delete_link (totals_col_list, totals_col_list);
1522 }
1523
1524 gnc_tree_view_configure_columns (GNC_TREE_VIEW(priv->tree_view));
1525
1526 // set visibility of the account code columns
1527 code_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "account-code");
1528 gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1529 code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), code_column);
1530 gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1531
1532 // set visibility of the account description columns
1533 desc_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "description");
1534 gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1535 desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), description_column);
1536 gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1537
1538 /* If we're creating new columns to be appended to already existing
1539 * columns, first delete the total column. (Then regenerate after
1540 * new columns have been appended */
1541 if (num_periods_visible != 0 && num_periods > num_periods_visible)
1542 {
1543 /* Delete the totals column */
1544 col = priv->total_col;
1545 gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1546 priv->total_col = NULL;
1547 col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view),
1548 startPeriods_column + num_periods_visible);
1549 gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1550 }
1551
1552 /* Create any needed columns */
1553 while (num_periods_visible < num_periods)
1554 {
1555 GtkCellRenderer *renderer = gnc_cell_renderer_text_flag_new ();
1556 g_object_set (renderer, "flag-color-rgba", note_color, NULL);
1557 g_object_set (renderer, "flag-color-rgba-selected", note_color_selected, NULL);
1558
1559 col = gnc_tree_view_account_add_custom_column_renderer (
1560 GNC_TREE_VIEW_ACCOUNT(priv->tree_view), "",
1561 budget_col_source, budget_col_edited, renderer);
1562 g_object_set_data (G_OBJECT(col), "budget_view", budget_view);
1563 g_object_set_data (G_OBJECT(col), "period_num", GUINT_TO_POINTER(num_periods_visible));
1564 col_list = g_list_prepend (col_list, col);
1565
1566 // add some padding to the right of the numbers
1567 gbv_renderer_add_padding (renderer);
1568
1569 g_signal_connect (G_OBJECT(renderer), "edited", (GCallback)gbv_col_edited_cb, budget_view);
1570 g_signal_connect (G_OBJECT(renderer), "editing-started",
1571 (GCallback)gdv_editing_started_cb, budget_view);
1572 g_signal_connect (G_OBJECT(renderer), "editing-canceled",
1573 (GCallback)gdv_editing_canceled_cb, budget_view);
1574 col = gbv_create_totals_column (budget_view, num_periods_visible);
1575 if (col != NULL)
1576 {
1577 gtk_tree_view_append_column (priv->totals_tree_view, col);
1578 totals_col_list = g_list_prepend (totals_col_list, col);
1579 }
1580
1581 num_periods_visible++;
1582 }
1583
1584 gdk_rgba_free (note_color);
1585 gdk_rgba_free (note_color_selected);
1586
1587 priv->period_col_list = g_list_reverse (col_list);
1588 priv->totals_col_list = g_list_reverse (totals_col_list);
1589
1590 if (priv->total_col == NULL)
1591 {
1592 gchar title[MAX_DATE_LENGTH + 1];
1593 guint titlelen;
1594 GDate *date;
1595 GtkCellRenderer* renderer;
1596
1597 priv->total_col = gnc_tree_view_account_add_custom_column (
1598 GNC_TREE_VIEW_ACCOUNT(priv->tree_view), _("Total"),
1599 budget_total_col_source, NULL);
1600
1601 // set column title alignment to right to match column data
1602 gtk_tree_view_column_set_alignment (priv->total_col, 1.0);
1603
1604 // set a minimum column size based on the date length, adds some space to the column
1605 date = g_date_new_dmy (31, 12, 2018);
1606 titlelen = qof_print_gdate (title, MAX_DATE_LENGTH, date);
1607 if (titlelen > 0)
1608 {
1609 PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET(budget_view), title);
1610 PangoRectangle logical_rect;
1611 pango_layout_set_width (layout, -1);
1612 pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
1613 g_object_unref (layout);
1614
1615 gtk_tree_view_column_set_min_width (priv->total_col, logical_rect.width);
1616 }
1617 g_date_free (date);
1618 g_object_set_data (G_OBJECT(priv->total_col), "budget_view", budget_view);
1619
1620 // as we only have one renderer/column, use this function to get it
1621 renderer = gnc_tree_view_column_get_renderer (priv->total_col);
1622
1623 // add some padding to the right of the numbers
1624 gbv_renderer_add_padding (renderer);
1625
1626 col = gbv_create_totals_column (budget_view, -1);
1627 if (col != NULL)
1628 gtk_tree_view_append_column (priv->totals_tree_view, col);
1629 }
1630 gbv_refresh_col_titles (budget_view);
1631
1632 PINFO("Number of columns is %d, totals columns is %d",
1633 gtk_tree_view_get_n_columns (priv->tree_view), gtk_tree_view_get_n_columns (priv->totals_tree_view));
1634
1635 LEAVE(" ");
1636}
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
Definition gnc-date.h:108
size_t qof_print_gdate(char *buf, size_t len, const GDate *gd)
Convenience; calls through to qof_print_date_dmy_buff().
Definition gnc-date.cpp:598
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting,...
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
Return the "main" cell renderer from a GtkTreeViewColumn added to a GncTreeView my one of the conveni...
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name" used with saved state.
GtkTreeViewColumn * gnc_tree_view_account_add_custom_column(GncTreeViewAccount *account_view, const gchar *column_title, GncTreeViewAccountColumnSource col_source_cb, GncTreeViewAccountColumnTextEdited col_edited_cb)
Add a new custom column to the set of columns in an account tree view.
#define PINFO(format, args...)
Print an informational note.
Definition qoflog.h:256

◆ gnc_budget_view_restore()

gboolean gnc_budget_view_restore ( GncBudgetView * budget_view,
GKeyFile * key_file,
const gchar * group_name )

Definition at line 633 of file gnc-budget-view.c.

634{
636 GError *error = NULL;
637 char *guid_str;
638 GncGUID guid;
639 GncBudget *bgt;
640 QofBook *book;
641 gboolean has_guid;
642
643 g_return_val_if_fail (key_file, FALSE);
644 g_return_val_if_fail (group_name, FALSE);
645
646 ENTER("key_file %p, group_name %s", key_file, group_name);
647
648 guid_str = g_key_file_get_string (key_file, group_name, BUDGET_GUID,
649 &error);
650 if (error)
651 {
652 g_warning ("error reading group %s key %s: %s",
653 group_name, BUDGET_GUID, error->message);
654 g_error_free (error);
655 error = NULL;
656 return FALSE;
657 }
658 has_guid = string_to_guid (guid_str, &guid);
659 g_free (guid_str);
660
661 if (!has_guid)
662 {
663 return FALSE;
664 }
665
666 book = qof_session_get_book (gnc_get_current_session());
667 bgt = gnc_budget_lookup (&guid, book);
668 if (!bgt)
669 {
670 return FALSE;
671 }
672
673 /* Create the new view */
674 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
675
676 // Restore the account filter and page state information from page section
677 gnc_tree_view_account_restore (GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
678 priv->fd, key_file, group_name);
679 LEAVE(" ");
680
681 return TRUE;
682}
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.

◆ gnc_budget_view_save()

void gnc_budget_view_save ( GncBudgetView * budget_view,
GKeyFile * key_file,
const gchar * group_name )

Definition at line 600 of file gnc-budget-view.c.

601{
603
604 g_return_if_fail (budget_view != NULL);
605 g_return_if_fail (key_file != NULL);
606 g_return_if_fail (group_name != NULL);
607
608 ENTER("view %p, key_file %p, group_name %s", budget_view, key_file, group_name);
609
610 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
611
612 // Save the account filter and page state information to page section
613 gnc_tree_view_account_save (GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
614 priv->fd, key_file, group_name);
615 LEAVE(" ");
616}

◆ gnc_budget_view_save_account_filter()

void gnc_budget_view_save_account_filter ( GncBudgetView * budget_view)

Definition at line 715 of file gnc-budget-view.c.

716{
718
719 g_return_if_fail (budget_view != NULL);
720
721 ENTER("view %p", budget_view);
722
723 priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
724
725 // Save account filter state information to budget section
726 gnc_tree_view_account_save_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
727 priv->fd, gnc_state_get_current (),
729 GNC_TREE_VIEW(priv->tree_view)));
730 LEAVE(" ");
731}
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition gnc-state.c:248
const gchar * gnc_tree_view_get_state_section(GncTreeView *view)
Get the name of the state section this tree view is associated with.

◆ gnc_budget_view_set_show_account_code()

void gnc_budget_view_set_show_account_code ( GncBudgetView * budget_view,
gboolean show_account_code )

Definition at line 247 of file gnc-budget-view.c.

248{
249 GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
250 priv->show_account_code = show_account_code;
251 gnc_budget_view_refresh (budget_view);
252}
void gnc_budget_view_refresh(GncBudgetView *budget_view)
refreshes the current budget view

◆ gnc_budget_view_set_show_account_description()

void gnc_budget_view_set_show_account_description ( GncBudgetView * budget_view,
gboolean show_account_desc )

Definition at line 262 of file gnc-budget-view.c.

263{
264 GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
265 priv->show_account_desc = show_account_desc;
266 gnc_budget_view_refresh (budget_view);
267}

◆ gnc_plugin_page_budget_new()

GncPluginPage * gnc_plugin_page_budget_new ( GncBudget * budget)

Create a new "budget" plugin page.

Returns
The newly created plugin page.

Definition at line 234 of file gnc-plugin-page-budget.cpp.

235{
237 gchar* label;
238 const GList *item;
239
240 g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
241 ENTER(" ");
242
243 /* Is there an existing page? */
244 item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_BUDGET_NAME);
245 for ( ; item; item = g_list_next (item))
246 {
247 auto plugin_page = GNC_PLUGIN_PAGE_BUDGET(item->data);
248 priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
249 if (priv->budget == budget)
250 {
251 LEAVE("existing budget page %p", plugin_page);
252 return GNC_PLUGIN_PAGE(plugin_page);
253 }
254 }
255
256 auto plugin_page = GNC_PLUGIN_PAGE_BUDGET (g_object_new (GNC_TYPE_PLUGIN_PAGE_BUDGET, nullptr));
257
258 priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
259 priv->budget = budget;
260 priv->delete_budget = FALSE;
261 priv->key = *gnc_budget_get_guid (budget);
262 priv->reportPage = NULL;
263 label = g_strdup_printf ("%s: %s", _("Budget"), gnc_budget_get_name (budget));
264 g_object_set (G_OBJECT(plugin_page), "page-name", label, NULL);
265 g_free (label);
266 LEAVE("new budget page %p", plugin_page);
267 return GNC_PLUGIN_PAGE(plugin_page);
268}
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.

◆ gnc_tree_model_budget_get_budget()

GncBudget * gnc_tree_model_budget_get_budget ( GtkTreeModel * tm,
GtkTreeIter * iter )

Definition at line 108 of file gnc-tree-model-budget.c.

109{
110 GncBudget *bgt;
111 GncGUID *guid;
112
113 gtk_tree_model_get (tm, iter, BUDGET_GUID_COLUMN, &guid, -1);
114 bgt = gnc_budget_lookup(guid, gnc_get_current_book());
115 return bgt;
116}

◆ gnc_tree_model_budget_get_iter_for_budget()

gboolean gnc_tree_model_budget_get_iter_for_budget ( GtkTreeModel * tm,
GtkTreeIter * iter,
GncBudget * bgt )

Definition at line 119 of file gnc-tree-model-budget.c.

121{
122 const GncGUID *guid1;
123 GncGUID *guid2;
124
125 g_return_val_if_fail(GNC_BUDGET(bgt), FALSE);
126
127 guid1 = gnc_budget_get_guid(bgt);
128 if (!gtk_tree_model_get_iter_first(tm, iter))
129 return FALSE;
130 while (gtk_list_store_iter_is_valid(GTK_LIST_STORE(tm), iter))
131 {
132 gtk_tree_model_get (tm, iter, BUDGET_GUID_COLUMN, &guid2, -1);
133
134 if (guid_equal(guid1, guid2))
135 return TRUE;
136
137 if (!gtk_tree_model_iter_next(tm, iter))
138 return FALSE;
139 }
140 return FALSE;
141}
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition guid.cpp:237

◆ gnc_tree_model_budget_new()

GtkTreeModel * gnc_tree_model_budget_new ( QofBook * book)

Definition at line 70 of file gnc-tree-model-budget.c.

71{
72 GtkListStore* store;
73
74 store = gtk_list_store_new (BUDGET_LIST_NUM_COLS,
75 G_TYPE_POINTER,
76 G_TYPE_STRING,
77 G_TYPE_STRING);
78
79 qof_collection_foreach(qof_book_get_collection(book, GNC_ID_BUDGET),
80 add_budget_to_model, GTK_TREE_MODEL(store));
81
82 return GTK_TREE_MODEL(store);
83}

◆ gnc_tree_view_budget_set_model()

void gnc_tree_view_budget_set_model ( GtkTreeView * tv,
GtkTreeModel * tm )

Definition at line 86 of file gnc-tree-model-budget.c.

87{
88 GtkCellRenderer *renderer;
89 GtkTreeViewColumn *column;
90
91 gtk_tree_view_set_model (tv, tm);
92
93 /* column for name */
94 renderer = gtk_cell_renderer_text_new ();
95 column = gtk_tree_view_column_new_with_attributes (
96 _("Name"), renderer, "text", BUDGET_NAME_COLUMN, NULL);
97 gtk_tree_view_append_column (tv, column);
98
99 /* column for description */
100 renderer = gtk_cell_renderer_text_new ();
101 column = gtk_tree_view_column_new_with_attributes (
102 _("Description"), renderer, "text", BUDGET_DESCRIPTION_COLUMN, NULL);
103 gtk_tree_view_append_column (tv, column);
104
105}

Variable Documentation

◆ budget [1/2]

GncBudget* BudgetAccumulationInfo::budget

Definition at line 1013 of file gnc-budget-view.c.

◆ budget [2/2]

GncBudget* GncBudgetViewPrivate::budget

Definition at line 162 of file gnc-budget-view.c.

◆ fd

AccountFilterDialog* GncBudgetViewPrivate::fd

Definition at line 169 of file gnc-budget-view.c.

◆ hadj

GtkAdjustment* GncBudgetViewPrivate::hadj

Definition at line 160 of file gnc-budget-view.c.

◆ key

GncGUID GncBudgetViewPrivate::key

Definition at line 163 of file gnc-budget-view.c.

◆ pdb

GNCPriceDB* BudgetAccumulationInfo::pdb

Definition at line 1015 of file gnc-budget-view.c.

◆ period_col_list

GList* GncBudgetViewPrivate::period_col_list

Definition at line 166 of file gnc-budget-view.c.

◆ period_num

guint BudgetAccumulationInfo::period_num

Definition at line 1014 of file gnc-budget-view.c.

◆ rootAcct

Account* GncBudgetViewPrivate::rootAcct

Definition at line 170 of file gnc-budget-view.c.

◆ show_account_code

gboolean GncBudgetViewPrivate::show_account_code

Definition at line 171 of file gnc-budget-view.c.

◆ show_account_desc

gboolean GncBudgetViewPrivate::show_account_desc

Definition at line 172 of file gnc-budget-view.c.

◆ temp_ce

GtkCellEditable* GncBudgetViewPrivate::temp_ce

Definition at line 175 of file gnc-budget-view.c.

◆ temp_cr

GtkCellRenderer* GncBudgetViewPrivate::temp_cr

Definition at line 174 of file gnc-budget-view.c.

◆ total

gnc_numeric BudgetAccumulationInfo::total

Definition at line 1012 of file gnc-budget-view.c.

◆ total_col

GtkTreeViewColumn* GncBudgetViewPrivate::total_col

Definition at line 168 of file gnc-budget-view.c.

◆ total_currency

gnc_commodity* BudgetAccumulationInfo::total_currency

Definition at line 1016 of file gnc-budget-view.c.

◆ totals_col_list

GList* GncBudgetViewPrivate::totals_col_list

Definition at line 167 of file gnc-budget-view.c.

◆ totals_scroll_window

GtkWidget* GncBudgetViewPrivate::totals_scroll_window

Definition at line 159 of file gnc-budget-view.c.

◆ totals_tree_view

GtkTreeView* GncBudgetViewPrivate::totals_tree_view

Definition at line 158 of file gnc-budget-view.c.

◆ tree_view

GtkTreeView* GncBudgetViewPrivate::tree_view

Definition at line 157 of file gnc-budget-view.c.

◆ use_red_color

gboolean GncBudgetViewPrivate::use_red_color

Definition at line 164 of file gnc-budget-view.c.

◆ w [1/2]

GtkBox GncBudgetView::w

Definition at line 89 of file gnc-budget-view.c.

◆ w [2/2]

GtkBoxClass GncBudgetViewClass::w

Definition at line 94 of file gnc-budget-view.c.