GnuCash  4.10-100-g8b5b6256d+
Files | Data Structures | Macros | Enumerations | Enumerator | Functions | Variables
Budgets

gnc-budget_view.c – Budget display widget More...

Files

file  gnc-budget.h
 GnuCash Budgets.
 
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
 
file  gnc-tree-model-budget.h
 provides some utilities for working with the list of budgets in a book.
 

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)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))
 
#define GNC_BUDGET_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))
 
#define GNC_IS_BUDGET(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))
 
#define GNC_IS_BUDGET_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))
 
#define GNC_BUDGET_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))
 
#define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS   3
 
#define GNC_BUDGET_NOTES_PATH   "notes"
 
#define gnc_budget_return_guid(X)   (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
 
#define gnc_budget_lookup_direct(g, b)   gnc_budget_lookup(&(g),(b))
 
#define PLUGIN_PAGE_BUDGET_CM_CLASS   "budget-view"
 
#define STATE_SECTION_PREFIX   "Budget"
 
#define GNC_BUDGET_VIEW_GET_PRIVATE(o)   ((GncBudgetViewPrivate*)g_type_instance_get_private ((GTypeInstance*)o, GNC_TYPE_BUDGET_VIEW))
 
#define BUDGET_GUID   "Budget GncGUID"
 
#define GNC_TYPE_BUDGET_VIEW   (gnc_budget_view_get_type ())
 
#define GNC_BUDGET_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetView))
 
#define GNC_BUDGET_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))
 
#define GNC_IS_BUDGET_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_BUDGET_VIEW))
 
#define GNC_IS_BUDGET_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_BUDGET_VIEW))
 
#define GNC_BUDGET_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_BUDGET_VIEW, GncBudgetViewClass))
 
#define GNC_BUDGET_VIEW_NAME   "GncBudgetView"
 
#define GNC_TYPE_PLUGIN_PAGE_BUDGET   (gnc_plugin_page_budget_get_type ())
 
#define GNC_PLUGIN_PAGE_BUDGET(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudget))
 
#define GNC_PLUGIN_PAGE_BUDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))
 
#define GNC_IS_PLUGIN_PAGE_BUDGET(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET))
 
#define GNC_IS_PLUGIN_PAGE_BUDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_BUDGET))
 
#define GNC_PLUGIN_PAGE_BUDGET_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_BUDGET, GncPluginPageBudgetClass))
 
#define GNC_PLUGIN_PAGE_BUDGET_NAME   "GncPluginPageBudget"
 

Enumerations

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

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. More...
 
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 GncGUIDgnc_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 Recurrencegnc_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)
 
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)
 
GncBudgetView * gnc_budget_view_new (GncBudget *budget, AccountFilterDialog *fd)
 Create new gnc budget view. More...
 
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. More...
 
Accountgnc_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 More...
 
GType gnc_budget_view_get_type (void)
 
GType gnc_plugin_page_budget_get_type (void)
 
GncPluginPagegnc_plugin_page_budget_new (GncBudget *budget)
 Create a new "budget" plugin page. More...
 
void gnc_budget_gui_delete_budget (GncBudget *budget)
 
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)
 

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
 
AccountFilterDialogGncBudgetViewPrivate::fd
 
AccountGncBudgetViewPrivate::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

Enumeration Type Documentation

◆ 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 95 of file gnc-budget-view.c.

96 {
101 };
This total is Remaining to Budget.
This total is Expenses type.
This total is Income type.
This total is Asset/Liab/Equity type.

◆ anonymous enum

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

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

39 {
40  BUDGET_GUID_COLUMN,
41  BUDGET_NAME_COLUMN,
42  BUDGET_DESCRIPTION_COLUMN,
43  BUDGET_LIST_NUM_COLS
44 };

Function Documentation

◆ gnc_budget_destroy()

void gnc_budget_destroy ( GncBudget *  budget)

Deletes the given budget object.

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

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

◆ 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 320 of file gnc-budget-view.c.

321 {
322  GncBudgetViewPrivate *priv;
323 
324  g_return_val_if_fail (GNC_IS_BUDGET_VIEW(budget_view), NULL);
325 
326  priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
327  return gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree_view));
328 }
the private budget view structure

◆ 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;
191  GncBudgetViewPrivate *priv;
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 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
the private budget view structure
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 1550 of file gnc-budget-view.c.

1551 {
1552  GncBudgetViewPrivate *priv;
1553  gint num_periods;
1554  gint num_periods_visible;
1555  GtkTreeViewColumn *col, *code_col, *desc_col;
1556  GList *col_list;
1557  GList *totals_col_list;
1558  GdkRGBA *note_color, *note_color_selected;
1559  GtkStyleContext *stylectxt;
1560 
1561  ENTER("view %p", budget_view);
1562 
1563  g_return_if_fail (budget_view != NULL);
1564  priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
1565 
1566  stylectxt = gtk_widget_get_style_context (GTK_WIDGET(priv->tree_view));
1567  gtk_style_context_get (stylectxt, GTK_STATE_FLAG_SELECTED, "background-color", &note_color, NULL);
1568  gtk_style_context_get (stylectxt, GTK_STATE_FLAG_NORMAL, "background-color", &note_color_selected, NULL);
1569 
1570  num_periods = gnc_budget_get_num_periods (priv->budget);
1571 
1572  col_list = g_list_reverse (priv->period_col_list);
1573  totals_col_list = g_list_reverse (priv->totals_col_list);
1574  num_periods_visible = g_list_length (col_list);
1575 
1576  /* Hide any unneeded extra columns */
1577  while (num_periods_visible > num_periods)
1578  {
1579  col = GTK_TREE_VIEW_COLUMN (col_list->data);
1580  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1581  col_list = g_list_delete_link (col_list, col_list);
1582  num_periods_visible--;
1583 
1584  col = GTK_TREE_VIEW_COLUMN(totals_col_list->data);
1585  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1586  totals_col_list = g_list_delete_link (totals_col_list, totals_col_list);
1587  }
1588 
1589  gnc_tree_view_configure_columns (GNC_TREE_VIEW(priv->tree_view));
1590 
1591  // set visibility of the account code columns
1592  code_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "account-code");
1593  gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1594  code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 1);
1595  gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1596 
1597  // set visibility of the account description columns
1598  desc_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "description");
1599  gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1600  desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 2);
1601  gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1602 
1603  /* If we're creating new columns to be appended to already existing
1604  * columns, first delete the total column. (Then regenerate after
1605  * new columns have been appended */
1606  if (num_periods_visible != 0 && num_periods > num_periods_visible)
1607  {
1608  /* Delete the totals column */
1609  col = priv->total_col;
1610  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1611  priv->total_col = NULL;
1612  col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), num_periods_visible + 1);
1613  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1614  }
1615 
1616  /* Create any needed columns */
1617  while (num_periods_visible < num_periods)
1618  {
1619  GtkCellRenderer *renderer = gnc_cell_renderer_text_flag_new ();
1620  g_object_set (renderer, "flag-color-rgba", note_color, NULL);
1621  g_object_set (renderer, "flag-color-rgba-selected", note_color_selected, NULL);
1622 
1623  col = gnc_tree_view_account_add_custom_column_renderer (
1624  GNC_TREE_VIEW_ACCOUNT(priv->tree_view), "",
1625  budget_col_source, budget_col_edited, renderer);
1626  g_object_set_data (G_OBJECT(col), "budget_view", budget_view);
1627  g_object_set_data (G_OBJECT(col), "period_num", GUINT_TO_POINTER(num_periods_visible));
1628  col_list = g_list_prepend (col_list, col);
1629 
1630  // add some padding to the right of the numbers
1631  gbv_renderer_add_padding (renderer);
1632 
1633  g_signal_connect (G_OBJECT(renderer), "edited", (GCallback)gbv_col_edited_cb, budget_view);
1634  g_signal_connect (G_OBJECT(renderer), "editing-started",
1635  (GCallback)gdv_editing_started_cb, budget_view);
1636  g_signal_connect (G_OBJECT(renderer), "editing-canceled",
1637  (GCallback)gdv_editing_canceled_cb, budget_view);
1638  col = gbv_create_totals_column (budget_view, num_periods_visible);
1639  if (col != NULL)
1640  {
1641  gtk_tree_view_append_column (priv->totals_tree_view, col);
1642  totals_col_list = g_list_prepend (totals_col_list, col);
1643  }
1644 
1645  num_periods_visible++;
1646  }
1647 
1648  gdk_rgba_free (note_color);
1649  gdk_rgba_free (note_color_selected);
1650 
1651  priv->period_col_list = g_list_reverse (col_list);
1652  priv->totals_col_list = g_list_reverse (totals_col_list);
1653 
1654  if (priv->total_col == NULL)
1655  {
1656  gchar title[MAX_DATE_LENGTH + 1];
1657  guint titlelen;
1658  GDate *date;
1659  GtkCellRenderer* renderer;
1660 
1661  priv->total_col = gnc_tree_view_account_add_custom_column (
1662  GNC_TREE_VIEW_ACCOUNT(priv->tree_view), _("Total"),
1663  budget_total_col_source, NULL);
1664 
1665  // set column title alignment to right to match column data
1666  gtk_tree_view_column_set_alignment (priv->total_col, 1.0);
1667 
1668  // set a minimum column size based on the date length, adds some space to the column
1669  date = g_date_new_dmy (31, 12, 2018);
1670  titlelen = qof_print_gdate (title, MAX_DATE_LENGTH, date);
1671  if (titlelen > 0)
1672  {
1673  PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET(budget_view), title);
1674  PangoRectangle logical_rect;
1675  pango_layout_set_width (layout, -1);
1676  pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
1677  g_object_unref (layout);
1678 
1679  gtk_tree_view_column_set_min_width (priv->total_col, logical_rect.width);
1680  }
1681  g_date_free (date);
1682  g_object_set_data (G_OBJECT(priv->total_col), "budget_view", budget_view);
1683 
1684  // as we only have one renderer/column, use this function to get it
1685  renderer = gnc_tree_view_column_get_renderer (priv->total_col);
1686 
1687  // add some padding to the right of the numbers
1688  gbv_renderer_add_padding (renderer);
1689 
1690  col = gbv_create_totals_column (budget_view, -1);
1691  if (col != NULL)
1692  gtk_tree_view_append_column (priv->totals_tree_view, col);
1693  }
1694  gbv_refresh_col_titles (budget_view);
1695 
1696  PINFO("Number of columns is %d, totals columns is %d",
1697  gtk_tree_view_get_n_columns (priv->tree_view), gtk_tree_view_get_n_columns (priv->totals_tree_view));
1698 
1699  LEAVE(" ");
1700 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
size_t qof_print_gdate(char *buf, size_t bufflen, const GDate *gd)
Convenience; calls through to qof_print_date_dmy_buff().
Definition: gnc-date.cpp:605
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.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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_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.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
the private budget view structure
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
Definition: gnc-date.h:114
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 291 of file gnc-plugin-page-budget.c.

292 {
293  GncPluginPageBudget *plugin_page;
295  gchar* label;
296  const GList *item;
297 
298  g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
299  ENTER(" ");
300 
301  /* Is there an existing page? */
302  item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_BUDGET_NAME);
303  for ( ; item; item = g_list_next (item))
304  {
305  plugin_page = (GncPluginPageBudget *)item->data;
306  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
307  if (priv->budget == budget)
308  {
309  LEAVE("existing budget page %p", plugin_page);
310  return GNC_PLUGIN_PAGE(plugin_page);
311  }
312  }
313 
314  plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_BUDGET, NULL);
315 
316  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
317  priv->budget = budget;
318  priv->delete_budget = FALSE;
319  priv->key = *gnc_budget_get_guid (budget);
320  priv->reportPage = NULL;
321  label = g_strdup_printf ("%s: %s", _("Budget"), gnc_budget_get_name (budget));
322  g_object_set (G_OBJECT(plugin_page), "page-name", label, NULL);
323  g_free (label);
324  LEAVE("new budget page %p", plugin_page);
325  return GNC_PLUGIN_PAGE(plugin_page);
326 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282