GnuCash  5.6-150-g038405b370+
window-main-summarybar.c
1 /********************************************************************
2  * window-main-summarybar.c -- summary of financial info *
3  * Copyright (C) 1998,1999 Jeremy Collins *
4  * Copyright (C) 1998,1999,2000 Linas Vepstas *
5  * Copyright (C) 2001 Bill Gribble *
6  * Copyright (C) 2005 Joshua Sled <jsled@asynchronous.org> *
7  * *
8  * This program is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License as *
10  * published by the Free Software Foundation; either version 2 of *
11  * the License, or (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License*
19  * along with this program; if not, contact: *
20  * *
21  * Free Software Foundation Voice: +1-617-542-5942 *
22  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
23  * Boston, MA 02110-1301, USA gnu@gnu.org *
24  ********************************************************************/
25 
26 #include <config.h>
27 
28 #include <gtk/gtk.h>
29 #include <glib/gi18n.h>
30 
31 #include "Account.h"
32 #include "gnc-accounting-period.h"
33 #include "gnc-component-manager.h"
34 #include "gnc-euro.h"
35 #include "gnc-event.h"
36 #include "gnc-prefs.h"
37 #include "gnc-locale-utils.h"
38 #include "gnc-ui-util.h"
39 #include "window-main-summarybar.h"
40 #include "dialog-utils.h"
41 
42 typedef struct
43 {
44  GtkWidget *hbox;
45  GtkWidget *totals_combo;
46  GtkListStore *datamodel;
47  int component_id;
48  int cnxn_id;
49  gboolean combo_popped;
50  gboolean show_negative_color;
51  gchar *negative_color;
53 
54 #define WINDOW_SUMMARYBAR_CM_CLASS "summary-bar"
55 
56 #define GNC_PREFS_GROUP "window.pages.account-tree.summary"
57 #define GNC_PREF_GRAND_TOTAL "grand-total"
58 #define GNC_PREF_NON_CURRENCY "non-currency"
59 
71 typedef struct
72 {
73  gnc_commodity * currency;
74  gnc_numeric assets;
75  gnc_numeric profits;
76  gint total_mode;
78 
79 
80 /* defines for total_mode in GNCCurrencyAcc and GNCCurrencyItem */
81 #define TOTAL_SINGLE 0
82 #define TOTAL_CURR_TOTAL 1
83 #define TOTAL_NON_CURR_TOTAL 2
84 #define TOTAL_GRAND_TOTAL 3
85 
86 
88 typedef struct
89 {
90  gnc_commodity *default_currency;
91  gboolean grand_total;
92  gboolean non_currency;
93  time64 start_date;
94  time64 end_date;
96 
101 static GNCCurrencyAcc *
102 gnc_ui_get_currency_accumulator(GList **list, gnc_commodity * currency, gint total_mode)
103 {
104  GList *current;
105  GNCCurrencyAcc *found;
106 
107  for (current = g_list_first(*list); current; current = g_list_next(current))
108  {
109  found = current->data;
110  if ((gnc_commodity_equiv(currency, found->currency))
111  && (found->total_mode == total_mode))
112  {
113  return found;
114  }
115  }
116 
117  found = g_new0 (GNCCurrencyAcc, 1);
118  found->currency = currency;
119  found->assets = gnc_numeric_zero ();
120  found->profits = gnc_numeric_zero ();
121  found->total_mode = total_mode;
122  *list = g_list_append (*list, found);
123 
124  return found;
125 }
126 
130 static void
131 gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
132  GNCSummarybarOptions options)
133 {
134  gnc_numeric start_amount;
135  gnc_numeric start_amount_default_currency;
136  gnc_numeric end_amount;
137  gnc_numeric end_amount_default_currency;
138  GNCAccountType account_type;
139  gnc_commodity * account_currency;
140  GNCCurrencyAcc *currency_accum = NULL;
141  GNCCurrencyAcc *grand_total_accum = NULL;
142  GNCCurrencyAcc *non_curr_accum = NULL;
143  GList *children, *node;
144  gboolean non_currency = FALSE;
145 
146  if (parent == NULL) return;
147 
148  children = gnc_account_get_children(parent);
149  for (node = children; node; node = g_list_next(node))
150  {
151  Account *account = node->data;
152  QofBook *book = gnc_account_get_book (account);
153  GNCPriceDB *pricedb = gnc_pricedb_get_db (book);
154  gnc_commodity *to_curr = options.default_currency;
155 
156  account_type = xaccAccountGetType(account);
157  account_currency = xaccAccountGetCommodity(account);
158 
159  if (options.grand_total)
160  grand_total_accum = gnc_ui_get_currency_accumulator(currency_list,
161  to_curr,
162  TOTAL_GRAND_TOTAL);
163 
164  if (!gnc_commodity_is_currency(account_currency))
165  {
166  non_currency = TRUE;
167  non_curr_accum = gnc_ui_get_currency_accumulator(currency_list,
168  to_curr,
169  TOTAL_NON_CURR_TOTAL);
170  }
171 
172  if (!non_currency || options.non_currency)
173  {
174  currency_accum = gnc_ui_get_currency_accumulator(currency_list,
175  account_currency,
176  TOTAL_SINGLE);
177  }
178 
179  switch (account_type)
180  {
181  case ACCT_TYPE_BANK:
182  case ACCT_TYPE_CASH:
183  case ACCT_TYPE_ASSET:
184  case ACCT_TYPE_STOCK:
185  case ACCT_TYPE_MUTUAL:
186  case ACCT_TYPE_CREDIT:
187  case ACCT_TYPE_LIABILITY:
188  case ACCT_TYPE_PAYABLE:
190  end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
191  end_amount_default_currency =
193  end_amount,
194  account_currency,
195  to_curr,
196  options.end_date);
197 
198  if (!non_currency || options.non_currency)
199  {
200  currency_accum->assets =
201  gnc_numeric_add (currency_accum->assets, end_amount,
202  gnc_commodity_get_fraction (account_currency),
204  }
205 
206  if (non_currency)
207  {
208  non_curr_accum->assets =
209  gnc_numeric_add (non_curr_accum->assets, end_amount_default_currency,
210  gnc_commodity_get_fraction (to_curr),
212  }
213 
214  if (options.grand_total)
215  {
216  grand_total_accum->assets =
217  gnc_numeric_add (grand_total_accum->assets, end_amount_default_currency,
218  gnc_commodity_get_fraction (to_curr),
220  }
221 
222  gnc_ui_accounts_recurse(account, currency_list, options);
223  break;
224  case ACCT_TYPE_INCOME:
225  case ACCT_TYPE_EXPENSE:
226  start_amount = xaccAccountGetBalanceAsOfDate(account, options.start_date);
227  start_amount_default_currency =
229  start_amount,
230  account_currency,
231  to_curr,
232  options.start_date);
233  end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
234  end_amount_default_currency =
236  end_amount,
237  account_currency,
238  to_curr,
239  options.end_date);
240 
241  if (!non_currency || options.non_currency)
242  {
243  currency_accum->profits =
244  gnc_numeric_add (currency_accum->profits, start_amount,
245  gnc_commodity_get_fraction (account_currency),
247  currency_accum->profits =
248  gnc_numeric_sub (currency_accum->profits, end_amount,
249  gnc_commodity_get_fraction (account_currency),
251  }
252 
253  if (non_currency)
254  {
255  non_curr_accum->profits =
256  gnc_numeric_add (non_curr_accum->profits, start_amount_default_currency,
257  gnc_commodity_get_fraction (to_curr),
259  non_curr_accum->profits =
260  gnc_numeric_sub (non_curr_accum->profits, end_amount_default_currency,
261  gnc_commodity_get_fraction (to_curr),
263  }
264 
265  if (options.grand_total)
266  {
267  grand_total_accum->profits =
268  gnc_numeric_add (grand_total_accum->profits,
269  start_amount_default_currency,
270  gnc_commodity_get_fraction (to_curr),
272  grand_total_accum->profits =
273  gnc_numeric_sub (grand_total_accum->profits,
274  end_amount_default_currency,
275  gnc_commodity_get_fraction (to_curr),
277  }
278 
279  gnc_ui_accounts_recurse(account, currency_list, options);
280  break;
281  case ACCT_TYPE_EQUITY:
282  /* no-op, see comments at top about summing assets */
283  break;
288  case ACCT_TYPE_TRADING:
289  break;
290  case ACCT_TYPE_CURRENCY:
291  default:
292  break;
293  }
294  }
295  g_list_free(children);
296 }
297 
298 static char*
299 get_total_mode_label (GNCCurrencyAcc *currency_accum)
300 {
301  const char *mnemonic = gnc_commodity_get_nice_symbol (currency_accum->currency);
302  char *label_str;
303  if (mnemonic == NULL)
304  mnemonic = "";
305  // i.e., "$, grand total," [profits: $12,345.67, assets: $23,456.78]
306  switch (currency_accum->total_mode)
307  {
308  case TOTAL_CURR_TOTAL:
309  label_str = g_strdup_printf( _("%s, Total:"), mnemonic );
310  break;
311  case TOTAL_NON_CURR_TOTAL:
312  label_str = g_strdup_printf( _("%s, Non Currency Commodities Total:"), mnemonic );
313  break;
314  case TOTAL_GRAND_TOTAL:
315  label_str = g_strdup_printf( _("%s, Grand Total:"), mnemonic );
316  break;
317  case TOTAL_SINGLE:
318  default:
319  label_str = g_strdup_printf( _("%s:"), mnemonic );
320  break;
321  }
322  return label_str;
323 }
324 
325 enum
326 {
327  COLUMN_MNEMONIC_TYPE,
328  COLUMN_ASSETS,
329  COLUMN_ASSETS_VALUE,
330  COLUMN_PROFITS,
331  COLUMN_PROFITS_VALUE,
332  COLUMN_ASSETS_NEG,
333  COLUMN_PROFITS_NEG,
334  N_COLUMNS
335 };
336 
337 /* The gnc_main_window_summary_refresh() subroutine redraws summary
338  * information. The statusbar includes two fields, titled 'profits'
339  * and 'assets'. The total assets equal the sum of all of the
340  * non-equity, non-income accounts. In theory, assets also equals the
341  * grand total value of the equity accounts, but that assumes that
342  * folks are using the equity account type correctly (which is not
343  * likely). Thus we show the sum of assets, rather than the sum of
344  * equities.
345  *
346  * The EURO gets special treatment. There can be one line with
347  * EUR amounts and a EUR (total) line which sums up all EURO
348  * member currencies.
349  *
350  * There can be a 'grand total', too, which sums up all accounts
351  * converted to one common currency and a total of all non
352  * currency commodities (e.g. stock, funds). */
353 
354 static void
355 gnc_main_window_summary_refresh (GNCMainSummary * summary)
356 {
357  Account *root;
358  GNCCurrencyAcc *currency_accum;
359  GList *currency_list;
360  GList *current;
361  GNCSummarybarOptions options;
362 
363 
364  root = gnc_get_current_root_account ();
365  options.default_currency = gnc_default_currency ();
366  if (options.default_currency == NULL)
367  {
368  options.default_currency = xaccAccountGetCommodity(root);
369  }
370 
371  options.grand_total =
372  gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_GRAND_TOTAL);
373  options.non_currency =
374  gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_NON_CURRENCY);
375  options.start_date = gnc_accounting_period_fiscal_start();
376  options.end_date = gnc_accounting_period_fiscal_end();
377 
378  currency_list = NULL;
379 
380  /* grand total should be first in the list */
381  if (options.grand_total)
382  {
383  gnc_ui_get_currency_accumulator (&currency_list, options.default_currency,
384  TOTAL_GRAND_TOTAL);
385  }
386  /* Make sure there's at least one accumulator in the list. */
387  gnc_ui_get_currency_accumulator (&currency_list, options.default_currency,
388  TOTAL_SINGLE);
389 
390  gnc_ui_accounts_recurse(root, &currency_list, options);
391 
392  {
393  GtkTreeIter iter;
394  char asset_amount_string[256], profit_amount_string[256];
395 
396  g_object_ref(summary->datamodel);
397  gtk_combo_box_set_model(GTK_COMBO_BOX(summary->totals_combo), NULL);
398  gtk_list_store_clear(summary->datamodel);
399  for (current = g_list_first(currency_list); current; current = g_list_next(current))
400  {
401  gchar *total_mode_label;
402  gchar *bidi_total, *bidi_asset_amount, *bidi_profit_amount;
403 
404  currency_accum = current->data;
405 
406  xaccSPrintAmount(asset_amount_string,
407  currency_accum->assets,
408  gnc_commodity_print_info(currency_accum->currency, TRUE));
409 
410  xaccSPrintAmount(profit_amount_string,
411  currency_accum->profits,
412  gnc_commodity_print_info(currency_accum->currency, TRUE));
413 
414  gtk_list_store_append(summary->datamodel, &iter);
415  total_mode_label = get_total_mode_label (currency_accum);
416  bidi_total = gnc_wrap_text_with_bidi_ltr_isolate(total_mode_label);
417  bidi_asset_amount = gnc_wrap_text_with_bidi_ltr_isolate(asset_amount_string);
418  bidi_profit_amount = gnc_wrap_text_with_bidi_ltr_isolate(profit_amount_string);
419  gtk_list_store_set(summary->datamodel, &iter,
420  COLUMN_MNEMONIC_TYPE, bidi_total,
421  COLUMN_ASSETS, _("Net Assets:"),
422  COLUMN_ASSETS_VALUE, bidi_asset_amount,
423  COLUMN_ASSETS_NEG, gnc_numeric_negative_p(currency_accum->assets),
424  COLUMN_PROFITS, _("Profits:"),
425  COLUMN_PROFITS_VALUE, bidi_profit_amount,
426  COLUMN_PROFITS_NEG, gnc_numeric_negative_p(currency_accum->profits),
427  -1);
428  g_free(total_mode_label);
429  g_free(bidi_total);
430  g_free(bidi_asset_amount);
431  g_free(bidi_profit_amount);
432  }
433  gtk_combo_box_set_model(GTK_COMBO_BOX(summary->totals_combo),
434  GTK_TREE_MODEL(summary->datamodel));
435  g_object_unref(summary->datamodel);
436 
437  gtk_combo_box_set_active(GTK_COMBO_BOX(summary->totals_combo), 0);
438  }
439 
440  g_list_free_full (currency_list, g_free);
441 }
442 
443 static gchar*
444 get_negative_color_str (void)
445 {
446  GdkRGBA color;
447  GdkRGBA *rgba;
448  gchar *color_str;
449  GtkWidget *label = gtk_label_new ("Color");
450  GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
451  gtk_style_context_add_class (context, "gnc-class-negative-numbers");
452  gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
453  rgba = gdk_rgba_copy (&color);
454 
455  color_str = g_strdup_printf ("#%02X%02X%02X",
456  (int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
457  (int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
458  (int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
459  gdk_rgba_free (rgba);
460  return color_str;
461 }
462 
463 static void
464 summarybar_update_color (gpointer gsettings, gchar *key, gpointer user_data)
465 {
466  GNCMainSummary *summary = user_data;
467 
468  summary->negative_color = get_negative_color_str();
469  summary->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
470 
471  gnc_main_window_summary_refresh (summary);
472 }
473 
474 static void
475 gnc_main_window_summary_destroy_cb(GNCMainSummary *summary, gpointer data)
476 {
477  gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP, summary->cnxn_id);
478  gnc_unregister_gui_component(summary->component_id);
479 
480  gnc_prefs_remove_cb_by_func(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
481  summarybar_update_color, summary);
482 
483  g_free (summary->negative_color);
484  g_free (summary);
485 }
486 
487 static void
488 summarybar_refresh_handler(GHashTable * changes, gpointer user_data)
489 {
490  GNCMainSummary * summary = user_data;
491  gnc_main_window_summary_refresh(summary);
492 }
493 
494 static void
495 prefs_changed_cb (gpointer prefs, gchar *pref, gpointer user_data)
496 {
497  GNCMainSummary * summary = user_data;
498  gnc_main_window_summary_refresh(summary);
499 }
500 
501 static gchar*
502 check_string_for_markup (gchar *string)
503 {
504  gchar **strings;
505  gchar *ret_string = g_strdup (string);
506 
507  if (g_strrstr (ret_string, "&") != NULL)
508  {
509  strings = g_strsplit (ret_string, "&", -1);
510  g_free (ret_string);
511  ret_string = g_strjoinv ("&amp;", strings);
512  g_strfreev (strings);
513  }
514  if (g_strrstr (ret_string, "<") != NULL)
515  {
516  strings = g_strsplit (ret_string, "<", -1);
517  g_free (ret_string);
518  ret_string = g_strjoinv ("&lt;", strings);
519  g_strfreev (strings);
520  }
521  if (g_strrstr (ret_string, ">") != NULL)
522  {
523  strings = g_strsplit (ret_string, ">", -1);
524  g_free (ret_string);
525  ret_string = g_strjoinv ("&gt;", strings);
526  g_strfreev (strings);
527  }
528  if (g_strrstr (ret_string, "\"") != NULL)
529  {
530  strings = g_strsplit (ret_string, "\"", -1);
531  g_free (ret_string);
532  ret_string = g_strjoinv ("&quot;", strings);
533  g_strfreev (strings);
534  }
535  if (g_strrstr (ret_string, "'") != NULL)
536  {
537  strings = g_strsplit (ret_string, "'", -1);
538  g_free (ret_string);
539  ret_string = g_strjoinv ("&apos;", strings);
540  g_strfreev (strings);
541  }
542  return ret_string;
543 }
544 
545 static void
546 cdf (GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter,
547  gpointer user_data)
548 {
549  GNCMainSummary * summary = user_data;
550  gchar *type, *assets, *assets_val, *profits, *profits_val;
551  gboolean assets_neg, profits_neg;
552  gint viewcol;
553 
554  viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
555 
556  if (summary->combo_popped)
557  g_object_set (cell, "xalign", 0.0, NULL);
558  else
559  g_object_set (cell, "xalign", 0.5, NULL);
560 
561  gtk_tree_model_get (GTK_TREE_MODEL (tree_model), iter,
562  COLUMN_MNEMONIC_TYPE, &type,
563  COLUMN_ASSETS, &assets,
564  COLUMN_ASSETS_VALUE, &assets_val,
565  COLUMN_PROFITS, &profits,
566  COLUMN_PROFITS_VALUE, &profits_val,
567  COLUMN_ASSETS_NEG, &assets_neg,
568  COLUMN_PROFITS_NEG, &profits_neg, -1);
569 
570  if (viewcol == 0)
571  g_object_set (cell, "text", type, NULL);
572 
573  if (viewcol == 2)
574  {
575  gchar *a_string, *checked_string = check_string_for_markup (assets_val);
576  if ((summary->show_negative_color == TRUE) && (assets_neg == TRUE))
577  a_string = g_strconcat (assets, " <span foreground='", summary->negative_color, "'>", checked_string, "</span>", NULL);
578  else
579  a_string = g_strconcat (assets, " ", checked_string, NULL);
580 
581  g_object_set (cell, "markup", a_string, NULL);
582  g_free (a_string);
583  g_free (checked_string);
584  }
585 
586  if (viewcol == 4)
587  {
588  gchar *p_string, *checked_string = check_string_for_markup (profits_val);
589  if ((summary->show_negative_color == TRUE) && (profits_neg == TRUE))
590  p_string = g_strconcat (profits, " <span foreground='", summary->negative_color, "'>", checked_string, "</span>", NULL);
591  else
592  p_string = g_strconcat (profits, " ", checked_string, NULL);
593 
594  g_object_set (cell, "markup", p_string, NULL);
595  g_free (p_string);
596  g_free (checked_string);
597  }
598 
599  g_free (type);
600  g_free (assets);
601  g_free (assets_val);
602  g_free (profits);
603  g_free (profits_val);
604 }
605 
606 static void
607 summary_combo_popped (GObject *widget, GParamSpec *pspec, gpointer user_data)
608 {
609  GNCMainSummary * summary = user_data;
610  if (summary->combo_popped)
611  summary->combo_popped = FALSE;
612  else
613  summary->combo_popped = TRUE;
614 }
615 
616 GtkWidget *
617 gnc_main_window_summary_new (void)
618 {
619  GNCMainSummary * retval = g_new0(GNCMainSummary, 1);
620  GtkCellRenderer *textRenderer;
621  int i;
622 
623  retval->datamodel = gtk_list_store_new (N_COLUMNS,
624  G_TYPE_STRING,
625  G_TYPE_STRING,
626  G_TYPE_STRING,
627  G_TYPE_STRING,
628  G_TYPE_STRING,
629  G_TYPE_BOOLEAN,
630  G_TYPE_BOOLEAN);
631 
632  retval->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
633  gtk_box_set_homogeneous (GTK_BOX (retval->hbox), FALSE);
634 
635  // Set the name for this wodget so it can be easily manipulated with css
636  gtk_widget_set_name (GTK_WIDGET(retval->hbox), "gnc-id-account-summary-bar");
637 
638  retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel));
639  g_object_unref (retval->datamodel);
640 
641  retval->negative_color = get_negative_color_str();
642  retval->show_negative_color = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
643  gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
644  summarybar_update_color, retval);
645 
646  retval->component_id = gnc_register_gui_component (WINDOW_SUMMARYBAR_CM_CLASS,
647  summarybar_refresh_handler,
648  NULL, retval);
649  gnc_gui_component_watch_entity_type (retval->component_id,
650  GNC_ID_ACCOUNT,
651  QOF_EVENT_DESTROY
652  | GNC_EVENT_ITEM_CHANGED);
653 
654  // Allows you to get when the popup menu is present
655  g_signal_connect (retval->totals_combo, "notify::popup-shown",G_CALLBACK (summary_combo_popped), retval);
656 
657  retval->combo_popped = FALSE;
658 
659  for (i = 0; i <= N_COLUMNS - 2; i += 2)
660  {
661  textRenderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
662 
663  gtk_cell_renderer_set_fixed_size (textRenderer, 50, -1);
664 
665  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, TRUE);
666 
667  g_object_set_data (G_OBJECT(textRenderer), "view_column", GINT_TO_POINTER (i));
668  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, cdf, retval, NULL);
669  }
670 
671  gtk_container_set_border_width (GTK_CONTAINER (retval->hbox), 2);
672  gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo, TRUE, TRUE, 5);
673  gtk_widget_show (retval->totals_combo);
674  gtk_widget_show (retval->hbox);
675 
676  g_signal_connect_swapped (G_OBJECT (retval->hbox), "destroy",
677  G_CALLBACK (gnc_main_window_summary_destroy_cb),
678  retval);
679 
680  gnc_main_window_summary_refresh(retval);
681 
682  retval->cnxn_id = gnc_prefs_register_cb (GNC_PREFS_GROUP, NULL,
683  prefs_changed_cb, retval);
684 
685  return retval->hbox;
686 }
options for summarybar
gboolean gnc_commodity_is_currency(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency...
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
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
utility functions for the GnuCash UI
Expense accounts are used to denote expenses.
Definition: Account.h:143
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account&#39;s account type.
Definition: Account.cpp:3289
STRUCTS.
Mutual Fund accounts will typically be shown in registers which show three columns: price...
Definition: Account.h:125
char * gnc_wrap_text_with_bidi_ltr_isolate(const char *text)
This function helps with GTK&#39;s use of &#39;Unicode Bidirectional Text Algorithm&#39;.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition: Account.h:110
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Return the pricedb associated with the book.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
Account used to record multiple commodity transactions.
Definition: Account.h:155
void gnc_prefs_remove_cb_by_id(const gchar *group, guint id)
Remove a function that was registered for a callback when a specific preference in the settings group...
Definition: gnc-prefs.c:153
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Definition: Account.h:122
Account handling public routines.
Income accounts are used to denote income.
Definition: Account.h:140
General utilities for dealing with accounting periods.
The bank account type denotes a savings or checking account held at a bank.
Definition: Account.h:107
A/P account type.
Definition: Account.h:151
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
Additional event handling code.
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:116
gnc_numeric xaccAccountGetBalanceAsOfDate(Account *acc, time64 date)
Get the balance of the account at the end of the day before the date specified.
Definition: Account.cpp:3614
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
The currency account type indicates that the account is a currency trading account.
Definition: Account.h:129
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Definition: Account.h:101
Generic api to store and retrieve preferences.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Definition: Account.h:119
GList * gnc_account_get_children(const Account *account)
This routine returns a GList of all children accounts of the specified account.
Definition: Account.cpp:2940
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account&#39;s commodity.
Definition: Account.cpp:3474
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
gnc_numeric gnc_pricedb_convert_balance_nearest_price_t64(GNCPriceDB *pdb, gnc_numeric balance, const gnc_commodity *balance_currency, const gnc_commodity *new_currency, time64 t)
Convert a balance from one currency to another using the price nearest to the given time...
A/R account type.
Definition: Account.h:149
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
Definition: gnc-numeric.h:165
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
Equity account is used to balance the balance sheet.
Definition: Account.h:146
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
The Credit card account is used to denote credit (e.g.
Definition: Account.h:113
An accumulator for a given currency.
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