GnuCash  4.12-75-g66025ae738+
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*)gnc_budget_view_get_instance_private((GncBudgetView*)o))
 
#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)
 
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)
 
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 323 of file gnc-budget.cpp.

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

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

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