GnuCash  4.901-15-g732a005710
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 93 of file gnc-budget-view.c.

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

◆ 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 };

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

319 {
320  GncBudgetViewPrivate *priv;
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 }
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 186 of file gnc-budget-view.c.

187 {
188  GncBudgetView *budget_view;
189  GncBudgetViewPrivate *priv;
190 
191  g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
192  ENTER(" ");
193 
194  budget_view = g_object_new (GNC_TYPE_BUDGET_VIEW, NULL);
195 
196  priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
197  priv->budget = budget;
198  priv->key = *gnc_budget_get_guid (budget);
199  priv->fd = fd;
200  priv->total_col = NULL;
201  priv->show_account_code = FALSE;
202  priv->show_account_desc = FALSE;
203  gbv_create_widget (budget_view);
204 
205  LEAVE("new budget view %p", budget_view);
206  return budget_view;
207 }
#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 1507 of file gnc-budget-view.c.

1508 {
1509  GncBudgetViewPrivate *priv;
1510  gint num_periods;
1511  gint num_periods_visible;
1512  GtkTreeViewColumn *col, *code_col, *desc_col;
1513  GList *col_list;
1514  GList *totals_col_list;
1515  GdkRGBA *note_color, *note_color_selected;
1516  GtkStyleContext *stylectxt;
1517 
1518  ENTER("view %p", budget_view);
1519 
1520  g_return_if_fail (budget_view != NULL);
1521  priv = GNC_BUDGET_VIEW_GET_PRIVATE(budget_view);
1522 
1523  stylectxt = gtk_widget_get_style_context (GTK_WIDGET(priv->tree_view));
1524  gtk_style_context_get (stylectxt, GTK_STATE_FLAG_SELECTED, "background-color", &note_color, NULL);
1525  gtk_style_context_get (stylectxt, GTK_STATE_FLAG_NORMAL, "background-color", &note_color_selected, NULL);
1526 
1527  num_periods = gnc_budget_get_num_periods (priv->budget);
1528 
1529  col_list = g_list_reverse (priv->period_col_list);
1530  totals_col_list = g_list_reverse (priv->totals_col_list);
1531  num_periods_visible = g_list_length (col_list);
1532 
1533  /* Hide any unneeded extra columns */
1534  while (num_periods_visible > num_periods)
1535  {
1536  col = GTK_TREE_VIEW_COLUMN (col_list->data);
1537  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1538  col_list = g_list_delete_link (col_list, col_list);
1539  num_periods_visible--;
1540 
1541  col = GTK_TREE_VIEW_COLUMN(totals_col_list->data);
1542  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1543  totals_col_list = g_list_delete_link (totals_col_list, totals_col_list);
1544  }
1545 
1546  gnc_tree_view_configure_columns (GNC_TREE_VIEW(priv->tree_view));
1547 
1548  // set visibility of the account code columns
1549  code_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "account-code");
1550  gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1551  code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 1);
1552  gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
1553 
1554  // set visibility of the account description columns
1555  desc_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "description");
1556  gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1557  desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 2);
1558  gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
1559 
1560  /* If we're creating new columns to be appended to already existing
1561  * columns, first delete the total column. (Then regenerate after
1562  * new columns have been appended */
1563  if (num_periods_visible != 0 && num_periods > num_periods_visible)
1564  {
1565  /* Delete the totals column */
1566  col = priv->total_col;
1567  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
1568  priv->total_col = NULL;
1569  col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), num_periods_visible + 1);
1570  gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
1571  }
1572 
1573  /* Create any needed columns */
1574  while (num_periods_visible < num_periods)
1575  {
1576  GtkCellRenderer *renderer = gnc_cell_renderer_text_flag_new ();
1577  g_object_set (renderer, "flag-color-rgba", note_color, NULL);
1578  g_object_set (renderer, "flag-color-rgba-selected", note_color_selected, NULL);
1579 
1580  col = gnc_tree_view_account_add_custom_column_renderer (
1581  GNC_TREE_VIEW_ACCOUNT(priv->tree_view), "",
1582  budget_col_source, budget_col_edited, renderer);
1583  g_object_set_data (G_OBJECT(col), "budget_view", budget_view);
1584  g_object_set_data (G_OBJECT(col), "period_num", GUINT_TO_POINTER(num_periods_visible));
1585  col_list = g_list_prepend (col_list, col);
1586 
1587  // add some padding to the right of the numbers
1588  gbv_renderer_add_padding (renderer);
1589 
1590  g_signal_connect (G_OBJECT(renderer), "edited", (GCallback)gbv_col_edited_cb, budget_view);
1591  g_signal_connect (G_OBJECT(renderer), "editing-started",
1592  (GCallback)gdv_editing_started_cb, budget_view);
1593  g_signal_connect (G_OBJECT(renderer), "editing-canceled",
1594  (GCallback)gdv_editing_canceled_cb, budget_view);
1595  col = gbv_create_totals_column (budget_view, num_periods_visible);
1596  if (col != NULL)
1597  {
1598  gtk_tree_view_append_column (priv->totals_tree_view, col);
1599  totals_col_list = g_list_prepend (totals_col_list, col);
1600  }
1601 
1602  num_periods_visible++;
1603  }
1604 
1605  gdk_rgba_free (note_color);
1606  gdk_rgba_free (note_color_selected);
1607 
1608  priv->period_col_list = g_list_reverse (col_list);
1609  priv->totals_col_list = g_list_reverse (totals_col_list);
1610 
1611  if (priv->total_col == NULL)
1612  {
1613  gchar title[MAX_DATE_LENGTH + 1];
1614  guint titlelen;
1615  GDate *date;
1616  GtkCellRenderer* renderer;
1617 
1618  priv->total_col = gnc_tree_view_account_add_custom_column (
1619  GNC_TREE_VIEW_ACCOUNT(priv->tree_view), _("Total"),
1620  budget_total_col_source, NULL);
1621 
1622  // set column title alignment to right to match column data
1623  gtk_tree_view_column_set_alignment (priv->total_col, 1.0);
1624 
1625  // set a minimum column size based on the date length, adds some space to the column
1626  date = g_date_new_dmy (31, 12, 2018);
1627  titlelen = qof_print_gdate (title, MAX_DATE_LENGTH, date);
1628  if (titlelen > 0)
1629  {
1630  PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET(budget_view), title);
1631  PangoRectangle logical_rect;
1632  pango_layout_set_width (layout, -1);
1633  pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
1634  g_object_unref (layout);
1635 
1636  gtk_tree_view_column_set_min_width (priv->total_col, logical_rect.width);
1637  }
1638  g_date_free (date);
1639  g_object_set_data (G_OBJECT(priv->total_col), "budget_view", budget_view);
1640 
1641  // as we only have one renderer/column, use this function to get it
1642  renderer = gnc_tree_view_column_get_renderer (priv->total_col);
1643 
1644  // add some padding to the right of the numbers
1645  gbv_renderer_add_padding (renderer);
1646 
1647  col = gbv_create_totals_column (budget_view, -1);
1648  if (col != NULL)
1649  gtk_tree_view_append_column (priv->totals_tree_view, col);
1650  }
1651  gbv_refresh_col_titles (budget_view);
1652 
1653  PINFO("Number of columns is %d, totals columns is %d",
1654  gtk_tree_view_get_n_columns (priv->tree_view), gtk_tree_view_get_n_columns (priv->totals_tree_view));
1655 
1656  LEAVE(" ");
1657 }
#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:602
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:108
#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 239 of file gnc-plugin-page-budget.c.

240 {
241  GncPluginPageBudget *plugin_page;
243  gchar* label;
244  const GList *item;
245 
246  g_return_val_if_fail (GNC_IS_BUDGET(budget), NULL);
247  ENTER(" ");
248 
249  /* Is there an existing page? */
250  item = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_BUDGET_NAME);
251  for ( ; item; item = g_list_next (item))
252  {
253  plugin_page = (GncPluginPageBudget *)item->data;
254  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
255  if (priv->budget == budget)
256  {
257  LEAVE("existing budget page %p", plugin_page);
258  return GNC_PLUGIN_PAGE(plugin_page);
259  }
260  }
261 
262  plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_BUDGET, NULL);
263 
264  priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(plugin_page);
265  priv->budget = budget;
266  priv->delete_budget = FALSE;
267  priv->key = *gnc_budget_get_guid (budget);
268  priv->reportPage = NULL;
269  label = g_strdup_printf ("%s: %s", _("Budget"), gnc_budget_get_name (budget));
270  g_object_set (G_OBJECT(plugin_page), "page-name", label, NULL);
271  g_free (label);
272  LEAVE("new budget page %p", plugin_page);
273  return GNC_PLUGIN_PAGE(plugin_page);
274 }
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