GnuCash  4.11-627-g58c1a51897
gnc-period-select.c
Go to the documentation of this file.
1 /*
2  * gnc-period-select.c -- Accounting Period selection widget
3  *
4  * Copyright (c) 2005 David Hampton <hampton@employees.org>
5  * All rights reserved.
6  *
7  * Gnucash is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public License
9  * as published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * Gnucash is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, contact:
19  *
20  * Free Software Foundation Voice: +1-617-542-5942
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22  * Boston, MA 02110-1301, USA gnu@gnu.org
23  */
24 
32 #include <config.h>
33 
34 #include <gtk/gtk.h>
35 #include <glib/gi18n.h>
36 
37 #include "gnc-date.h"
38 #include "gnc-period-select.h"
39 #include "gnc-prefs.h"
40 #include "dialog-utils.h"
41 
42 enum
43 {
44  PROP_0,
45  PROP_FY_END,
46  PROP_SHOW_DATE,
47  PROP_DATE_BASE,
48  PROP_PS_ACTIVE,
49 };
50 
51 enum
52 {
53  CHANGED,
54  LAST_SIGNAL
55 };
56 
57 static guint signals[LAST_SIGNAL] = { 0 };
58 
60 static void gnc_period_select_init (GncPeriodSelect *gce);
61 static void gnc_period_select_class_init (GncPeriodSelectClass *klass);
62 static void gnc_period_select_finalize (GObject *object);
63 
64 static GtkComboBoxClass *parent_class;
65 
66 
67 const gchar *start_strings[GNC_ACCOUNTING_PERIOD_LAST] =
68 {
69  /* CY (current year) Strings */
70  N_("Today"),
71  N_("Start of this month"),
72  N_("Start of previous month"),
73  N_("Start of this quarter"),
74  N_("Start of previous quarter"),
75  N_("Start of this year"),
76  N_("Start of previous year"),
77 
78  /* FY (fiscal year) Strings */
79  N_("Start of this accounting period"),
80  N_("Start of previous accounting period"),
81 };
82 
83 const gchar *end_strings[GNC_ACCOUNTING_PERIOD_LAST] =
84 {
85  /* CY (current year) Strings */
86  N_("Today"),
87  N_("End of this month"),
88  N_("End of previous month"),
89  N_("End of this quarter"),
90  N_("End of previous quarter"),
91  N_("End of this year"),
92  N_("End of previous year"),
93 
94  /* FY (fiscal year) Strings */
95  N_("End of this accounting period"),
96  N_("End of previous accounting period"),
97 };
98 
99 
102 typedef struct _GncPeriodSelectPrivate GncPeriodSelectPrivate;
104 {
105  GtkWidget *selector;
106 
107  gboolean start;
108  GDate *fy_end;
109 
110  GDate *date_base;
111  GtkWidget *date_label;
112 };
113 
114 G_DEFINE_TYPE_WITH_PRIVATE(GncPeriodSelect, gnc_period_select, GTK_TYPE_BOX)
115 
116 #define GNC_PERIOD_SELECT_GET_PRIVATE(o) \
117  ((GncPeriodSelectPrivate*)gnc_period_select_get_instance_private((GncPeriodSelect*)o))
118 
119 
120 /************************************************************/
121 /* Signal Functions */
122 /************************************************************/
123 
124 /* Tells a GncPeriodSelect object to emit a "changed" signal.
125  */
126 static void
127 gnc_period_select_changed (GncPeriodSelect *period)
128 {
129  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
130 
131  g_signal_emit(G_OBJECT(period), signals[CHANGED], 0);
132 }
133 
134 
140 static void
141 gnc_period_sample_update_date_label (GncPeriodSelect *period)
142 {
143  GncPeriodSelectPrivate *priv;
144  gchar time_string[MAX_DATE_LENGTH + 1];
145  GDate *date;
146  GncAccountingPeriod which;
147 
148  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
149  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
150  if (!priv->date_label)
151  return;
152  which = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->selector));
153  if (which == -1)
154  date = g_date_new_dmy (31, 7, 2013);
155 
156  else if (priv->start)
157  date = gnc_accounting_period_start_gdate (which, priv->fy_end,
158  priv->date_base);
159  else
160  date = gnc_accounting_period_end_gdate (which, priv->fy_end,
161  priv->date_base);
162  qof_print_gdate (time_string, MAX_DATE_LENGTH, date);
163  gtk_label_set_label (GTK_LABEL(priv->date_label), time_string);
164  g_date_free (date);
165 }
166 
167 
177 static void
178 gnc_period_sample_combobox_changed (GtkComboBox *box, GncPeriodSelect *period)
179 {
180  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
181 
182  g_object_set (G_OBJECT (period),
183  "active",
184  gtk_combo_box_get_active (box),
185  NULL);
186 }
187 
188 
201 static void
202 gnc_period_sample_new_date_format (gpointer prefs, gchar *pref,
203  GncPeriodSelect *period)
204 {
205  gnc_period_sample_update_date_label(period);
206 }
207 
208 
209 /************************************************************/
210 /* Property Functions */
211 /************************************************************/
212 
213 /* Set an item in the GncPeriodSelect to be the active one.
214  * This will first update the internal GtkCombobox (blocking
215  * its "changed" callback to prevent an infinite loop).
216  * Then it will update the sample label and finally it will
217  * emit a "changed" signal of it's own for other objects
218  * listening for this signal.
219  */
220 static void
221 gnc_period_select_set_active_internal (GncPeriodSelect *period,
222  GncAccountingPeriod which)
223 {
224  GncPeriodSelectPrivate *priv;
225 
226  g_return_if_fail(period != NULL);
227  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
228  g_return_if_fail(which >= 0);
229  g_return_if_fail(which < GNC_ACCOUNTING_PERIOD_LAST);
230 
231  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
232 
233  g_signal_handlers_block_by_func(G_OBJECT(period),
234  G_CALLBACK(gnc_period_sample_combobox_changed), period);
235  gtk_combo_box_set_active(GTK_COMBO_BOX(priv->selector), which);
236  g_signal_handlers_unblock_by_func(G_OBJECT(period),
237  G_CALLBACK(gnc_period_sample_combobox_changed), period);
238 
239  /* Update this widget */
240  gnc_period_sample_update_date_label(period);
241 
242  /* Pass it on... */
243  gnc_period_select_changed(period);
244 }
245 
246 
250 /* Get the current value of the fiscal year end setting from a
251  * GncPeriodSelect widget. If the result is NULL then fiscal years
252  * are not currently supported.
253  */
254 GDate *
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 }
269 
270 
271 /* Set the fiscal year end on a GncPeriodSelect widget. If set to a
272  * value other than NULL then widget will include fiscal accounting
273  * period like "this fiscal year".
274  */
275 void
276 gnc_period_select_set_fy_end (GncPeriodSelect *period, const GDate *fy_end)
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 }
316 
317 
318 static void
319 gnc_period_select_set_date_common (GncPeriodSelect *period, const GDate *date)
320 {
321  GncPeriodSelectPrivate *priv;
322 
323  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
324  if (date)
325  {
326  if (priv->date_base)
327  g_date_free(priv->date_base);
328  priv->date_base = g_date_new_dmy(g_date_get_day(date),
329  g_date_get_month(date),
330  g_date_get_year(date));
331  if (priv->date_label == NULL)
332  {
333  priv->date_label = gtk_label_new("");
334  gtk_widget_set_margin_start (GTK_WIDGET(priv->date_label), 6);
335  gtk_box_pack_start(GTK_BOX(period), priv->date_label, TRUE, TRUE, 0);
336  gtk_widget_show_all(priv->date_label);
337  }
338  gnc_period_sample_update_date_label(period);
339  return;
340  }
341 
342  if (priv->date_base)
343  {
344  g_date_free(priv->date_base);
345  priv->date_base = NULL;
346  gtk_widget_destroy(priv->date_label);
347  priv->date_label = NULL;
348  }
349 }
350 
351 
352 /* Get the current value of the "show date" setting from a
353  * GncPeriodSelect widget.
354  */
355 gboolean
357 {
358  GncPeriodSelectPrivate *priv;
359 
360  g_return_val_if_fail(period != NULL, FALSE);
361  g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), FALSE);
362 
363  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
364  return (priv->date_base != NULL);
365 }
366 
367 /* Set the "show date" setting on a GncPeriodSelect widget. If set
368  * to TRUE then a GtkLabel will be used to show the date
369  * corresponding to the selected time period.
370  */
371 void
372 gnc_period_select_set_show_date (GncPeriodSelect *period, const gboolean show_date)
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 }
390 
391 
392 GDate *
393 gnc_period_select_get_date_base (GncPeriodSelect *period)
394 {
395  GncPeriodSelectPrivate *priv;
396 
397  g_return_val_if_fail(period != NULL, NULL);
398  g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), NULL);
399 
400  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
401  if (!priv->date_base)
402  return NULL;
403  return g_date_new_dmy(g_date_get_day(priv->date_base),
404  g_date_get_month(priv->date_base),
405  g_date_get_year(priv->date_base));
406 }
407 
408 
409 /* Set the base date used by a GncPeriodSelect widget. All example
410  * dates presented by the widget will be computed from this date.
411  */
412 void
413 gnc_period_select_set_date_base (GncPeriodSelect *period, const GDate *date_base)
414 {
415  g_return_if_fail(period != NULL);
416  g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
417 
418  gnc_period_select_set_date_common(period, date_base);
419 }
420 
421 
429 static void
430 gnc_period_select_get_property (GObject *object,
431  guint prop_id,
432  GValue *value,
433  GParamSpec *pspec)
434 {
435  GncPeriodSelect *period = GNC_PERIOD_SELECT(object);
436 
437  switch (prop_id)
438  {
439  case PROP_FY_END:
440  g_value_set_pointer(value, gnc_period_select_get_fy_end(period));
441  break;
442  case PROP_SHOW_DATE:
443  g_value_set_boolean(value, gnc_period_select_get_show_date(period));
444  break;
445  case PROP_DATE_BASE:
446  g_value_set_pointer(value, gnc_period_select_get_date_base(period));
447  break;
448  case PROP_PS_ACTIVE:
449  g_value_set_int(value, gnc_period_select_get_active(period));
450  break;
451  default:
452  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
453  break;
454  }
455 }
456 
457 
466 static void
467 gnc_period_select_set_property (GObject *object,
468  guint prop_id,
469  const GValue *value,
470  GParamSpec *pspec)
471 {
472  GncPeriodSelect *period = GNC_PERIOD_SELECT(object);
473 
474  switch (prop_id)
475  {
476  case PROP_FY_END:
477  gnc_period_select_set_fy_end(period, g_value_get_pointer(value));
478  break;
479  case PROP_SHOW_DATE:
480  gnc_period_select_set_show_date(period, g_value_get_boolean(value));
481  break;
482  case PROP_DATE_BASE:
483  gnc_period_select_set_date_base(period, g_value_get_pointer(value));
484  break;
485  case PROP_PS_ACTIVE:
486  gnc_period_select_set_active_internal(period, g_value_get_int(value));
487  break;
488  default:
489  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
490  break;
491  }
492 }
493 
496 /************************************************************/
497 /* Core Implementation */
498 /************************************************************/
499 
512 static void
513 gnc_period_select_class_init (GncPeriodSelectClass *klass)
514 {
515  GObjectClass *gobject_class;
516 
517  parent_class = g_type_class_peek_parent(klass);
518 
519  gobject_class = G_OBJECT_CLASS(klass);
520  gobject_class->set_property = gnc_period_select_set_property;
521  gobject_class->get_property = gnc_period_select_get_property;
522  gobject_class->finalize = gnc_period_select_finalize;
523 
524 
525  signals[CHANGED] = g_signal_new("changed",
526  G_OBJECT_CLASS_TYPE (klass),
527  G_SIGNAL_RUN_FIRST,
528  G_STRUCT_OFFSET(GncPeriodSelectClass, changed),
529  NULL, NULL,
530  g_cclosure_marshal_VOID__VOID,
531  G_TYPE_NONE,
532  0);
533 
534 
535  g_object_class_install_property(gobject_class,
536  PROP_FY_END,
537  g_param_spec_pointer("fy-end",
538  "Fiscal Year End",
539  "The fiscal year to use for this widget",
540  G_PARAM_READWRITE));
541  g_object_class_install_property(gobject_class,
542  PROP_SHOW_DATE,
543  g_param_spec_boolean("show-date",
544  "Show Date",
545  "Show the start/end date of the accounting period in this widget",
546  FALSE,
547  G_PARAM_READWRITE));
548  g_object_class_install_property(gobject_class,
549  PROP_DATE_BASE,
550  g_param_spec_pointer("date-base",
551  "Date Base",
552  "The starting date to use for display calculations",
553  G_PARAM_READWRITE));
554  g_object_class_install_property(gobject_class,
555  PROP_PS_ACTIVE,
556  g_param_spec_int("active",
557  "Active period",
558  "The currently selected period in the list of periods",
559  -1,
560  G_MAXINT,
561  0,
562  G_PARAM_READWRITE));
563 }
564 
573 static void
574 gnc_period_select_init (GncPeriodSelect *period)
575 {
576  GncPeriodSelectPrivate *priv;
577 
578  gtk_orientable_set_orientation (GTK_ORIENTABLE(period), GTK_ORIENTATION_HORIZONTAL);
579 
580  // Set the name for this widget so it can be easily manipulated with css
581  gtk_widget_set_name (GTK_WIDGET(period), "gnc-id-period-select");
582 
583  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
584  priv->start = TRUE;
585 }
586 
587 
598 static void
599 gnc_period_select_finalize (GObject *object)
600 {
601  GncPeriodSelectPrivate *priv;
602  GncPeriodSelect *period;
603 
604  g_return_if_fail (object != NULL);
605  g_return_if_fail (GNC_IS_PERIOD_SELECT (object));
606 
607  period = GNC_PERIOD_SELECT(object);
608  priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
609 
610  /* Stop tracking changes to date formatting */
611  gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT,
612  gnc_period_sample_new_date_format, period);
613 
614  /* The selector and date_label were added to the hbox. They will be
615  * freed automatically. */
616  if (priv->fy_end)
617  g_date_free(priv->fy_end);
618  if (priv->date_base)
619  g_date_free(priv->date_base);
620 
621  /* Do not free the private data structure. It is part of a larger
622  * memory block allocated by the type system. */
623 
624  if (G_OBJECT_CLASS(parent_class)->finalize)
625  (* G_OBJECT_CLASS(parent_class)->finalize) (object);
626 }
627 
628 
629 /* Create a new GncPeriodSelect widget which is used to select a
630  * accounting period like "previous month" or "this year".
631  *
632  * @param starting_labels If set to TRUE then all the labels will
633  * refer to the "Start of...". If FALSE, labels will refer to "End
634  * of...".
635  *
636  * @return A GncPeriodSelect widget.
637  */
638 GtkWidget *
639 gnc_period_select_new (gboolean starting_labels)
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 }
674 
675 
676 /* Create a new GncPeriodSelect widget from a glade file. The int1
677  * argument passed from glade is used to determine whether the widget
678  * uses labels for start times or end times. A non-zero int2
679  * argument indicates that an example date should be shown.
680  */
681 GtkWidget *
682 gnc_period_select_new_glade (gchar *widget_name,
683  gchar *string1, gchar *string2,
684  gint int1, gint int2)
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 }
693 
696 /************************************************************/
697 /* Auxiliary Functions */
698 /************************************************************/
699 
700 
701 /* Set which item in the GncPeriodSelect is initially selected. This
702  * is used to set the initial selection before the widget is shown to
703  * the user.
704  */
705 void
707  GncAccountingPeriod which)
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 }
716 
717 
718 /* Get the currently selected accounting period from a
719  * GncPeriodSelect widget. This is used to retrieve the user's
720  * selection in the form of an enum.
721  */
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 }
733 
734 
735 /* Get the currently selected accounting period choice from a
736  * GncPeriodSelect widget. This is used to retrieve the user's
737  * selection in the form of a GDate.
738  */
739 GDate *
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 }
759 
Date and Time handling routines.
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
size_t qof_print_gdate(char *buf, size_t bufflen, const GDate *gd)
Convenience; calls through to qof_print_date_dmy_buff().
Definition: gnc-date.cpp:605
GncAccountingPeriod gnc_period_select_get_active(GncPeriodSelect *period)
Get the currently selected accounting period 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.
GDate * gnc_period_select_get_date(GncPeriodSelect *period)
Get the currently selected accounting period choice from a GncPeriodSelect widget.
GncAccountingPeriod
This specifies a time interval.
GDate * gnc_period_select_get_fy_end(GncPeriodSelect *period)
Get the current value of the fiscal year end setting from a GncPeriodSelect widget.
void gnc_period_select_set_fy_end(GncPeriodSelect *period, const GDate *fy_end)
Set the fiscal year end on a GncPeriodSelect widget.
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
Definition: gnc-date.h:114
Generic api to store and retrieve preferences.
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.
Private Data Structure.
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.
gboolean gnc_period_select_get_show_date(GncPeriodSelect *period)
Get the current value of the "show sample" setting from a GncPeriodSelect widget. ...
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
Definition: gnc-date.cpp:1247
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.
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:273
GtkWidget * gnc_period_select_new(gboolean starting_labels)
Create a new GncPeriodSelect widget which is used to select a accounting period like "previous month"...
void gnc_period_select_set_active(GncPeriodSelect *period, GncAccountingPeriod which)
Set which item in the GncPeriodSelect is initially selected.
A custom widget for selecting accounting periods.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.
Definition: gnc-prefs.c:143