GnuCash  4.904-1-g0110442c28
Modules | Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
GUI

gnc-plugin-page-report.h – A GncPlugin page for a report. More...

Modules

 Window/Plugin Structure
 
 Dialogs
 
 Assistants
 
 Utility functions for the GnuCash GUI
 
 Auto-complete typed user input.
 QuickFill is meant to be used by the GUI to auto-complete (e.g.
 
 Options Dialog
 
 Reports
 
 Creating and editing accounts in the GUI
 
 Commodity windows
 
 GncCurrencyEdit
 
 Gnome-specific GUI handling.
 
 GUIUtility
 
 GnuCash Tree Model
 
 GncTreeView
 
 Registers, Ledgers and Journals
 

Files

file  gnc-accounting-period.c
 General utilities for dealing with accounting periods.
 
file  gnc-accounting-period.h
 General utilities for dealing with accounting periods.
 
file  dialog-book-close.h
 This file contains the functions to present a GUI to select a book closing date and accounts into which to close the Income and Expense accounts.
 
file  dialog-file-access.h
 This file contains the functions to present a GUI to select a file or a database connection.
 
file  dialog-object-references.h
 This file contains the functions to present a dialog box with a list of object references and an explanation that these objects must be modified to not refer to another specific object so that that object may be deleted.
 
file  gnc-period-select.c
 A custom widget for selecting accounting periods.
 
file  gnc-period-select.h
 A custom widget for selecting accounting periods.
 
file  gnc-tree-view-sx-list.h
 GncTreeView implementation for Scheduled Transaction List.
 
file  gnc-tree-view.h
 common utilities for manipulating a GtkTreeView within gnucash
 

Data Structures

struct  GncPeriodSelectPrivate
 Private Data Structure. More...
 
struct  GncPeriodSelect
 
struct  GncPeriodSelectClass
 
struct  GncTreeViewSxList
 
struct  GncTreeViewSxListClass
 
struct  GncTreeView
 
struct  GncTreeViewClass
 

Macros

#define GNC_PERIOD_SELECT_GET_PRIVATE(o)   ((GncPeriodSelectPrivate*)gnc_period_select_get_instance_private((GncPeriodSelect*)o))
 
#define GNC_TYPE_PERIOD_SELECT   (gnc_period_select_get_type())
 
#define GNC_PERIOD_SELECT(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PERIOD_SELECT, GncPeriodSelect))
 
#define GNC_PERIOD_SELECT_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_PERIOD_SELECT, GncPeriodSelectClass))
 
#define GNC_IS_PERIOD_SELECT(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PERIOD_SELECT))
 
#define GNC_TYPE_TREE_VIEW_SX_LIST   (gnc_tree_view_sx_list_get_type ())
 
#define GNC_TREE_VIEW_SX_LIST(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_SX_LIST, GncTreeViewSxList))
 
#define GNC_TREE_VIEW_SX_LIST_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_SX_LIST, GncTreeViewSxListClass))
 
#define GNC_IS_TREE_VIEW_SX_LIST(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_SX_LIST))
 
#define GNC_IS_TREE_VIEW_SX_LIST_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_SX_LIST))
 
#define GNC_TREE_VIEW_SX_LIST_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_SX_LIST, GncTreeViewSxListClass))
 
#define GNC_TYPE_TREE_VIEW   (gnc_tree_view_get_type ())
 
#define GNC_TREE_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW, GncTreeView))
 
#define GNC_TREE_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
 
#define GNC_IS_TREE_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW))
 
#define GNC_IS_TREE_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW))
 
#define GNC_TREE_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW, GncTreeViewClass))
 
#define GNC_TREE_VIEW_NAME   "GncTreeView"
 
#define MODEL_COLUMN   "model_column"
 
#define REAL_TITLE   "real_title"
 
#define PREF_NAME   "pref-name"
 
#define ALWAYS_VISIBLE   "always-visible"
 
#define DEFAULT_VISIBLE   "default-visible"
 
#define GNC_TREE_VIEW_COLUMN_DATA_NONE   -1
 
#define GNC_TREE_VIEW_COLUMN_COLOR_NONE   -1
 
#define GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS   -1
 

Typedefs

typedef void(* renderer_toggled) (GtkCellRendererToggle *cell_renderer_toggle, const gchar *path, gpointer user_data)
 

Enumerations

enum  GncAccountingPeriod {
  GNC_ACCOUNTING_PERIOD_INVALID = -1, GNC_ACCOUNTING_PERIOD_TODAY, GNC_ACCOUNTING_PERIOD_MONTH, GNC_ACCOUNTING_PERIOD_MONTH_PREV,
  GNC_ACCOUNTING_PERIOD_QUARTER, GNC_ACCOUNTING_PERIOD_QUARTER_PREV, GNC_ACCOUNTING_PERIOD_CYEAR, GNC_ACCOUNTING_PERIOD_CYEAR_PREV,
  GNC_ACCOUNTING_PERIOD_CYEAR_LAST, GNC_ACCOUNTING_PERIOD_FYEAR = GNC_ACCOUNTING_PERIOD_CYEAR_LAST, GNC_ACCOUNTING_PERIOD_FYEAR_PREV, GNC_ACCOUNTING_PERIOD_FYEAR_LAST,
  GNC_ACCOUNTING_PERIOD_LAST = GNC_ACCOUNTING_PERIOD_FYEAR_LAST
}
 This specifies a time interval.
 
enum  {
  PROP_0, PROP_FY_END, PROP_SHOW_DATE, PROP_DATE_BASE,
  PROP_PS_ACTIVE
}
 
enum  { CHANGED, LAST_SIGNAL }
 

Functions

void gnc_ui_close_book (QofBook *book, GtkWindow *parent)
 Create and run the dialog to close the book. More...
 
void gnc_ui_file_access_for_open (GtkWindow *parent)
 
void gnc_ui_file_access_for_save_as (GtkWindow *parent)
 
void gnc_ui_file_access_for_export (GtkWindow *parent)
 
void gnc_ui_object_references_show (const gchar *explanation, GList *objlist)
 
 GncOptionsDialog::GncOptionsDialog (const char *title, GtkWindow *parent)
 
 GncOptionsDialog::GncOptionsDialog (bool modal, const char *title, const char *component_class, GtkWindow *parent)
 Constructs a GncOptionsDialog. More...
 
 GncOptionsDialog::GncOptionsDialog (const GncOptionsDialog &)=default
 
 GncOptionsDialog::GncOptionsDialog (GncOptionsDialog &&)=default
 
GtkWidget * GncOptionsDialog::get_widget () const noexcept
 
GtkWidget * GncOptionsDialog::get_page_list () const noexcept
 
GtkWidget * GncOptionsDialog::get_page_list_view () const noexcept
 
GtkWidget * GncOptionsDialog::get_notebook () const noexcept
 
GncOptionDBGncOptionsDialog::get_option_db () noexcept
 
void GncOptionsDialog::build_contents (GncOptionDB *odb)
 
void GncOptionsDialog::build_contents (GncOptionDB *odb, bool show_dialog)
 Populate the dialog's notebook with the contents of odb. More...
 
void GncOptionsDialog::set_sensitive (bool sensitive) noexcept
 
void GncOptionsDialog::changed () noexcept
 
void GncOptionsDialog::set_apply_cb (GncOptionsDialogCallback, void *cb_data) noexcept
 
void GncOptionsDialog::call_apply_cb () noexcept
 
void GncOptionsDialog::set_help_cb (GncOptionsDialogCallback, void *cb_data) noexcept
 
void GncOptionsDialog::call_help_cb () noexcept
 
void GncOptionsDialog::set_close_cb (GncOptionsDialogCallback, void *cb_data) noexcept
 
void GncOptionsDialog::call_close_cb () noexcept
 
void GncOptionsDialog::set_book_help_cb () noexcept
 
void GncOptionsDialog::call_book_help_cb () noexcept
 
void GncOptionsDialog::set_style_sheet_help_cb () noexcept
 
void GncOptionsDialog::call_style_sheet_help_cb () noexcept
 
void gnc_period_select_set_active (GncPeriodSelect *period, GncAccountingPeriod which)
 Set which item in the GncPeriodSelect is initially selected. More...
 
GncAccountingPeriod gnc_period_select_get_active (GncPeriodSelect *period)
 Get the currently selected accounting period from a GncPeriodSelect widget. More...
 
GDate * gnc_period_select_get_date (GncPeriodSelect *period)
 Get the currently selected accounting period choice from a GncPeriodSelect widget. More...
 
GType gnc_tree_view_sx_list_get_type (void)
 
GtkTreeView * gnc_tree_view_sx_list_new (GncSxInstanceModel *sx_instances)
 
SchedXaction * gnc_tree_view_sx_list_get_sx_from_path (GncTreeViewSxList *view, GtkTreePath *path)
 
GType gnc_tree_view_get_type (void)
 

Variables

const gchar * start_strings [GNC_ACCOUNTING_PERIOD_LAST]
 
const gchar * end_strings [GNC_ACCOUNTING_PERIOD_LAST]
 

Accounting Periods

time64 gnc_accounting_period_fiscal_start (void)
 
time64 gnc_accounting_period_fiscal_end (void)
 
GDate * gnc_accounting_period_start_gdate (GncAccountingPeriod which, const GDate *fy_end, const GDate *contains)
 This function returns the starting date for an accounting period. More...
 
GDate * gnc_accounting_period_end_gdate (GncAccountingPeriod which, const GDate *fy_end, const GDate *contains)
 This function returns the ending date for an accounting period. More...
 

GncPeriodSelect Properties

GDate * gnc_period_select_get_fy_end (GncPeriodSelect *period)
 Get the current value of the fiscal year end setting from a GncPeriodSelect widget. More...
 
void gnc_period_select_set_fy_end (GncPeriodSelect *period, const GDate *fy_end)
 Set the fiscal year end on a GncPeriodSelect widget. More...
 
gboolean gnc_period_select_get_show_date (GncPeriodSelect *period)
 Get the current value of the "show sample" setting from a GncPeriodSelect widget.
 
void gnc_period_select_set_show_date (GncPeriodSelect *period, const gboolean show_date)
 Set the "show sample" setting on a GncPeriodSelect widget. More...
 
GDate * gnc_period_select_get_date_base (GncPeriodSelect *period)
 
void gnc_period_select_set_date_base (GncPeriodSelect *period, const GDate *date_base)
 

GncPeriodSelect Core Implementation

GtkWidget * gnc_period_select_new (gboolean starting_labels)
 Create a new GncPeriodSelect widget which is used to select a accounting period like "previous month" or "this year". More...
 
GtkWidget * gnc_period_select_new_glade (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2)
 Create a new GncPeriodSelect widget from a glade file. More...
 

GncPeriodSelect Widget Implementation

GType gnc_period_select_get_type (void)
 Returns the GType of a GncPeriodSelect widget.
 

Tree View Creation

GtkTreeViewColumn * gnc_tree_view_add_toggle_column (GncTreeView *view, const gchar *column_title, const gchar *column_short_title, const gchar *pref_name, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn, renderer_toggled toggle_edited_cb)
 This function adds a new toggle column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_text_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a new text column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_text_view_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a new text view column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_pix_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a pixbuf view column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_combo_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeModel *combo_tree_model, gint combo_model_text_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a new combobox column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_date_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a new date column to a GncTreeView base view. More...
 
GtkTreeViewColumn * gnc_tree_view_add_numeric_column (GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_color_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
 This function adds a new numeric column to a GncTreeView base view. More...
 
gint gnc_tree_view_append_column (GncTreeView *view, GtkTreeViewColumn *column)
 Add a column to a view based upon a GncTreeView. More...
 

Tree View Properties

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. More...
 
GtkTreeViewColumn * gnc_tree_view_find_column_by_name (GncTreeView *view, const gchar *wanted)
 Find a tree column given the "pref name". More...
 
void gnc_tree_view_set_state_section (GncTreeView *view, const gchar *section)
 This function is called to set up or remove an association between a saved state section and the display of a view. More...
 
const gchar * gnc_tree_view_get_state_section (GncTreeView *view)
 This function is called to get the current association between a saved state section and the display of a view. More...
 
void gnc_tree_view_remove_state_information (GncTreeView *view)
 This function is called to completely wipe the treeview's state information (column visibility, width, sorting order,..). More...
 
void gnc_tree_view_save_state (GncTreeView *view)
 This function is called to write the treeview's state information (column visibility, width, sorting order,..) to the state file. More...
 
void gnc_tree_view_expand_columns (GncTreeView *view, gchar *first_column_name,...)
 This function set the columns that will be allocated the free space in the view. More...
 
void gnc_tree_view_set_control_column_background (GncTreeView *view, gint column, GtkTreeCellDataFunc func)
 This function links the cell backgrounds of the two control columns to a column in the model that has color strings or a cell data function that sets the "cell-background" property. More...
 
void gnc_tree_view_set_sort_user_data (GncTreeView *view, GtkTreeModel *s_model)
 This allows the columns to be setup without the model connected. More...
 
void gnc_tree_view_set_show_column_menu (GncTreeView *view, gboolean visible)
 This function is called to set the "show-column-menu" property on this view. More...
 
gboolean gnc_tree_view_get_show_column_menu (GncTreeView *view)
 This function is called to get the current value of the "show-column-menu" property. More...
 
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 convenience routines. More...
 
void gnc_tree_view_keynav (GncTreeView *view, GtkTreeViewColumn **col, GtkTreePath *path, GdkEventKey *event)
 
gboolean gnc_tree_view_path_is_valid (GncTreeView *view, GtkTreePath *path)
 
void gnc_tree_view_set_editing_started_cb (GncTreeView *view, GFunc editing_started_cb, gpointer editing_cb_data)
 Setup a callback for when the user starts editing so appropriate actions can be taken like disable the actions delete menu option.
 
void gnc_tree_view_set_editing_finished_cb (GncTreeView *view, GFunc editing_finished_cb, gpointer editing_cb_data)
 Setup a callback for when the user finishes editing so appropriate actions can be taken like enable the actions delete menu option.
 

Detailed Description

gnc-plugin-page-report.h – A GncPlugin page for a report.

Copyright (C) 2004 Joshua Sled Author: Joshua Sled jsled.nosp@m.@asy.nosp@m.nchro.nosp@m.nous.nosp@m..org

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, contact:

Free Software Foundation Voice: +1-617-542-5942 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 Boston, MA 02110-1301, USA gnu@g.nosp@m.nu.o.nosp@m.rg

Function Documentation

◆ build_contents()

void GncOptionsDialog::build_contents ( GncOptionDB odb,
bool  show_dialog 
)

Populate the dialog's notebook with the contents of odb.

Parameters
odb- option database to use *
show_dialog- should dialog be made visible or not *

Definition at line 335 of file dialog-options.cpp.

336 {
337  gint default_page = -1;
338 
339  g_return_if_fail (odb != NULL);
340 
341  m_option_db = odb;
342 
343  auto default_section = odb->get_default_section();
344 
345  PINFO("Default Section name is %s",
346  default_section ? default_section->get_name().c_str() : "NULL");
347 
348  odb->foreach_section(
349  [this, default_section, &default_page]
350  (GncOptionSectionPtr& section) {
351  auto page = dialog_append_page(this, section);
352  if (default_section && section.get() == default_section)
353  default_page = page;
354  });
355 
356  gtk_notebook_popup_enable(GTK_NOTEBOOK(m_notebook));
357  if (default_page >= 0)
358  {
359  /* Find the page list and set the selection to the default page */
360  auto selection{gtk_tree_view_get_selection(GTK_TREE_VIEW(m_page_list_view))};
361  GtkTreeIter iter;
362 
363  auto model{gtk_tree_view_get_model(GTK_TREE_VIEW(m_page_list_view))};
364  gtk_tree_model_iter_nth_child(model, &iter, NULL, default_page);
365  gtk_tree_selection_select_iter (selection, &iter);
366  gtk_notebook_set_current_page(GTK_NOTEBOOK(m_notebook), default_page);
367  }
368  dialog_changed_internal(m_window, FALSE);
369  if (show_dialog)
370  gtk_widget_show(m_window);
371 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256

◆ gnc_accounting_period_end_gdate()

GDate * gnc_accounting_period_end_gdate ( GncAccountingPeriod  which,
const GDate *  fy_end,
const GDate *  contains 
)

This function returns the ending date for an accounting period.

The date will be computed based upon the type of accounting interval requested, an optional fiscal year end value, and an optional time value.

Parameters
whichAn enum specifying the type of accounting period.
fy_endThis argument specifies the month and day of the fiscal year end. If the accounting period specified in the 'which' parameter is not a fiscal accounting period, this variable is ignored and may be NULL. Note: the year field of this argument is always ignored.
containsThis argument specifies the origin time value used by the calculations in this function. If this value is NULL, the origin will be the current time.
Returns
The final day of the specified time interval, as a GDate.

Definition at line 229 of file gnc-accounting-period.c.

232 {
233  GDate *date;
234 
235  if (contains)
236  {
237  date = g_date_new_dmy (g_date_get_day (contains),
238  g_date_get_month (contains),
239  g_date_get_year (contains));
240  }
241  else
242  {
243  date = g_date_new ();
244  gnc_gdate_set_today (date);
245  }
246 
247  switch (which)
248  {
249  default:
250  PINFO ("Undefined relative time constant %d", which);
251  g_date_free (date);
252  return 0;
253 
254  case GNC_ACCOUNTING_PERIOD_TODAY:
255  /* Already have today's date */
256  break;
257 
258  case GNC_ACCOUNTING_PERIOD_MONTH:
260  break;
261 
262  case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
264  break;
265 
266  case GNC_ACCOUNTING_PERIOD_QUARTER:
268  break;
269 
270  case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
272  break;
273 
274  case GNC_ACCOUNTING_PERIOD_CYEAR:
275  gnc_gdate_set_year_end (date);
276  break;
277 
278  case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
280  break;
281 
282  case GNC_ACCOUNTING_PERIOD_FYEAR:
283  if (fy_end == NULL)
284  {
285  PINFO ("Request for fisal year value but no fiscal year end value provided.");
286  g_date_free (date);
287  return 0;
288  }
289  gnc_gdate_set_fiscal_year_end (date, fy_end);
290  break;
291 
292  case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
293  if (fy_end == NULL)
294  {
295  PINFO ("Request for fisal year value but no fiscal year end value provided.");
296  g_date_free (date);
297  return 0;
298  }
299  gnc_gdate_set_prev_fiscal_year_end (date, fy_end);
300  break;
301  }
302 
303  return date;
304 }
void gnc_gdate_set_fiscal_year_end(GDate *date, const GDate *year_end)
This function modifies a GDate to set it to the last day of the fiscal year in which it falls...
Definition: gnc-date.cpp:1618
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
void gnc_gdate_set_today(GDate *gd)
Set a GDate to the current day.
Definition: gnc-date.cpp:1236
void gnc_gdate_set_prev_month_end(GDate *date)
This function modifies a GDate to set it to the last day of the month prior to the one in which it fa...
Definition: gnc-date.cpp:1513
void gnc_gdate_set_prev_year_end(GDate *date)
This function modifies a GDate to set it to the last day of the year prior to the one in which it fal...
Definition: gnc-date.cpp:1585
void gnc_gdate_set_prev_fiscal_year_end(GDate *date, const GDate *year_end)
This function modifies a GDate to set it to the last day of the fiscal year prior to the one in which...
Definition: gnc-date.cpp:1652
void gnc_gdate_set_year_end(GDate *date)
This function modifies a GDate to set it to the last day of the year in which it falls.
Definition: gnc-date.cpp:1571
void gnc_gdate_set_month_end(GDate *date)
This function modifies a GDate to set it to the last day of the month in which it falls...
Definition: gnc-date.cpp:1481
void gnc_gdate_set_quarter_end(GDate *date)
This function modifies a GDate to set it to the last day of the quarter in which it falls...
Definition: gnc-date.cpp:1536
void gnc_gdate_set_prev_quarter_end(GDate *date)
This function modifies a GDate to set it to the last day of the quarter prior to the one in which it ...
Definition: gnc-date.cpp:1555

◆ gnc_accounting_period_start_gdate()

GDate * gnc_accounting_period_start_gdate ( GncAccountingPeriod  which,
const GDate *  fy_end,
const GDate *  contains 
)

This function returns the starting date for an accounting period.

The date will be computed based upon the type of accounting interval requested, an optional fiscal year end value, and an optional time value.

Parameters
whichAn enum specifying the type of accounting period.
fy_endThis argument specifies the month and day of the fiscal year end. If the accounting period specified in the 'which' parameter is not a fiscal accounting period, this variable is ignored and may be NULL. Note: the year field of this argument is always ignored.
containsThis argument specifies the origin time value used by the calculations in this function. If this value is NULL, the origin will be the current time.
Returns
The starting day of the specified time interval, as a GDate.

Definition at line 135 of file gnc-accounting-period.c.

138 {
139  GDate *date;
140 
141  if (contains)
142  {
143  date = g_date_new_dmy (g_date_get_day (contains),
144  g_date_get_month (contains),
145  g_date_get_year (contains));
146  }
147  else
148  {
149  date = g_date_new ();
150  gnc_gdate_set_today (date);
151  }
152 
153  switch (which)
154  {
155  default:
156  PINFO ("Undefined relative time constant %d", which);
157  g_date_free (date);
158  return NULL;
159 
160  case GNC_ACCOUNTING_PERIOD_TODAY:
161  /* Already have today's date */
162  break;
163 
164  case GNC_ACCOUNTING_PERIOD_MONTH:
166  break;
167 
168  case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
170  break;
171 
172  case GNC_ACCOUNTING_PERIOD_QUARTER:
174  break;
175 
176  case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
178  break;
179 
180  case GNC_ACCOUNTING_PERIOD_CYEAR:
182  break;
183 
184  case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
186  break;
187 
188  case GNC_ACCOUNTING_PERIOD_FYEAR:
189  if (fy_end == NULL)
190  {
191  PINFO ("Request for fisal year value but no fiscal year end value provided.");
192  g_date_free (date);
193  return NULL;
194  }
195  gnc_gdate_set_fiscal_year_start (date, fy_end);
196  break;
197 
198  case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
199  if (fy_end == NULL)
200  {
201  PINFO ("Request for fisal year value but no fiscal year end value provided.");
202  g_date_free (date);
203  return NULL;
204  }
206  break;
207  }
208  return date;
209 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
void gnc_gdate_set_quarter_start(GDate *date)
This function modifies a GDate to set it to the first day of the quarter in which it falls...
Definition: gnc-date.cpp:1523
void gnc_gdate_set_today(GDate *gd)
Set a GDate to the current day.
Definition: gnc-date.cpp:1236
void gnc_gdate_set_prev_year_start(GDate *date)
This function modifies a GDate to set it to the first day of the year prior to the one in which it fa...
Definition: gnc-date.cpp:1578
void gnc_gdate_set_month_start(GDate *date)
This function modifies a GDate to set it to the first day of the month in which it falls...
Definition: gnc-date.cpp:1468
void gnc_gdate_set_fiscal_year_start(GDate *date, const GDate *year_end)
This function modifies a GDate to set it to the first day of the fiscal year in which it falls...
Definition: gnc-date.cpp:1594
void gnc_gdate_set_prev_fiscal_year_start(GDate *date, const GDate *year_end)
This function modifies a GDate to set it to the first day of the fiscal year prior to the one in whic...
Definition: gnc-date.cpp:1641
void gnc_gdate_set_prev_quarter_start(GDate *date)
This function modifies a GDate to set it to the first day of the quarter prior to the one in which it...
Definition: gnc-date.cpp:1548
void gnc_gdate_set_year_start(GDate *date)
This function modifies a GDate to set it to the first day of the year in which it falls...
Definition: gnc-date.cpp:1564
void gnc_gdate_set_prev_month_start(GDate *date)
This function modifies a GDate to set it to the first day of the month prior to the one in which it f...
Definition: gnc-date.cpp:1499

◆ gnc_period_select_get_active()

GncAccountingPeriod gnc_period_select_get_active ( GncPeriodSelect period)

Get the currently selected accounting period from a GncPeriodSelect widget.

This is used to retrieve the user's selection in the form of an enum.

Parameters
periodThe selection widget to query.
Returns
An enum indicating the user's choice of accounting period.

Definition at line 723 of file gnc-period-select.c.

724 {
725  GncPeriodSelectPrivate *priv;
726 
727  g_return_val_if_fail(period != NULL, -1);
728  g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), -1);
729 
730  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
731  return gtk_combo_box_get_active(GTK_COMBO_BOX(priv->selector));
732 }

◆ gnc_period_select_get_date()

GDate * gnc_period_select_get_date ( GncPeriodSelect period)

Get the currently selected accounting period choice from a GncPeriodSelect widget.

This is used to retrieve the user's selection in the form of a GDate.

Parameters
periodThe selection widget to query.
Returns
The starting/ending time.

Definition at line 740 of file gnc-period-select.c.

741 {
742  GncPeriodSelectPrivate *priv;
743  GncAccountingPeriod which;
744 
745  g_return_val_if_fail(period != NULL, 0);
746  g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), 0);
747 
748  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
749  which = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->selector));
750  if (which == -1)
751  return NULL;
752 
753  if (priv->start)
754  return gnc_accounting_period_start_gdate(which, priv->fy_end,
755  priv->date_base);
756  return gnc_accounting_period_end_gdate(which, priv->fy_end,
757  priv->date_base);
758 }
GncAccountingPeriod
This specifies a time interval.
GDate * gnc_accounting_period_end_gdate(GncAccountingPeriod which, const GDate *fy_end, const GDate *contains)
This function returns the ending date for an accounting period.
GDate * gnc_accounting_period_start_gdate(GncAccountingPeriod which, const GDate *fy_end, const GDate *contains)
This function returns the starting date for an accounting period.

◆ gnc_period_select_get_fy_end()

GDate * gnc_period_select_get_fy_end ( GncPeriodSelect period)

Get the current value of the fiscal year end setting from a GncPeriodSelect widget.

If the result is NULL then fiscal years are not currently supported.

Parameters
periodThe GncPeriodSelect widget to query.
Returns
A pointer to a GDate containing the fiscal year end value, or NULL if no fiscal year end is set. Note that only the month and day fields are valid in the returned GDate.

Definition at line 255 of file gnc-period-select.c.

256 {
257  GncPeriodSelectPrivate *priv;
258 
259  g_return_val_if_fail(period != NULL, NULL);
260  g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), NULL);
261 
262  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
263  if (!priv->fy_end)
264  return NULL;
265  return g_date_new_dmy(g_date_get_day(priv->fy_end),
266  g_date_get_month(priv->fy_end),
267  G_DATE_BAD_YEAR);
268 }

◆ gnc_period_select_new()

GtkWidget * gnc_period_select_new ( gboolean  starting_labels)

Create a new GncPeriodSelect widget which is used to select a accounting period like "previous month" or "this year".

Parameters
starting_labelsIf set to TRUE then all the labels will refer to the "Start of...". If FALSE, labels will refer to "End of...".
Returns
A newly created GncPeriodSelect widget.

Definition at line 639 of file gnc-period-select.c.

640 {
641  GncPeriodSelectPrivate *priv;
642  GncPeriodSelect *period;
643  const gchar *label;
644  gint i;
645 
646  period = g_object_new(GNC_TYPE_PERIOD_SELECT, NULL);
647 
648  /* Set up private data structures */
649  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
650  priv->selector = gtk_combo_box_text_new();
651  priv->start = starting_labels;
652 
653  /* Add the internal widgets to the hbox */
654  gtk_box_pack_start(GTK_BOX(period), priv->selector, TRUE, TRUE, 0);
655  gtk_widget_show(priv->selector);
656 
657  /* Find out when the combo box changes */
658  g_signal_connect(G_OBJECT(priv->selector), "changed",
659  G_CALLBACK(gnc_period_sample_combobox_changed), period);
660 
661  /* Build all the labels except the fiscal year labels */
662  for (i = 0; i < GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i++)
663  {
664  label = starting_labels ? _(start_strings[i]) : _(end_strings[i]);
665  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label);
666  }
667 
668  /* Track changes to date formatting */
669  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT,
670  gnc_period_sample_new_date_format, period);
671 
672  return GTK_WIDGET (period);
673 }
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
Definition: gnc-prefs.c:128

◆ gnc_period_select_new_glade()

GtkWidget * gnc_period_select_new_glade ( gchar *  widget_name,
gchar *  string1,
gchar *  string2,
gint  int1,
gint  int2 
)

Create a new GncPeriodSelect widget from a glade file.

The int1 argument passed from glade is used to determine whether the widget uses labels for start times or end times. A non-zero int2 argument indicates that an example date should be shown.

Returns
A newly created GncPeriodSelect widget.

Definition at line 682 of file gnc-period-select.c.

685 {
686  GtkWidget *widget;
687  widget = gnc_period_select_new(int1 != 0);
688  if (int2)
689  gnc_period_select_set_show_date(GNC_PERIOD_SELECT(widget), TRUE);
690  gtk_widget_show(widget);
691  return widget;
692 }
void gnc_period_select_set_show_date(GncPeriodSelect *period, const gboolean show_date)
Set the "show sample" setting on a GncPeriodSelect widget.
GtkWidget * gnc_period_select_new(gboolean starting_labels)
Create a new GncPeriodSelect widget which is used to select a accounting period like "previous month"...

◆ gnc_period_select_set_active()

void gnc_period_select_set_active ( GncPeriodSelect period,
GncAccountingPeriod  which 
)

Set which item in the GncPeriodSelect is initially selected.

This is used to set the initial selection before the widget is shown to the user.

Parameters
periodThe selection widget to update.
whichThe accounting period that should be selected.

Definition at line 706 of file gnc-period-select.c.

708 {
709  g_return_if_fail(period != NULL);
710  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
711  g_return_if_fail(which >= 0);
712  g_return_if_fail(which < GNC_ACCOUNTING_PERIOD_LAST);
713 
714  g_object_set (G_OBJECT (period), "active", which, NULL);
715 }

◆ gnc_period_select_set_fy_end()

void gnc_period_select_set_fy_end ( GncPeriodSelect period,
const GDate *  fy_end 
)

Set the fiscal year end on a GncPeriodSelect widget.

If set to a value other than NULL then widget will include fiscal accounting period like "this fiscal year".

Parameters
periodThe GncPeriodSelect widget to update.
fy_endThe new fiscal year end value, or NULL if no fiscal year is set. Note that only the month and day fields need be valid in the provided GDate.

Definition at line 276 of file gnc-period-select.c.

277 {
278  GncPeriodSelectPrivate *priv;
279  const gchar *label;
280  gint i;
281 
282  g_return_if_fail(period != NULL);
283  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
284 
285  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
286  if (priv->fy_end)
287  g_date_free(priv->fy_end);
288 
289  if (fy_end)
290  {
291  priv->fy_end = g_date_new_dmy(g_date_get_day(fy_end),
292  g_date_get_month(fy_end),
293  G_DATE_BAD_YEAR);
294  }
295  else
296  {
297  priv->fy_end = NULL;
298  }
299 
300  if (fy_end)
301  {
302  for (i = GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i < GNC_ACCOUNTING_PERIOD_FYEAR_LAST; i++)
303  {
304  label = priv->start ? _(start_strings[i]) : _(end_strings[i]);
305  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label);
306  }
307  }
308  else
309  {
310  for (i = GNC_ACCOUNTING_PERIOD_FYEAR_LAST - 1; i >= GNC_ACCOUNTING_PERIOD_FYEAR_LAST; i--)
311  {
312  gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(priv->selector), i);
313  }
314  }
315 }

◆ gnc_period_select_set_show_date()

void gnc_period_select_set_show_date ( GncPeriodSelect period,
const gboolean  show_date 
)

Set the "show sample" setting on a GncPeriodSelect widget.

If set to TRUE then a GtkLabel will be used to show the date corresponding to the selected time period.

Definition at line 372 of file gnc-period-select.c.

373 {
374  GDate date;
375 
376  g_return_if_fail(period != NULL);
377  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
378 
379  if (show_date)
380  {
381  g_date_clear(&date, 1);
382  gnc_gdate_set_time64(&date, gnc_time (NULL));
383  gnc_period_select_set_date_common(period, &date);
384  }
385  else
386  {
387  gnc_period_select_set_date_common(period, NULL);
388  }
389 }
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
Definition: gnc-date.cpp:1244
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:270

◆ gnc_tree_view_add_combo_column()

GtkTreeViewColumn* gnc_tree_view_add_combo_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeModel *  combo_tree_model,
gint  combo_model_text_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a new combobox column to a GncTreeView base view.

The parameters it takes in common with gnc_tree_view_add_text_column() behave the same as there. In addition, it will use combo_tree_model as the GtkTreeModel for the combobox, and combo_model_text_column will be the column in the model used for displaying the text in the combobox.

Definition at line 2097 of file gnc-tree-view.c.

2106 {
2107  GtkTreeViewColumn *column;
2108  GtkCellRenderer *renderer;
2109  PangoLayout* layout;
2110  int default_width, title_width;
2111 
2112  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
2113 
2114  column = gtk_tree_view_column_new ();
2115  gtk_tree_view_column_set_title (column, gettext(column_title));
2116 
2117  /* Set up a renderer and attributes */
2118  renderer = gtk_cell_renderer_combo_new ();
2119  gtk_tree_view_column_pack_start (column, renderer, TRUE);
2120 
2121  /* Set renderer attributes controlled by the model */
2122  if (model_data_column != GNC_TREE_VIEW_COLUMN_DATA_NONE)
2123  gtk_tree_view_column_add_attribute (column, renderer,
2124  "text", model_data_column);
2125  if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
2126  gtk_tree_view_column_add_attribute (column, renderer,
2127  "visible", model_visibility_column);
2128 
2129  /* Default size is the larger of the column title and the sizing text */
2130  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
2131  pango_layout_get_pixel_size (layout, &title_width, NULL);
2132  g_object_unref (layout);
2133  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
2134  pango_layout_get_pixel_size (layout, &default_width, NULL);
2135  g_object_unref (layout);
2136  default_width = MAX(default_width, title_width);
2137  if (default_width)
2138  default_width += 10; /* padding on either side */
2139 
2140  gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
2141  default_width, TRUE, column_sort_fn);
2142 
2143  /* Stuff specific to combo */
2144  if (combo_tree_model)
2145  {
2146  g_object_set (G_OBJECT(renderer), "model", combo_tree_model,
2147  "text-column", combo_model_text_column, NULL);
2148  }
2149  /* TODO: has-entry? */
2150 
2151  gnc_tree_view_append_column (view, column);
2152  return column;
2153 }
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.

◆ gnc_tree_view_add_date_column()

GtkTreeViewColumn* gnc_tree_view_add_date_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  icon_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a new date column to a GncTreeView base view.

The parameters it takes in common with gnc_tree_view_add_text_column() behave the same as there.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered.

Parameters are defined in gnc-tree-view.h

Definition at line 2039 of file gnc-tree-view.c.

2047 {
2048  GtkTreeViewColumn *column;
2049  GtkCellRenderer *renderer;
2050  PangoLayout* layout;
2051  int default_width, title_width;
2052 
2053  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
2054 
2055  column = gtk_tree_view_column_new ();
2056  gtk_tree_view_column_set_title (column, column_title);
2057 
2058  /* Set up an icon renderer if requested */
2059  if (icon_name)
2060  {
2061  renderer = gtk_cell_renderer_pixbuf_new ();
2062  g_object_set (renderer, "icon-name", icon_name, NULL);
2063  gtk_tree_view_column_pack_start (column, renderer, FALSE);
2064  }
2065 
2066  /* Set up a text renderer and attributes */
2067  renderer = gnc_cell_renderer_date_new (TRUE);
2068  gtk_tree_view_column_pack_start (column, renderer, TRUE);
2069 
2070  /* Set renderer attributes controlled by the model */
2071  if (model_data_column != GNC_TREE_VIEW_COLUMN_DATA_NONE)
2072  gtk_tree_view_column_add_attribute (column, renderer,
2073  "text", model_data_column);
2074  if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
2075  gtk_tree_view_column_add_attribute (column, renderer,
2076  "visible", model_visibility_column);
2077 
2078  /* Default size is the larger of the column title and the sizing text */
2079  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
2080  pango_layout_get_pixel_size (layout, &title_width, NULL);
2081  g_object_unref (layout);
2082  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
2083  pango_layout_get_pixel_size (layout, &default_width, NULL);
2084  g_object_unref (layout);
2085  default_width = MAX(default_width, title_width);
2086  if (default_width)
2087  default_width += 10; /* padding on either side */
2088  gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
2089  default_width, TRUE, column_sort_fn);
2090 
2091  gnc_tree_view_append_column (view, column);
2092  return column;
2093 }
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.

◆ gnc_tree_view_add_numeric_column()

GtkTreeViewColumn* gnc_tree_view_add_numeric_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_color_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a new numeric column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. A numeric column is nothing more then a text column with a few extra attributes.

Parameters
viewA pointer to a generic GncTreeView.
column_titleThe title for this column.
pref_nameThe internal name of this column. This name is used in several functions to look up the column, and it is also used when saving/restoring the view's state.
sizing_textA string used to compute the default width of the column. This text is never displayed.
model_data_columnThe index of the GtkTreeModel data column used to determine the data that will be displayed in this column for each row in the view. Use GNC_TREE_VIEW_COLUMN_DATA_NONE if you plan on using an non-model data source for this column.
model_color_columnThe index of the GtkTreeModel data column used to determine the foreground color of any text in this column. It should be used to display negative numbers in red. Use GNC_TREE_VIEW_COLUMN_COLOR_NONE if the text in this column should always be displayed in the default theme color for text.
model_visibility_columnThe index of the GtkTreeModel data column used to determine whether or not a checkbox for each row will be displayed at all. Use GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS if the checkbox should be displayed in all rows.
column_sort_fnThe function that GtkTreeModelSort will call to compare two rows to determine their displayed order.
Returns
The newly created GtkTreeViewColumn.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered. A numeric column is nothing more then a text column with a few extra attributes.

Parameters are defined in gnc-tree-view.h

Definition at line 2183 of file gnc-tree-view.c.

2191 {
2192  GtkTreeViewColumn *column;
2193  GtkCellRenderer *renderer;
2194  gfloat alignment = 1.0;
2195 
2196  column = gnc_tree_view_add_text_column (view, column_title, pref_name,
2197  NULL, sizing_text, model_data_column,
2198  model_visibility_column,
2199  column_sort_fn);
2200 
2201  renderer = gnc_tree_view_column_get_renderer (column);
2202 
2203  /* Right align the column title and data for both ltr and rtl */
2204  if (gtk_widget_get_direction (GTK_WIDGET(view)) == GTK_TEXT_DIR_RTL)
2205  alignment = 0.0;
2206 
2207  g_object_set (G_OBJECT(column), "alignment", alignment, NULL);
2208  g_object_set (G_OBJECT(renderer), "xalign", alignment, NULL);
2209 
2210  /* Change the text color */
2211  if (model_color_column != GNC_TREE_VIEW_COLUMN_COLOR_NONE)
2212  gtk_tree_view_column_add_attribute (column, renderer,
2213  "foreground", model_color_column);
2214 
2215  return column;
2216 }
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_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text column to a GncTreeView base view.

◆ gnc_tree_view_add_pix_column()

GtkTreeViewColumn* gnc_tree_view_add_pix_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a pixbuf view column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn.

Parameters
viewA pointer to a generic GncTreeView.
column_titleThe title for this column.
pref_nameThe internal name of this column. This name is used in several functions to look up the column, and it is also used when saving/restoring the view's state.
sizing_textA string used to compute the default width of the column. This text is never displayed.
model_data_columnThe index of the GtkTreeModel data column used to determine the data that will be displayed in this column for each row in the view. Use GNC_TREE_VIEW_COLUMN_DATA_NONE if you plan on using a non-model data source for this column. This index is connected to the "icon-name" attribute of the cell renderer.
model_visibility_columnThe index of the GtkTreeModel data column used to determine whether or not a checkbox for each row will be displayed at all. Use GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS if the checkbox should be displayed in all rows.
column_sort_fnThe function that GtkTreeModelSort will call to compare two rows to determine their displayed order.
Returns
The newly created GtkTreeViewColumn.

This function adds a pixbuf view column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered.

Parameters are defined in gnc-tree-view.h

Definition at line 1981 of file gnc-tree-view.c.

1988 {
1989  GtkTreeViewColumn *column;
1990  PangoLayout* layout;
1991  int default_width, title_width;
1992  GtkCellRenderer *renderer;
1993 
1994  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1995 
1996  renderer = gtk_cell_renderer_pixbuf_new ();
1997 
1998  column = gtk_tree_view_column_new ();
1999  gtk_tree_view_column_set_title (column, column_title);
2000 
2001  /* Set up a text renderer and attributes */
2002  gtk_tree_view_column_pack_start (column, renderer, TRUE);
2003 
2004  /* Set renderer attributes controlled by the model */
2005  if (model_data_column != GNC_TREE_VIEW_COLUMN_DATA_NONE)
2006  gtk_tree_view_column_add_attribute (column, renderer,
2007  "icon-name", model_data_column);
2008  if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
2009  gtk_tree_view_column_add_attribute (column, renderer,
2010  "visible", model_visibility_column);
2011 
2012  /* Default size is the larger of the column title and the sizing text */
2013  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
2014  pango_layout_get_pixel_size (layout, &title_width, NULL);
2015  g_object_unref (layout);
2016  layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
2017  pango_layout_get_pixel_size (layout, &default_width, NULL);
2018  g_object_unref (layout);
2019  default_width = MAX(default_width, title_width);
2020  if (default_width)
2021  default_width += 10; /* padding on either side */
2022  gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
2023  default_width, TRUE, column_sort_fn);
2024 
2025  gnc_tree_view_append_column (view, column);
2026  return column;
2027 }
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.

◆ gnc_tree_view_add_text_column()

GtkTreeViewColumn* gnc_tree_view_add_text_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  icon_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a new text column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn.

Parameters
viewA pointer to a generic GncTreeView.
column_titleThe title for this column.
pref_nameThe internal name of this column. This name is used in several functions to look up the column, and it is also used when saving/restoring the view's state.
icon_nameThe name of the icon to display to the left of the text in this column. Used for adding icons like the "account" icon to a view. This must be a registered icon, not a filename.
sizing_textA string used to compute the default width of the column. This text is never displayed.
model_data_columnThe index of the GtkTreeModel data column used to determine the data that will be displayed in this column for each row in the view. Use GNC_TREE_VIEW_COLUMN_DATA_NONE if you plan on using a non-model data source for this column. This index is connected to the "text" attribute of the cell renderer.
model_visibility_columnThe index of the GtkTreeModel data column used to determine whether or not a checkbox for each row will be displayed at all. Use GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS if the checkbox should be displayed in all rows.
column_sort_fnThe function that GtkTreeModelSort will call to compare two rows to determine their displayed order.
Returns
The newly created GtkTreeViewColumn.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered.

Parameters are defined in gnc-tree-view.h

Definition at line 1917 of file gnc-tree-view.c.

1925 {
1926  GtkCellRenderer *renderer;
1927 
1928  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1929 
1930  renderer = gtk_cell_renderer_text_new ();
1931 
1932  return add_text_column_variant (view, renderer,
1933  column_title, pref_name,
1934  icon_name, sizing_text,
1935  model_data_column,
1936  model_visibility_column,
1937  column_sort_fn);
1938 }

◆ gnc_tree_view_add_text_view_column()

GtkTreeViewColumn* gnc_tree_view_add_text_view_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  pref_name,
const gchar *  icon_name,
const gchar *  sizing_text,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn 
)

This function adds a new text view column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn.

Parameters
viewA pointer to a generic GncTreeView.
column_titleThe title for this column.
pref_nameThe internal name of this column. This name is used in several functions to look up the column, and it is also used when saving/restoring the view's state.
icon_nameThe name of the icon to display to the left of the text in this column. Used for adding icons like the "account" icon to a view. This must be a registered icon, not a filename.
sizing_textA string used to compute the default width of the column. This text is never displayed.
model_data_columnThe index of the GtkTreeModel data column used to determine the data that will be displayed in this column for each row in the view. Use GNC_TREE_VIEW_COLUMN_DATA_NONE if you plan on using a non-model data source for this column. This index is connected to the "text" attribute of the cell renderer.
model_visibility_columnThe index of the GtkTreeModel data column used to determine whether or not a checkbox for each row will be displayed at all. Use GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS if the checkbox should be displayed in all rows.
column_sort_fnThe function that GtkTreeModelSort will call to compare two rows to determine their displayed order.
Returns
The newly created GtkTreeViewColumn.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered.

Parameters are defined in gnc-tree-view.h

Definition at line 1949 of file gnc-tree-view.c.

1957 {
1958  GtkCellRenderer *renderer;
1959 
1960  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1961 
1962  renderer = gnc_cell_renderer_text_view_new ();
1963 
1964  return add_text_column_variant (view, renderer,
1965  column_title, pref_name,
1966  icon_name, sizing_text,
1967  model_data_column,
1968  model_visibility_column,
1969  column_sort_fn);
1970 }

◆ gnc_tree_view_add_toggle_column()

GtkTreeViewColumn* gnc_tree_view_add_toggle_column ( GncTreeView view,
const gchar *  column_title,
const gchar *  column_short_title,
const gchar *  pref_name,
gint  model_data_column,
gint  model_visibility_column,
GtkTreeIterCompareFunc  column_sort_fn,
renderer_toggled  toggle_edited_cb 
)

This function adds a new toggle column to a GncTreeView base view.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. It handles creating a tooltip to show the full title name, and setting the sort and edit callback functions.

Parameters
viewA pointer to a generic GncTreeView.
column_titleThe full title for this column. This will be added as a tooltip what will be displayed when the mouse is hovered over the column title button.
column_short_titleThis is what will actually be displayed as the title of the column. This should be a single character, as anything more will unnecessarily expand the width of the column.
pref_nameThe internal name of this column. This name is used in several functions to look up the column, and it is also used when saving/restoring the view's state.
model_data_columnThe index of the GtkTreeModel data column used to determine whether the displayed checkbox for each row will be show as checked or empty. Use GNC_TREE_VIEW_COLUMN_DATA_NONE if you plan on using an non-model data source for this column.
model_visibility_columnThe index of the GtkTreeModel data column used to determine whether or not a checkbox for each row will be displayed at all. Use GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS if the checkbox should be displayed in all rows.
column_sort_fnThe function that GtkTreeModelSort will call to compare two rows to determine their displayed order.
toggle_edited_cbThe function to call when the user toggles the state of a checkbox.
Returns
The newly created GtkTreeViewColumn.

It takes all the parameters necessary to hook a GtkTreeModel column to a GtkTreeViewColumn. It handles creating a tooltip to show the full title name, and setting the sort and edit callback functions. If the tree has a state section associated with it, this function also wires up the column so that its visibility and width are remembered.

Parameters are defined in gnc-tree-view.h

Definition at line 1764 of file gnc-tree-view.c.

1772 {
1773  GtkTreeViewColumn *column;
1774  GtkCellRenderer *renderer;
1775 
1776  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1777 
1778  renderer = gtk_cell_renderer_toggle_new ();
1779  if (!toggle_edited_cb)
1780  {
1781  gtk_cell_renderer_toggle_set_activatable (GTK_CELL_RENDERER_TOGGLE(renderer), FALSE);
1782  }
1783  column =
1784  gtk_tree_view_column_new_with_attributes (column_short_title,
1785  renderer,
1786  "active", model_data_column,
1787  NULL);
1788 
1789  /* Add the full title to the object for menu creation */
1790  g_object_set_data_full (G_OBJECT(column), REAL_TITLE,
1791  g_strdup(column_title), g_free);
1792  if (toggle_edited_cb)
1793  g_signal_connect (G_OBJECT(renderer), "toggled",
1794  G_CALLBACK(toggle_edited_cb), view);
1795 
1796  if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
1797  gtk_tree_view_column_add_attribute (column, renderer,
1798  "visible", model_visibility_column);
1799 
1800 
1801  gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
1802  0, FALSE, column_sort_fn);
1803 
1804  gnc_tree_view_append_column (view, column);
1805 
1806  /* Also add the full title to the object as a tooltip */
1807  gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (column), column_title);
1808 
1809  return column;
1810 }
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.

◆ gnc_tree_view_append_column()

gint gnc_tree_view_append_column ( GncTreeView view,
GtkTreeViewColumn *  column 
)

Add a column to a view based upon a GncTreeView.

This function knows about the two special columns on the right side of this type of view, and adds the new column before these two columns. You could say that it appends to the data columns and ignores the infrastructure columns.

Parameters
viewA pointer to a generic GncTreeView.
columnThe column to append.
Returns
The index of the newly added column.

This function knows about the two special columns on the right side of this type of view, and adds the new column before these two columns. You could say that it appends to the data columns and ignores the infrastructure columns.

Parameters are defined in gnc-tree-view.h

Definition at line 2227 of file gnc-tree-view.c.

2229 {
2230  int n = gtk_tree_view_get_n_columns (GTK_TREE_VIEW(view));
2231 
2232  /* Ignore the initial column, the selection menu */
2233  if (n >= 1)
2234  n -= 1;
2235  return gtk_tree_view_insert_column (GTK_TREE_VIEW(view), column, n);
2236 }

◆ gnc_tree_view_column_get_renderer()

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 convenience routines.

Parameters
columnThe tree view column that was added to the GncTreeView
Returns
The cell renderer in use in the column.

Definition at line 2156 of file gnc-tree-view.c.

2157 {
2158  GList *renderers;
2159  GtkCellRenderer *cr = NULL;
2160 
2161  g_return_val_if_fail (GTK_TREE_VIEW_COLUMN(column), NULL);
2162 
2163  /* Get the list of one renderer */
2164  renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(column));
2165  if (g_list_length (renderers) > 0)
2166  cr = GTK_CELL_RENDERER(renderers->data);
2167  g_list_free (renderers);
2168 
2169  return cr;
2170 }

◆ gnc_tree_view_configure_columns()

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.

Parameters
viewA pointer to an gnc tree view.

Definition at line 1594 of file gnc-tree-view.c.

1595 {
1596  GncTreeViewPrivate *priv;
1597  GtkTreeViewColumn *column;
1598  GList *columns;
1599  gboolean hide_menu_column;
1600 
1601  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1602 
1603  ENTER(" ");
1604 
1605  /* Update the view and saved state */
1606  columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1607  g_list_foreach (columns, (GFunc)gnc_tree_view_update_visibility, view);
1608  g_list_free (columns);
1609 
1610  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1611  if (priv->state_section)
1612  priv->seen_state_visibility = TRUE;
1613 
1614  /* If only the first column is visible, hide the spacer and make that
1615  * column expand. */
1616  hide_menu_column = (gnc_tree_view_count_visible_columns (view) == 1);
1617  column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), 0);
1618  gtk_tree_view_column_set_expand (column, hide_menu_column);
1619  gtk_tree_view_column_set_visible (priv->column_menu_column, !hide_menu_column);
1620 
1621  LEAVE(" ");
1622 }
#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
Private Data Structure.

◆ gnc_tree_view_expand_columns()

void gnc_tree_view_expand_columns ( GncTreeView view,
gchar *  first_column_name,
  ... 
)

This function set the columns that will be allocated the free space in the view.

Parameters
viewThe tree view.
listof column names.

Definition at line 1429 of file gnc-tree-view.c.

1432 {
1433  GtkTreeViewColumn *column;
1434  GList *columns, *tmp;
1435  gchar *name, *pref_name;
1436  va_list args;
1437 
1438  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1439  ENTER(" ");
1440  va_start (args, first_column_name);
1441  name = first_column_name;
1442 
1443  /* First disable the expand property on all (non-infrastructure) columns. */
1444  columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1445  for (tmp = columns; tmp; tmp = g_list_next (tmp))
1446  {
1447  column = tmp->data;
1448  pref_name = g_object_get_data (G_OBJECT(column), PREF_NAME);
1449  if (pref_name != NULL)
1450  gtk_tree_view_column_set_expand (column, FALSE);
1451  }
1452  g_list_free(columns);
1453 
1454  /* Now enable it on the requested columns. */
1455  while (name != NULL)
1456  {
1457  column = gnc_tree_view_find_column_by_name (view, name);
1458  if (column != NULL)
1459  {
1460  gtk_tree_view_column_set_expand (column, TRUE);
1461  }
1462  name = va_arg (args, gchar*);
1463  }
1464  va_end (args);
1465 
1466  LEAVE(" ");
1467 }
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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ gnc_tree_view_find_column_by_name()

GtkTreeViewColumn* gnc_tree_view_find_column_by_name ( GncTreeView view,
const gchar *  wanted 
)

Find a tree column given the "pref name".

This function simply runs the list of all (visible and invisible) columns looking for a match. Column names were attached to each column at the time the column was created.

Parameters
viewThe visible tree widget.
wantedThe "pref name" to find.

Find a tree column given the "pref name".

This function simply runs the list of all (visible and invisible) columns looking for a match. Column names were attached to each column at the time the column was created.

Parameters
viewThe visible tree widget.
wantedThe "pref name" to find.

Definition at line 535 of file gnc-tree-view.c.

537 {
538  GtkTreeViewColumn *column, *found = NULL;
539  GList *column_list, *tmp;
540  const gchar *name;
541 
542  // ENTER("view %p, wanted %s", view, wanted);
543  column_list = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
544  for (tmp = column_list; tmp; tmp = g_list_next (tmp))
545  {
546  column = tmp->data;
547  name = g_object_get_data (G_OBJECT(column), PREF_NAME);
548  if (!name || (strcmp(name, wanted) != 0))
549  continue;
550  found = column;
551  break;
552  }
553  g_list_free (column_list);
554 
555  // LEAVE("column %p", found);
556  return found;
557 }

◆ gnc_tree_view_get_show_column_menu()

gboolean gnc_tree_view_get_show_column_menu ( GncTreeView view)

This function is called to get the current value of the "show-column-menu" property.

It returns the same value passed to gnc_tree_view_set_show_menu_column().

Parameters
viewThe tree view.
Returns
Whether or not the column selection menu should be shown.

It returns the same value passed to gnc_tree_view_set_show_menu_column().

Parameters are defined in gnc-tree-view.h

Definition at line 1558 of file gnc-tree-view.c.

1559 {
1560  GncTreeViewPrivate *priv;
1561 
1562  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), FALSE);
1563 
1564  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1565  return (priv->show_column_menu);
1566 }
Private Data Structure.

◆ gnc_tree_view_get_state_section()

const gchar* gnc_tree_view_get_state_section ( GncTreeView view)

This function is called to get the current association between a saved state section and the display of a view.

It returns the same value passed to gnc_tree_view_set_state_section().

Parameters
viewThe tree view.
Returns
The current state section.

This function is called to get the current association between a saved state section and the display of a view.

It returns the same value passed to gnc_tree_view_set_state_section(); i.e. a string like "dialogs/edit_prices".

Parameters are defined in gnc-tree-view.h

Definition at line 1121 of file gnc-tree-view.c.

1122 {
1123  GncTreeViewPrivate *priv;
1124 
1125  g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1126 
1127  priv = GNC_TREE_VIEW_GET_PRIVATE (view);
1128  return priv->state_section;
1129 }
Private Data Structure.

◆ gnc_tree_view_remove_state_information()

void gnc_tree_view_remove_state_information ( GncTreeView view)

This function is called to completely wipe the treeview's state information (column visibility, width, sorting order,..).

This function may be called at any time; either when the user wants to disconnect or when the view object is being destroyed.

Parameters
viewThe tree view.

This function is called to completely wipe the treeview's state information (column visibility, width, sorting order,..).

This function may be called at any time; either when the user wants to disconnect or when the view object is being destroyed.

Parameters
viewThe tree view.

Definition at line 979 of file gnc-tree-view.c.

980 {
981  GncTreeViewPrivate *priv;
982  GKeyFile *state_file = gnc_state_get_current ();
983 
984  ENTER(" ");
985  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
986  if (!priv->state_section)
987  {
988  LEAVE("no state section");
989  return;
990  }
991 
992  g_key_file_remove_group (state_file, priv->state_section, NULL);
993  g_free (priv->state_section);
994  priv->state_section = NULL;
995  LEAVE(" ");
996 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition: gnc-state.c:248
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
Private Data Structure.

◆ gnc_tree_view_save_state()

void gnc_tree_view_save_state ( GncTreeView view)

This function is called to write the treeview's state information (column visibility, width, sorting order,..) to the state file.

Parameters
viewThe tree view.

Definition at line 1131 of file gnc-tree-view.c.

1132 {
1133  GncTreeViewPrivate *priv;
1134 
1135  ENTER("view %p", view);
1136  g_return_if_fail (view != NULL);
1137  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1138 
1139  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1140 
1141  if (priv->state_section)
1142  {
1143  /* Save state. Only store non-default values when possible. */
1144  GList *column_list, *tmp;
1145  GKeyFile *state_file = gnc_state_get_current();
1146  gsize num_cols = 0;
1147  gchar *sort_column = gnc_tree_view_get_sort_column (view);
1148  gchar *sort_order = gnc_tree_view_get_sort_order (view);
1149  gchar **col_order = gnc_tree_view_get_column_order (view, &num_cols);
1150 
1151  /* Default sort column is the name column */
1152  if (sort_column && (g_strcmp0 (sort_column, "name") != 0))
1153  g_key_file_set_string (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, sort_column);
1154  else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, NULL))
1155  g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, NULL);
1156  g_free (sort_column);
1157 
1158 
1159  /* Default sort order is "ascending" */
1160  if (g_strcmp0 (sort_order, "descending") == 0)
1161  g_key_file_set_string (state_file, priv->state_section, STATE_KEY_SORT_ORDER, sort_order);
1162  else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_SORT_ORDER, NULL))
1163  g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_SORT_ORDER, NULL);
1164  g_free (sort_order);
1165 
1166  if (col_order && (num_cols > 0))
1167  g_key_file_set_string_list (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER,
1168  (const gchar**) col_order, num_cols);
1169  else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER, NULL))
1170  g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER, NULL);
1171 
1172  g_strfreev (col_order);
1173 
1174 
1175  // ENTER("view %p, wanted %s", view, wanted);
1176  column_list = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1177  for (tmp = column_list; tmp; tmp = g_list_next (tmp))
1178  {
1179  GtkTreeViewColumn *column = tmp->data;
1180  gchar *key=NULL;
1181  const gchar *name = g_object_get_data (G_OBJECT(column), PREF_NAME);
1182  if (!name)
1183  continue;
1184 
1185  if (!g_object_get_data (G_OBJECT(column), ALWAYS_VISIBLE))
1186  {
1187  key = g_strjoin ("_", name, STATE_KEY_SUFF_VISIBLE, NULL);
1188  g_key_file_set_boolean (state_file, priv->state_section, key,
1189  gtk_tree_view_column_get_visible (column));
1190  g_free (key);
1191  }
1192 
1193  key = g_strjoin ("_", name, STATE_KEY_SUFF_WIDTH, NULL);
1194  if (g_object_get_data (G_OBJECT(column), "default-width") &&
1195  (GPOINTER_TO_INT((g_object_get_data (G_OBJECT(column), "default-width")))
1196  != gtk_tree_view_column_get_width (column)))
1197  {
1198  g_key_file_set_integer (state_file, priv->state_section, key,
1199  gtk_tree_view_column_get_width (column));
1200  }
1201  else if (g_key_file_has_key (state_file, priv->state_section, key, NULL))
1202  g_key_file_remove_key (state_file, priv->state_section, key, NULL);
1203  g_free (key);
1204  }
1205  g_list_free (column_list);
1206  }
1207 
1208  LEAVE(" ");
1209 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition: gnc-state.c:248
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
Private Data Structure.

◆ gnc_tree_view_set_control_column_background()

void gnc_tree_view_set_control_column_background ( GncTreeView view,
gint  column,
GtkTreeCellDataFunc  func 
)

This function links the cell backgrounds of the two control columns to a column in the model that has color strings or a cell data function that sets the "cell-background" property.

Parameters
viewThe tree view.
columnThe column in the model containing color strings.
funcThis is a cell data function that sets the "cell-background".

Definition at line 1498 of file gnc-tree-view.c.

1499 {
1500  GncTreeViewPrivate *priv;
1501 
1502  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1503 
1504  ENTER("view %p, column %d, func %p", view, column, func);
1505  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1506 
1507  update_control_cell_renderers_background (view, priv->column_menu_column, column, func);
1508 
1509  LEAVE(" ");
1510 }
#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
Private Data Structure.

◆ gnc_tree_view_set_show_column_menu()

void gnc_tree_view_set_show_column_menu ( GncTreeView view,
gboolean  visible 
)

This function is called to set the "show-column-menu" property on this view.

This function has no visible effect if the "state-section" property has not been set.

Parameters
viewThe tree view.
visibleCreate the column selection menu if TRUE.

This function has no visible effect if the "state-section" property has not been set.

Parameters are defined in gnc-tree-view.h

Definition at line 1537 of file gnc-tree-view.c.

1539 {
1540  GncTreeViewPrivate *priv;
1541 
1542  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1543 
1544  ENTER("view %p, show menu %d", view, visible);
1545  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1546  priv->show_column_menu = visible;
1547  gnc_tree_view_build_column_menu (view);
1548  LEAVE(" ");
1549 }
#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
Private Data Structure.

◆ gnc_tree_view_set_sort_user_data()

void gnc_tree_view_set_sort_user_data ( GncTreeView view,
GtkTreeModel *  s_model 
)

This allows the columns to be setup without the model connected.

Parameters
viewThe tree view.
sortmodel.

Definition at line 1516 of file gnc-tree-view.c.

1517 {
1518  GncTreeViewPrivate *priv;
1519 
1520  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1521 
1522  ENTER("view %p, sort_model %p", view, s_model);
1523  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1524 
1525  priv->sort_model = s_model;
1526  LEAVE(" ");
1527 }
#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
Private Data Structure.

◆ gnc_tree_view_set_state_section()

void gnc_tree_view_set_state_section ( GncTreeView view,
const gchar *  section 
)

This function is called to set up or remove an association between a saved state section and the display of a view.

It will first remove any existing association, and then install the new one.

Note
This function currently marks the first column as autosized and all other columns as fixed size. This may change in the future. It must change if we want to take advantage of the "fixed row height" performance enhancements added to GtkTreeView in gtk-2.4
Parameters
viewThe tree view.
sectionLink the view to this saved state section. Use NULL to disconnect saved state association.

This function is called to set up or remove an association between a saved state section and the display of a view.

It will first remove any existing association, and then install the new one. If the new section has state information, update the view with this information.

Parameters are defined in gnc-tree-view.h

Definition at line 1006 of file gnc-tree-view.c.

1008 {
1009  GncTreeViewPrivate *priv;
1010  GKeyFile *state_file;
1011 
1012  g_return_if_fail (GNC_IS_TREE_VIEW(view));
1013 
1014  ENTER("view %p, section %s", view, section);
1015 
1016  priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1017 
1018  /* Drop any previous state section */
1019  if (priv->state_section)
1021 
1022  if (!section)
1023  {
1024  LEAVE("cleared state section");
1025  return;
1026  }
1027 
1028  /* Catch changes in state. Propagate to view. */
1029  priv->state_section = g_strdup (section);
1030 
1031  state_file = gnc_state_get_current ();
1032  if (g_key_file_has_group (state_file, priv->state_section))
1033  {
1034  gsize num_keys, idx;
1035  gchar **keys = g_key_file_get_keys (state_file, priv->state_section, &num_keys, NULL);
1036  for (idx = 0; idx < num_keys; idx++)
1037  {
1038  gchar *key = keys[idx];
1039  if (g_strcmp0 (key, STATE_KEY_SORT_COLUMN) == 0)
1040  {
1041  gchar *name = g_key_file_get_string (state_file, priv->state_section,
1042  key, NULL);
1043  gnc_tree_view_set_sort_column (view, name);
1044  g_free (name);
1045  }
1046  else if (g_strcmp0 (key, STATE_KEY_SORT_ORDER) == 0)
1047  {
1048  gchar *name = g_key_file_get_string (state_file, priv->state_section,
1049  key, NULL);
1050  gnc_tree_view_set_sort_order (view, name);
1051  g_free (name);
1052  }
1053  else if (g_strcmp0 (key, STATE_KEY_COLUMN_ORDER) == 0)
1054  {
1055  gsize length;
1056  gchar **columns = g_key_file_get_string_list (state_file, priv->state_section,
1057  key, &length, NULL);
1058  gnc_tree_view_set_column_order (view, columns, length);
1059  g_strfreev (columns);
1060  }
1061  else
1062  {
1063  /* Make a copy of the local part of the key so it can be split
1064  * into column name and key type */
1065  gboolean known = FALSE;
1066  gchar *column_name = g_strdup (key);
1067  gchar *type_name = g_strrstr (column_name, "_");
1068 
1069  if (type_name != NULL) //guard against not finding '_'
1070  {
1071  *type_name++ = '\0';
1072 
1073  if (g_strcmp0 (type_name, STATE_KEY_SUFF_VISIBLE) == 0)
1074  {
1075  GtkTreeViewColumn *column = gnc_tree_view_find_column_by_name (view, column_name);
1076  if (column)
1077  {
1078  known = TRUE;
1079  if (!g_object_get_data (G_OBJECT (column), ALWAYS_VISIBLE))
1080  {
1081  gtk_tree_view_column_set_visible (column,
1082  g_key_file_get_boolean (state_file, priv->state_section, key, NULL));
1083  }
1084  }
1085  }
1086  else if (g_strcmp0 (type_name, STATE_KEY_SUFF_WIDTH) == 0)
1087  {
1088  gint width = g_key_file_get_integer (state_file, priv->state_section, key, NULL);
1089  GtkTreeViewColumn *column = gnc_tree_view_find_column_by_name (view, column_name);
1090  if (column)
1091  {
1092  known = TRUE;
1093  if (width && (width != gtk_tree_view_column_get_width (column)))
1094  {
1095  gtk_tree_view_column_set_fixed_width (column, width);
1096  }
1097  }
1098  }
1099  if (!known)
1100  DEBUG ("Ignored key %s", key);
1101 
1102  g_free (column_name);
1103  }
1104  }
1105  }
1106  g_strfreev (keys);
1107  }
1108 
1109  /* Rebuild the column visibility menu */
1110  gnc_tree_view_build_column_menu (view);
1111  LEAVE ("set state section");
1112 }
#define DEBUG(format, args...)
Print a debugging message.
Definition: qoflog.h:264
void gnc_tree_view_remove_state_information(GncTreeView *view)
Completely wipe the treeview&#39;s state information (column visibility, width, sorting order...
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
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition: gnc-state.c:248
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
Private Data Structure.

◆ gnc_ui_close_book()

void gnc_ui_close_book ( QofBook *  book,
GtkWindow *  parent 
)

Create and run the dialog to close the book.

Parameters
bookThis parameter specifies the book whose data will be closed.
parentThis parameter specifies the parent window

Definition at line 318 of file dialog-book-close.c.

319 {
320  struct CloseBookWindow *cbw;
321  GtkBuilder* builder;
322  GtkWidget* box;
323  GList* equity_list = NULL;
324 
325  g_return_if_fail(book);
326 
327  cbw = g_new0(struct CloseBookWindow, 1);
328  g_return_if_fail(cbw);
329  cbw->book = book;
330 
331  /* Open the dialog */
332  builder = gtk_builder_new();
333  gnc_builder_add_from_file (builder, "dialog-book-close.glade", "close_book_dialog");
334  cbw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "close_book_dialog"));
335 
336  // Set the name for this dialog so it can be easily manipulated with css
337  gtk_widget_set_name (GTK_WIDGET(cbw->dialog), "gnc-id-book-close");
338 
339  /* parent */
340  if (parent != NULL)
341  gtk_window_set_transient_for (GTK_WINDOW(cbw->dialog), GTK_WINDOW(parent));
342 
343  PINFO("Closed Book Window is %p, Dialog is %p", cbw, cbw->dialog);
344 
345  /* close date */
346  box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box"));
347  cbw->close_date_widget = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
348  gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0);
349 
350  /* income acct */
351  equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY));
352  box = GTK_WIDGET(gtk_builder_get_object (builder, "income_acct_box"));
353  cbw->income_acct_widget = gnc_account_sel_new();
354  gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget),
355  equity_list, NULL);
356  gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
357  gtk_box_pack_start(GTK_BOX(box), cbw->income_acct_widget, TRUE, TRUE, 0);
358 
359  /* expense acct */
360  box = GTK_WIDGET(gtk_builder_get_object (builder, "expense_acct_box"));
361  cbw->expense_acct_widget = gnc_account_sel_new();
362  gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget),
363  equity_list, NULL);
364  gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);
365  gtk_box_pack_start(GTK_BOX(box), cbw->expense_acct_widget, TRUE, TRUE, 0);
366 
367  /* desc */
368  cbw->desc_widget = GTK_WIDGET(gtk_builder_get_object (builder, "desc_entry"));
369 
370  /* Autoconnect signals */
371  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, cbw->dialog);
372 
373  /* Register dialog with component manager */
374  cbw->component_manager_id =
375  gnc_register_gui_component(DIALOG_BOOK_CLOSE_CM_CLASS, NULL, close_handler,
376  cbw->dialog);
377  gnc_gui_component_set_session(cbw->component_manager_id,
378  gnc_get_current_session());
379  g_signal_connect(cbw->dialog, "destroy", G_CALLBACK(destroy_cb), NULL);
380 
381  /* Clean up the data structure when the dialog is destroyed */
382  g_object_set_data_full(G_OBJECT(cbw->dialog), "CloseBookWindow", cbw, g_free);
383 
384  g_object_unref(G_OBJECT(builder));
385 
386  /* Run the dialog */
387  gtk_widget_show_all(cbw->dialog);
388 
389  g_list_free(equity_list);
390 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:270
Equity account is used to balance the balance sheet.
Definition: Account.h:146

◆ GncOptionsDialog()

GncOptionsDialog::GncOptionsDialog ( bool  modal,
const char *  title,
const char *  component_class,
GtkWindow *  parent 
)

Constructs a GncOptionsDialog.

Based on the description in the GtkBuilder file. Initializes signals. Two component classes might be used, DIALOG_BOOK_OPTIONS_CM_CLASS or DIALOG_OPTIONS_CM_CLASS of which the latter is the default.

Parameters
modalIf true the "Apply" button is hidden. It doesn't make the dialog run in its own event loop so it's not truly modal.
titleThe title that will appear in the dialog's title bar.
component_classFor registering the dialog in the component manager.
parentThe widget for which the dialog will be transient-for.

Definition at line 533 of file dialog-options.cpp.

535  :
536  m_component_class{component_class ? component_class : DIALOG_OPTIONS_CM_CLASS}
537 {
538  auto builder = gtk_builder_new();
539  gnc_builder_add_from_file (builder, "dialog-options.glade", "gnucash_options_window");
540  m_window = GTK_WIDGET(gtk_builder_get_object (builder, "gnucash_options_window"));
541  g_object_ref(m_window);
542  m_page_list = GTK_WIDGET(gtk_builder_get_object (builder, "page_list_scroll"));
543  g_object_set_data(G_OBJECT(m_window), "optionwin", this);
544 
545  // Set the name for this dialog so it can be easily manipulated with css
546  gtk_widget_set_name (GTK_WIDGET(m_window), "gnc-id-options");
547 
548  /* Page List */
549 
550  m_page_list_view = GTK_WIDGET(gtk_builder_get_object (builder, "page_list_treeview"));
551 
552  auto view = GTK_TREE_VIEW(m_page_list_view);
553 
554  auto store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING);
555  gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
556  g_object_unref(store);
557 
558  auto renderer = gtk_cell_renderer_text_new();
559  auto column =
560  gtk_tree_view_column_new_with_attributes(_("Page"), renderer,
561  "text", PAGE_NAME,
562  nullptr);
563  gtk_tree_view_append_column(view, column);
564 
565  gtk_tree_view_column_set_alignment(column, 0.5);
566 
567  auto selection = gtk_tree_view_get_selection(view);
568  gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
569  g_signal_connect (selection, "changed",
570  G_CALLBACK (dialog_list_select_cb), this);
571 
572  m_help_button = GTK_BUTTON(gtk_builder_get_object (builder, "helpbutton"));
573  g_signal_connect(m_help_button, "clicked",
574  G_CALLBACK(dialog_help_button_cb), this);
575  m_cancel_button = GTK_BUTTON(gtk_builder_get_object (builder, "cancelbutton"));
576  g_signal_connect(m_cancel_button, "clicked",
577  G_CALLBACK(dialog_cancel_button_cb), this);
578  m_apply_button = GTK_BUTTON(gtk_builder_get_object (builder, "applybutton"));
579  g_signal_connect(m_apply_button, "clicked",
580  G_CALLBACK(dialog_apply_button_cb), this);
581  m_ok_button = GTK_BUTTON(gtk_builder_get_object (builder, "okbutton"));
582  g_signal_connect(m_ok_button, "clicked",
583  G_CALLBACK(dialog_ok_button_cb), this);
584 
585  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func,
586  this);
587 
588  // when added to a page of the hierarchy assistant there will be no parent
589  if (parent)
590  gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(m_window),
591  parent);
592 
593  if (title)
594  gtk_window_set_title(GTK_WINDOW(m_window), title);
595 
596  /* modal */
597  if (modal)
598  gtk_widget_hide (GTK_WIDGET(m_apply_button));
599 
600  /* glade doesn't support a notebook with zero pages */
601  auto hbox = GTK_WIDGET(gtk_builder_get_object (builder,
602  "notebook_placeholder"));
603  m_notebook = gtk_notebook_new();
604 
605  gtk_widget_set_vexpand (m_notebook, TRUE);
606 
607  gtk_widget_show(m_notebook);
608  gtk_box_pack_start(GTK_BOX(hbox), m_notebook, TRUE, TRUE, 5);
609 
610  auto component_id = gnc_register_gui_component (m_component_class,
611  nullptr,
612  component_close_handler,
613  this);
614  gnc_gui_component_set_session (component_id, gnc_get_current_session());
615 
616  g_signal_connect (m_window, "destroy", G_CALLBACK(dialog_destroy_cb), this);
617 
618  g_signal_connect (m_window, "key_press_event",
619  G_CALLBACK(dialog_window_key_press_cb), this);
620 
621  g_object_unref(G_OBJECT(builder));
622 }

Variable Documentation

◆ end_strings

const gchar* end_strings[GNC_ACCOUNTING_PERIOD_LAST]
Initial value:
=
{
N_("Today"),
N_("End of this month"),
N_("End of previous month"),
N_("End of this quarter"),
N_("End of previous quarter"),
N_("End of this year"),
N_("End of previous year"),
N_("End of this accounting period"),
N_("End of previous accounting period"),
}

Definition at line 83 of file gnc-period-select.c.

◆ start_strings

const gchar* start_strings[GNC_ACCOUNTING_PERIOD_LAST]
Initial value:
=
{
N_("Today"),
N_("Start of this month"),
N_("Start of previous month"),
N_("Start of this quarter"),
N_("Start of previous quarter"),
N_("Start of this year"),
N_("Start of previous year"),
N_("Start of this accounting period"),
N_("Start of previous accounting period"),
}

Definition at line 67 of file gnc-period-select.c.