GnuCash  4.8a-132-gcdaeb421d+
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 304 of file gnc-budget.c.

305 {
306  g_return_if_fail(GNC_IS_BUDGET(budget));
307  gnc_budget_begin_edit(budget);
308  qof_instance_set_dirty(&budget->inst);
309  qof_instance_set_destroying(budget, TRUE);
310  gnc_budget_commit_edit(budget);
311 }

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

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

281 {
282  GncPluginPageBudget *plugin_page;
284  gchar* label;
285  const GList *item;
286 
287  g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
288  ENTER(" ");
289 
290  /* Is there an existing page? */
291  item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_BUDGET_NAME);
292  for ( ; item; item = g_list_next (item))
293  {
294  plugin_page = (GncPluginPageBudget *)item->data;
295  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
296  if (priv->budget == budget)
297  {
298  LEAVE("existing budget page %p", plugin_page);
299  return GNC_PLUGIN_PAGE(plugin_page);
300  }
301  }
302 
303  plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_BUDGET, NULL);
304 
305  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
306  priv->budget = budget;
307  priv->delete_budget = FALSE;
308  priv->key = *gnc_budget_get_guid (budget);
309  priv->reportPage = NULL;
310  label = g_strdup_printf ("%s: %s", _("Budget"), gnc_budget_get_name (budget));
311  g_object_set (G_OBJECT(plugin_page), "page-name", label, NULL);
312  g_free (label);
313  LEAVE("new budget page %p", plugin_page);
314  return GNC_PLUGIN_PAGE(plugin_page);
315 }
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