29 #include <glib/gi18n.h> 40 #include "gnc-component-manager.h" 45 #include "gnc-hooks.h" 46 #include "gnc-session.h" 47 #include "gnc-icons.h" 48 #include "gnc-ui-balances.h" 49 #include "dialog-utils.h" 50 #include "window-main-summarybar.h" 52 #define SAMPLE_ACCOUNT_VALUE "$1,000,000.00" 53 #define GNC_PREF_ACCOUNT_COLOR "show-account-color" 58 static QofLogModule log_module = GNC_MOD_GUI;
61 static void gnc_tree_view_account_finalize (GObject *
object);
62 static gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
63 const gchar *key, GtkTreeIter *iter, gpointer search_data);
65 static void gtva_update_column_names (GncTreeViewAccount *view);
66 static void gtva_currency_changed_cb (
void);
68 static gboolean gnc_tree_view_account_filter_helper (GtkTreeModel *model,
72 static void gtva_setup_column_renderer_edited_cb(GncTreeViewAccount *account_view,
73 GtkTreeViewColumn *column,
74 GtkCellRenderer *renderer,
75 GncTreeViewAccountColumnTextEdited col_edited_cb);
77 static void tax_info_data_func (GtkTreeViewColumn *col,
78 GtkCellRenderer *renderer,
83 static void acc_color_data_func (GtkTreeViewColumn *col,
84 GtkCellRenderer *renderer,
89 static void gnc_tree_view_account_color_update (gpointer gsettings,
90 gchar *key, gpointer user_data);
93 gnc_tree_view_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_tip,
94 GtkTooltip *tooltip, gpointer user_data);
98 GncTreeView gnc_tree_view;
104 gpointer filter_data;
105 GSourceFunc filter_destroy;
107 GtkTreeViewColumn *name_column;
108 GtkTreeViewColumn *code_column;
109 GtkTreeViewColumn *desc_column;
110 GtkTreeViewColumn *present_report_column;
111 GtkTreeViewColumn *balance_report_column;
112 GtkTreeViewColumn *cleared_report_column;
113 GtkTreeViewColumn *reconciled_report_column;
114 GtkTreeViewColumn *future_min_report_column;
115 GtkTreeViewColumn *total_report_column;
116 GtkTreeViewColumn *notes_column;
118 gboolean show_account_color;
120 } GncTreeViewAccountPrivate;
127 G_DEFINE_TYPE(GncTreeViewAccount, gnc_tree_view_account, GNC_TYPE_TREE_VIEW)
130 gnc_tree_view_account_class_init (GncTreeViewAccountClass *klass)
132 GObjectClass *o_class;
135 o_class = G_OBJECT_CLASS (klass);
136 o_class->finalize = gnc_tree_view_account_finalize;
138 gnc_hook_add_dangler(HOOK_CURRENCY_CHANGED,
139 (GFunc)gtva_currency_changed_cb, NULL, NULL);
150 gnc_init_account_view_info(AccountViewInfo *avi)
155 avi->include_type[i] = TRUE;
156 avi->show_hidden = FALSE;
160 gnc_tree_view_account_init (GncTreeViewAccount *view)
163 GNC_PREF_ACCOUNT_COLOR,
164 gnc_tree_view_account_color_update,
167 gnc_init_account_view_info(&view->avi);
171 gnc_tree_view_account_finalize (GObject *
object)
173 ENTER(
"view %p",
object);
174 g_return_if_fail (
object != NULL);
175 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (
object));
177 GncTreeViewAccount *view = GNC_TREE_VIEW_ACCOUNT (
object);
180 GNC_PREF_ACCOUNT_COLOR,
181 gnc_tree_view_account_color_update,
183 if (view->filter_destroy)
185 view->filter_destroy(view->filter_data);
186 view->filter_destroy = NULL;
188 view->filter_fn = NULL;
190 G_OBJECT_CLASS (gnc_tree_view_account_parent_class)->finalize (
object);
199 gnc_tree_view_account_hidden_toggled (GtkCellRendererToggle *cell,
200 const gchar *s_path_str,
203 GncTreeViewAccount *tree_view;
209 tree_view = user_data;
210 s_path = gtk_tree_path_new_from_string (s_path_str);
214 hidden = !gtk_cell_renderer_toggle_get_active (cell);
219 gtk_tree_path_free (s_path);
224 gnc_tree_view_account_placeholder_toggled (GtkCellRendererToggle *cell,
225 const gchar *s_path_str,
228 GncTreeViewAccount *tree_view;
231 gboolean placeholder;
234 tree_view = user_data;
235 s_path = gtk_tree_path_new_from_string (s_path_str);
239 placeholder = !gtk_cell_renderer_toggle_get_active (cell);
244 gtk_tree_path_free (s_path);
252 static GtkTreeModel *
253 sort_cb_setup_w_iters (GtkTreeModel *f_model,
254 GtkTreeIter *f_iter_a,
255 GtkTreeIter *f_iter_b,
263 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
264 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
267 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
276 sort_cb_setup (GtkTreeModel *f_model,
277 GtkTreeIter *f_iter_a,
278 GtkTreeIter *f_iter_b,
282 GtkTreeIter iter_a, iter_b;
284 sort_cb_setup_w_iters (f_model, f_iter_a, f_iter_b,
285 &iter_a, &iter_b, account_a, account_b);
289 sort_by_last_reconcile_date (GtkTreeModel *f_model,
290 GtkTreeIter *f_iter1,
291 GtkTreeIter *f_iter2,
294 const Account *account1, *account2;
295 time64 account1_date, account2_date;
297 sort_cb_setup (f_model, f_iter1, f_iter2, &account1, &account2);
305 if (account1_date < account2_date)
307 else if (account1_date > account2_date)
314 sort_by_string (GtkTreeModel *f_model,
315 GtkTreeIter *f_iter1,
316 GtkTreeIter *f_iter2,
320 GtkTreeIter iter1, iter2;
321 const Account *account1, *account2;
323 gint column = GPOINTER_TO_INT(user_data);
326 model = sort_cb_setup_w_iters(f_model, f_iter1, f_iter2, &iter1, &iter2, &account1, &account2);
329 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter1, column, &str1, -1);
330 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter2, column, &str2, -1);
341 sort_by_code (GtkTreeModel *f_model,
342 GtkTreeIter *f_iter_a,
343 GtkTreeIter *f_iter_b,
346 const Account *account_a, *account_b;
348 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
355 sort_by_xxx_value (xaccGetBalanceInCurrencyFn fn,
357 GtkTreeModel *f_model,
358 GtkTreeIter *f_iter_a,
359 GtkTreeIter *f_iter_b,
362 const Account *account_a, *account_b;
364 gnc_numeric balance_a, balance_b;
368 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
371 balance_a = gnc_ui_account_get_balance_full(fn, account_a, recurse, NULL, cur);
372 balance_b = gnc_ui_account_get_balance_full(fn, account_b, recurse, NULL, cur);
381 sort_by_present_value (GtkTreeModel *f_model,
382 GtkTreeIter *f_iter_a,
383 GtkTreeIter *f_iter_b,
386 return sort_by_xxx_value (xaccAccountGetPresentBalanceInCurrency, TRUE,
387 f_model, f_iter_a, f_iter_b, user_data);
391 sort_by_balance_value (GtkTreeModel *f_model,
392 GtkTreeIter *f_iter_a,
393 GtkTreeIter *f_iter_b,
396 return sort_by_xxx_value (xaccAccountGetBalanceInCurrency, TRUE,
397 f_model, f_iter_a, f_iter_b, user_data);
401 sort_by_cleared_value (GtkTreeModel *f_model,
402 GtkTreeIter *f_iter_a,
403 GtkTreeIter *f_iter_b,
406 return sort_by_xxx_value (xaccAccountGetClearedBalanceInCurrency, TRUE,
407 f_model, f_iter_a, f_iter_b, user_data);
411 sort_by_reconciled_value (GtkTreeModel *f_model,
412 GtkTreeIter *f_iter_a,
413 GtkTreeIter *f_iter_b,
416 return sort_by_xxx_value (xaccAccountGetReconciledBalanceInCurrency, TRUE,
417 f_model, f_iter_a, f_iter_b, user_data);
421 sort_by_future_min_value (GtkTreeModel *f_model,
422 GtkTreeIter *f_iter_a,
423 GtkTreeIter *f_iter_b,
426 return sort_by_xxx_value (xaccAccountGetProjectedMinimumBalanceInCurrency, TRUE,
427 f_model, f_iter_a, f_iter_b, user_data);
431 sort_by_total_value (GtkTreeModel *f_model,
432 GtkTreeIter *f_iter_a,
433 GtkTreeIter *f_iter_b,
436 return sort_by_xxx_value (xaccAccountGetBalanceInCurrency, TRUE,
437 f_model, f_iter_a, f_iter_b, user_data);
441 sort_by_hidden (GtkTreeModel *f_model,
442 GtkTreeIter *f_iter_a,
443 GtkTreeIter *f_iter_b,
446 const Account *account_a, *account_b;
447 gboolean flag_a, flag_b;
450 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
458 else if (flag_a < flag_b)
464 sort_by_placeholder (GtkTreeModel *f_model,
465 GtkTreeIter *f_iter_a,
466 GtkTreeIter *f_iter_b,
469 const Account *account_a, *account_b;
470 gboolean flag_a, flag_b;
473 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
481 else if (flag_a < flag_b)
487 sort_by_opening_balance (GtkTreeModel *f_model,
488 GtkTreeIter *f_iter_a,
489 GtkTreeIter *f_iter_b,
492 const Account *account_a, *account_b;
493 gboolean flag_a, flag_b;
496 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
504 else if (flag_a < flag_b)
510 sort_by_xxx_period_value (GtkTreeModel *f_model,
511 GtkTreeIter *f_iter_a,
512 GtkTreeIter *f_iter_b,
520 sort_cb_setup (f_model, f_iter_a, f_iter_b,
523 t1 = gnc_accounting_period_fiscal_start();
524 t2 = gnc_accounting_period_fiscal_end();
526 b1 = xaccAccountGetBalanceChangeForPeriod(acct1, t1, t2, recurse);
527 b2 = xaccAccountGetBalanceChangeForPeriod(acct2, t1, t2, recurse);
536 sort_by_balance_period_value (GtkTreeModel *f_model,
537 GtkTreeIter *f_iter_a,
538 GtkTreeIter *f_iter_b,
541 return sort_by_xxx_period_value (f_model, f_iter_a, f_iter_b, FALSE);
545 sort_by_total_period_value (GtkTreeModel *f_model,
546 GtkTreeIter *f_iter_a,
547 GtkTreeIter *f_iter_b,
550 return sort_by_xxx_period_value (f_model, f_iter_a, f_iter_b, TRUE);
566 tax_info_data_func (GtkTreeViewColumn *col,
567 GtkCellRenderer *renderer,
572 gchar *tax_info = NULL;
575 gtk_tree_model_get(model,
577 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
581 path = gtk_tree_model_get_path(model, iter);
582 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path))
583 g_object_set(renderer,
"text",
584 (tax_info == NULL ?
"" : tax_info), NULL);
587 gchar *tax_info_sub_acct = NULL;
589 gtk_tree_model_get(model,
591 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT,
594 if ((g_strcmp0 (tax_info_sub_acct,
"") == 0) ||
595 (tax_info_sub_acct == NULL))
596 g_object_set(renderer,
"text",
597 (tax_info == NULL ?
"" : tax_info), NULL);
600 if ((g_strcmp0 (tax_info,
"") == 0) ||
602 g_object_set(renderer,
"text",
603 (tax_info_sub_acct == NULL ?
"" : tax_info_sub_acct),
607 gchar *combined_tax_info;
608 combined_tax_info = g_strdup_printf (
"%s; %s",
609 (tax_info == NULL ?
"" : tax_info),
610 (tax_info_sub_acct == NULL ?
"" :
612 g_object_set(renderer,
"text", combined_tax_info, NULL);
613 g_free(combined_tax_info);
616 g_free(tax_info_sub_acct);
619 gtk_tree_path_free(path);
632 update_cell_renderers (GList *renderers, gchar *account_color)
634 GtkCellRenderer *cell;
638 for (node = renderers; node; node = node->next)
641 g_object_set (cell,
"cell-background", account_color, NULL);
653 acc_color_data_func (GtkTreeViewColumn *col,
654 GtkCellRenderer *renderer,
659 gchar *acc_color = NULL, *acc_cond_color = NULL;
665 gtk_tree_model_get(model,
667 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT,
672 if ((item) && (*item !=
'\0'))
673 acc_color = g_strstrip(g_strdup(item));
677 if (acc_color && (!gdk_rgba_parse(&color, acc_color)))
685 GncTreeViewAccount *view = data;
686 if (view->show_account_color)
687 acc_cond_color = acc_color;
689 column_name = g_object_get_data(G_OBJECT(col), PREF_NAME);
690 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
693 if (g_strcmp0(column_name,
"account-color") == 0)
694 update_cell_renderers (renderers, acc_color);
696 update_cell_renderers (renderers, acc_cond_color);
698 g_list_free (renderers);
708 gnc_tree_view_account_color_update (gpointer gsettings, gchar *key, gpointer user_data)
710 GncTreeViewAccount *view;
712 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(user_data));
714 if (g_strcmp0 (key, GNC_PREF_ACCOUNT_COLOR) == 0)
729 gtk_tree_view_column_set_cell_data_func (col, renderer, acc_color_data_func,
730 GTK_TREE_VIEW(view), NULL);
746 GtkTreeModel *model, *f_model, *s_model;
747 GtkTreePath *virtual_root_path = NULL;
748 const gchar *sample_type, *sample_commodity;
749 GtkTreeViewColumn *tax_info_column, *acc_color_column, *acc_balance_limit_column;
750 GtkCellRenderer *renderer;
751 GList *col_list = NULL, *node = NULL;
755 GncTreeViewAccount *view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT,
757 "name",
"gnc-id-account-tree", NULL);
760 view->show_account_color =
gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_COLOR);
767 virtual_root_path = gtk_tree_path_new_first ();
768 f_model = gtk_tree_model_filter_new (model, virtual_root_path);
771 g_object_unref(G_OBJECT(model));
772 if (virtual_root_path)
773 gtk_tree_path_free(virtual_root_path);
776 s_model = gtk_tree_model_sort_new_with_model(f_model);
777 g_object_unref(G_OBJECT(f_model));
778 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
779 g_object_unref(G_OBJECT(s_model));
782 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
789 GNC_ICON_ACCOUNT,
"Expenses:Entertainment",
790 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
791 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
795 GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
796 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
801 GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
802 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
807 GNC_TREE_MODEL_ACCOUNT_COL_CODE,
808 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
812 "Sample account description.",
813 GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
814 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
818 GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
819 GNC_TREE_VIEW_COLUMN_COLOR_NONE,
820 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
824 SAMPLE_ACCOUNT_VALUE,
825 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
826 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
827 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
828 sort_by_present_value);
829 view->present_report_column
831 SAMPLE_ACCOUNT_VALUE,
832 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
833 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
834 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
835 sort_by_present_value);
838 SAMPLE_ACCOUNT_VALUE,
839 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
840 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
841 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
842 sort_by_balance_value);
843 view->balance_report_column
845 SAMPLE_ACCOUNT_VALUE,
846 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
847 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
848 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
849 sort_by_balance_value);
852 SAMPLE_ACCOUNT_VALUE,
853 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD,
854 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
855 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
856 sort_by_balance_period_value);
859 SAMPLE_ACCOUNT_VALUE,
860 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
861 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
862 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
863 sort_by_cleared_value);
864 view->cleared_report_column
866 SAMPLE_ACCOUNT_VALUE,
867 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
868 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
869 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
870 sort_by_cleared_value);
873 SAMPLE_ACCOUNT_VALUE,
874 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
875 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
876 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
877 sort_by_reconciled_value);
878 view->reconciled_report_column
880 SAMPLE_ACCOUNT_VALUE,
881 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
882 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
883 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
884 sort_by_reconciled_value);
887 "Last Reconcile Date",
888 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
889 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
890 sort_by_last_reconcile_date);
893 SAMPLE_ACCOUNT_VALUE,
894 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
895 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
896 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
897 sort_by_future_min_value);
898 view->future_min_report_column
900 SAMPLE_ACCOUNT_VALUE,
901 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
902 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
903 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
904 sort_by_future_min_value);
907 SAMPLE_ACCOUNT_VALUE,
908 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
909 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
910 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
911 sort_by_total_value);
912 view->total_report_column
914 SAMPLE_ACCOUNT_VALUE,
915 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
916 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
917 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
918 sort_by_total_value);
921 SAMPLE_ACCOUNT_VALUE,
922 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
923 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
924 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
925 sort_by_total_period_value);
931 GNC_TREE_VIEW_COLUMN_DATA_NONE,
932 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
936 g_object_set_data_full(G_OBJECT(acc_color_column), REAL_TITLE,
937 g_strdup(_(
"Account Color")), g_free);
940 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_color_column), _(
"Account Color"));
942 acc_balance_limit_column
944 C_(
"Column header for 'Balance Limit'",
"L"),
945 "account-balance-limit",
947 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT,
948 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
952 g_object_set_data_full(G_OBJECT(acc_balance_limit_column), REAL_TITLE,
953 g_strdup(_(
"Balance Limit")), g_free);
956 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_balance_limit_column), _(
"Balance Limit"));
960 "Sample account notes.",
961 GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
962 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
968 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
969 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
973 gtk_tree_view_column_set_cell_data_func(tax_info_column,
980 C_(
"Column header for 'Hidden'",
"H"),
982 GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
983 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
985 gnc_tree_view_account_hidden_toggled);
988 C_(
"Column header for 'Placeholder'",
"P"),
990 GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
991 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
993 gnc_tree_view_account_placeholder_toggled);
996 C_(
"Column header for 'Opening Balance'",
"O"),
998 GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE,
999 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1000 sort_by_opening_balance,
1004 col_list = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
1005 for (node = col_list; node; node = node->next)
1008 gtk_tree_view_column_set_cell_data_func(node->data,
1010 acc_color_data_func,
1011 GTK_TREE_VIEW(view),
1014 g_list_free (col_list);
1017 gtva_update_column_names(view);
1021 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
1022 gnc_tree_view_account_filter_helper,
1027 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
1028 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
1029 GTK_SORT_ASCENDING);
1032 gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(view), gnc_tree_view_search_compare, NULL, NULL);
1034 g_signal_connect (G_OBJECT(view),
"query-tooltip",
1035 G_CALLBACK(gnc_tree_view_tooltip_cb), NULL);
1037 gtk_widget_show(GTK_WIDGET(view));
1039 return GTK_TREE_VIEW(view);
1053 root = gnc_book_get_root_account (gnc_get_current_book ());
1061 #define debug_path(fn, path) { \ 1062 gchar *path_string = gtk_tree_path_to_string(path); \ 1063 fn("tree path %s", path_string); \ 1064 g_free(path_string); \ 1067 static GtkTreePath *
1068 gnc_tree_view_account_get_path_from_account (GncTreeViewAccount *view,
1071 GtkTreeModel *model, *f_model, *s_model;
1072 GtkTreePath *path, *f_path, *s_path;
1076 if (account == NULL)
1078 LEAVE(
"no account");
1083 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1084 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1085 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1094 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), path);
1095 gtk_tree_path_free(path);
1098 LEAVE(
"no filter path");
1103 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path);
1104 gtk_tree_path_free(f_path);
1105 debug_path(
LEAVE, s_path);
1110 gnc_tree_view_account_get_iter_from_account (GncTreeViewAccount *view,
1112 GtkTreeIter *s_iter)
1114 GtkTreeModel *model, *f_model, *s_model;
1115 GtkTreeIter iter, f_iter;
1117 g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view), FALSE);
1118 g_return_val_if_fail(account != NULL, FALSE);
1119 g_return_val_if_fail(s_iter != NULL, FALSE);
1124 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1125 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1126 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1128 GNC_TREE_MODEL_ACCOUNT(model), account, &iter))
1130 LEAVE(
"model_get_iter_from_account failed");
1135 gtk_tree_model_filter_convert_child_iter_to_iter (
1136 GTK_TREE_MODEL_FILTER(f_model), &f_iter, &iter);
1137 gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT(s_model),
1147 GtkTreeModel *s_model;
1153 if (account == NULL)
1155 LEAVE(
"no account");
1159 if (!gnc_tree_view_account_get_iter_from_account (view, account, &s_iter))
1161 LEAVE(
"view_get_iter_from_account failed");
1166 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1167 num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
1168 LEAVE(
"%d children", num_children);
1169 return num_children;
1175 GtkTreeModel *model, *f_model, *s_model;
1177 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
1178 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(s_model));
1179 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(f_model));
1194 AccountViewInfo *avi)
1196 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1197 g_return_if_fail(avi != NULL);
1208 AccountViewInfo *avi)
1211 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1212 g_return_if_fail(avi != NULL);
1217 view, gnc_tree_view_account_filter_by_view_info,
1224 gnc_tree_view_account_filter_helper (GtkTreeModel *model,
1229 GncTreeViewAccount *view = data;
1231 g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), FALSE);
1232 g_return_val_if_fail (iter != NULL, FALSE);
1235 GNC_TREE_MODEL_ACCOUNT(model), iter);
1237 if (view->filter_fn)
1238 return view->filter_fn(account, view->filter_data);
1253 GSourceFunc destroy)
1255 ENTER(
"view %p, filter func %p, data %p, destroy %p",
1256 view, func, data, destroy);
1258 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1260 if (view->filter_destroy)
1262 view->filter_destroy(view->filter_data);
1264 view->filter_destroy = destroy;
1265 view->filter_data = data;
1266 view->filter_fn = func;
1278 GtkTreeModel *f_model, *s_model;
1280 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1282 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1283 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1284 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
1288 gnc_tree_view_account_filter_by_view_info(
Account* acct, gpointer data)
1291 AccountViewInfo* avi = (AccountViewInfo*)data;
1293 g_return_val_if_fail(GNC_IS_ACCOUNT(acct), FALSE);
1296 if (!avi->include_type[acct_type])
return FALSE;
1311 GtkTreePath *s_path)
1313 GtkTreeModel *model, *f_model, *s_model;
1314 GtkTreePath *path, *f_path;
1318 ENTER(
"view %p", view);
1319 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1320 g_return_val_if_fail (s_path != NULL, NULL);
1322 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1323 f_path = gtk_tree_model_sort_convert_path_to_child_path (
1324 GTK_TREE_MODEL_SORT (s_model), s_path);
1327 LEAVE(
"no filter path");
1331 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1332 path = gtk_tree_model_filter_convert_path_to_child_path (
1333 GTK_TREE_MODEL_FILTER (f_model), f_path);
1334 gtk_tree_path_free(f_path);
1341 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1342 if (!gtk_tree_model_get_iter (model, &iter, path))
1348 account = iter.user_data;
1349 gtk_tree_path_free(path);
1357 GtkTreeIter *s_iter)
1359 GtkTreeModel *model, *f_model;
1360 GtkTreeIter iter, f_iter;
1363 g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1364 g_return_val_if_fail (s_iter != NULL, NULL);
1366 ENTER(
"model %p, iter %p", s_model, s_iter);
1368 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1371 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1372 gtk_tree_model_filter_convert_iter_to_child_iter (
1373 GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1374 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1376 GNC_TREE_MODEL_ACCOUNT(model), &iter);
1389 GtkTreeSelection *selection;
1390 GtkTreeModel *f_model, *s_model;
1391 GtkTreeIter iter, f_iter, s_iter;
1393 GtkSelectionMode mode;
1395 ENTER(
"view %p", view);
1396 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1398 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1399 mode = gtk_tree_selection_get_mode(selection);
1400 if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
1404 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
1406 LEAVE(
"no account, get_selected failed");
1410 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1413 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1414 gtk_tree_model_filter_convert_iter_to_child_iter (
1415 GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
1417 account = iter.user_data;
1430 GtkTreeModel *model, *f_model, *s_model;
1431 GtkTreePath *path, *f_path, *s_path, *parent_path;
1432 GtkTreeSelection *selection;
1434 ENTER(
"view %p, account %p (%s)", view,
1436 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1439 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1440 gtk_tree_selection_unselect_all (selection);
1442 if (account == NULL)
1445 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1446 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1447 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1450 GNC_TREE_MODEL_ACCOUNT(model), account);
1456 debug_path(
DEBUG, path);
1458 f_path = gtk_tree_model_filter_convert_child_path_to_path (
1459 GTK_TREE_MODEL_FILTER (f_model), path);
1460 gtk_tree_path_free(path);
1463 LEAVE(
"no filter path");
1466 debug_path(
DEBUG, f_path);
1468 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1470 gtk_tree_path_free(f_path);
1473 LEAVE(
"no sort path");
1478 parent_path = gtk_tree_path_copy (s_path);
1479 if (gtk_tree_path_up (parent_path))
1484 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1486 gtk_tree_path_free(parent_path);
1488 gtk_tree_selection_select_path (selection, s_path);
1492 while (gtk_events_pending ())
1493 gtk_main_iteration ();
1494 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1495 debug_path(
LEAVE, s_path);
1496 gtk_tree_path_free(s_path);
1503 GncTreeViewAccount* view;
1512 get_selected_accounts_helper (GtkTreeModel *s_model,
1513 GtkTreePath *s_path,
1514 GtkTreeIter *s_iter,
1518 GtkTreeModel *f_model;
1519 GtkTreeIter iter, f_iter;
1522 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1525 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1526 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
1528 account = iter.user_data;
1531 if (gtvsi->view->filter_fn == NULL || gtvsi->view->filter_fn(account, gtvsi->view->filter_data))
1533 gtvsi->return_list = g_list_prepend (gtvsi->return_list, account);
1547 GtkTreeSelection *selection;
1550 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1552 info.return_list = NULL;
1554 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1555 gtk_tree_selection_selected_foreach(selection, get_selected_accounts_helper, &info);
1556 info.return_list = g_list_reverse (info.return_list);
1557 return info.return_list;
1566 GList *account_list,
1569 GtkTreeModel *model, *f_model, *s_model;
1570 GtkTreePath *path, *f_path, *s_path, *parent_path;
1571 GtkTreeSelection *selection;
1575 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1577 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1578 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1579 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1582 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1583 gtk_tree_selection_unselect_all (selection);
1584 gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
1587 for (element = account_list; element; )
1589 account = element->data;
1590 element = g_list_next(element);
1592 if (account == NULL)
1611 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
1613 gtk_tree_path_free(path);
1617 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1619 gtk_tree_path_free(f_path);
1624 parent_path = gtk_tree_path_copy (s_path);
1625 if (gtk_tree_path_up (parent_path))
1630 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1632 gtk_tree_path_free(parent_path);
1634 gtk_tree_selection_select_path (selection, s_path);
1635 if (show_last && (element == NULL))
1636 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1637 gtk_tree_path_free(s_path);
1648 GtkTreeModel *s_model;
1649 GtkTreeSelection *selection;
1650 GtkTreePath *sp_account, *sp_start, *sp_end;
1651 GtkTreeIter si_account, si_start, si_end;
1652 gboolean have_start, have_end = FALSE;
1657 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1659 if (account == NULL)
1661 LEAVE(
"no account");
1665 if (!gnc_tree_view_account_get_iter_from_account (view, account, &si_account))
1667 LEAVE(
"view_get_iter_from_account failed");
1672 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1673 num_children = gtk_tree_model_iter_n_children(s_model, &si_account);
1674 if (num_children == 0)
1676 LEAVE(
"no children");
1681 sp_account = gtk_tree_model_get_path (s_model, &si_account);
1682 gtk_tree_view_expand_row (GTK_TREE_VIEW(view), sp_account, TRUE);
1685 have_start = gtk_tree_model_iter_nth_child(s_model, &si_start, &si_account, 0);
1686 si_end = si_account;
1687 while (num_children)
1689 GtkTreeIter tmp_iter = si_end;
1690 have_end = gtk_tree_model_iter_nth_child(s_model, &si_end, &tmp_iter,
1693 num_children = gtk_tree_model_iter_n_children(s_model, &si_end);
1698 if (have_start && have_end)
1700 sp_start = gtk_tree_model_get_path (s_model, &si_start);
1701 sp_end = gtk_tree_model_get_path (s_model, &si_end);
1704 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1705 gtk_tree_selection_select_range (selection, sp_start, sp_end);
1708 gtk_tree_path_free(sp_start);
1709 gtk_tree_path_free(sp_end);
1711 gtk_tree_path_free(sp_account);
1722 g_return_if_fail(view != NULL);
1723 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1724 ENTER(
"view %p, account %p", view, account);
1726 path = gnc_tree_view_account_get_path_from_account(view, account);
1729 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1730 gtk_tree_path_free(path);
1742 GtkTreePath *s_path;
1745 ENTER(
"view %p", view);
1746 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1748 gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1751 LEAVE(
"no account");
1756 gtk_tree_path_free(s_path);
1767 gtva_update_column_name (GtkTreeViewColumn *column,
1769 const gchar *mnemonic)
1773 g_return_if_fail(column);
1775 name = g_strdup_printf(fmt, mnemonic);
1776 gtk_tree_view_column_set_title(column, name);
1782 gtva_update_column_names (GncTreeViewAccount *view)
1786 gtva_update_column_name(view->present_report_column,
1788 _(
"Present (%s)"), mnemonic);
1789 gtva_update_column_name(view->balance_report_column,
1791 _(
"Balance (%s)"), mnemonic);
1792 gtva_update_column_name(view->cleared_report_column,
1794 _(
"Cleared (%s)"), mnemonic);
1795 gtva_update_column_name(view->reconciled_report_column,
1797 _(
"Reconciled (%s)"), mnemonic);
1798 gtva_update_column_name(view->future_min_report_column,
1800 _(
"Future Minimum (%s)"), mnemonic);
1801 gtva_update_column_name(view->total_report_column,
1803 _(
"Total (%s)"), mnemonic);
1810 gtva_currency_changed_cb (
void)
1812 const GList *views, *ptr;
1815 for (ptr = views; ptr; ptr = g_list_next(ptr))
1817 gtva_update_column_names (ptr->data);
1824 account_cell_property_data_func (GtkTreeViewColumn *tree_column,
1825 GtkCellRenderer *cell,
1826 GtkTreeModel *s_model,
1827 GtkTreeIter *s_iter,
1830 GncTreeViewAccount *view;
1832 gchar *
string = NULL;
1834 g_return_if_fail (GTK_IS_TREE_MODEL_SORT (s_model));
1838 string = g_strdup (
"");
1840 g_object_set (G_OBJECT (cell),
"text",
string,
"xalign", 0.0, NULL);
1843 view = g_object_get_data(G_OBJECT(tree_column),
"tree-view");
1845 if (GNC_IS_TREE_VIEW_ACCOUNT (view))
1846 acc_color_data_func (tree_column, cell, s_model, s_iter, view);
1852 const gchar *column_title,
1853 const gchar *propname)
1855 GtkCellRenderer *renderer;
1856 GtkTreeViewColumn *column;
1858 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1859 g_return_val_if_fail (propname != NULL, NULL);
1862 propname, NULL,
"Sample text",
1868 g_object_set (G_OBJECT (renderer),
"xalign", 1.0, NULL);
1871 g_object_set_data(G_OBJECT(column),
"tree-view", (gpointer)view);
1873 gtk_tree_view_column_set_cell_data_func (column, renderer,
1874 account_cell_property_data_func,
1875 g_strdup(propname), g_free);
1879 static void col_edited_helper(GtkCellRendererText *cell, gchar *path_string,
1880 gchar *new_text, gpointer _s_model)
1883 GtkTreeModel *s_model;
1885 GncTreeViewAccountColumnTextEdited col_edited_cb;
1886 GtkTreeViewColumn *col;
1888 col_edited_cb = g_object_get_data(G_OBJECT(cell),
1889 "column_edited_callback");
1890 col = GTK_TREE_VIEW_COLUMN(g_object_get_data(G_OBJECT(cell),
1892 s_model = GTK_TREE_MODEL(_s_model);
1894 if (!gtk_tree_model_get_iter_from_string(s_model, &s_iter, path_string))
1898 col_edited_cb(account, col, new_text);
1901 static void col_source_helper(GtkTreeViewColumn *col, GtkCellRenderer *cell,
1902 GtkTreeModel *s_model, GtkTreeIter *s_iter,
1903 gpointer _col_source_cb)
1907 GncTreeViewAccountColumnSource col_source_cb;
1909 g_return_if_fail (GTK_IS_TREE_MODEL_SORT (s_model));
1910 col_source_cb = (GncTreeViewAccountColumnSource) _col_source_cb;
1912 text = col_source_cb(account, col, cell);
1913 g_object_set (G_OBJECT (cell),
"text", text,
"xalign", 1.0, NULL);
1922 gtva_setup_column_renderer_edited_cb(GncTreeViewAccount *account_view,
1923 GtkTreeViewColumn *column,
1924 GtkCellRenderer *renderer,
1925 GncTreeViewAccountColumnTextEdited col_edited_cb)
1927 GtkTreeModel *s_model;
1929 if (col_edited_cb == NULL)
1931 g_object_set(G_OBJECT(renderer),
"editable", FALSE, NULL);
1932 g_object_set_data(G_OBJECT(renderer),
"column_edited_callback", col_edited_cb);
1933 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(account_view));
1934 g_signal_handlers_disconnect_by_func(G_OBJECT(renderer), col_edited_cb, s_model);
1935 g_object_set_data(G_OBJECT(renderer),
"column_view", column);
1939 g_object_set(G_OBJECT(renderer),
"editable", TRUE, NULL);
1940 g_object_set_data(G_OBJECT(renderer),
"column_edited_callback",
1942 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(account_view));
1943 g_signal_connect(G_OBJECT(renderer),
"edited",
1944 (GCallback) col_edited_helper, s_model);
1945 g_object_set_data(G_OBJECT(renderer),
"column_view", column);
1951 const gchar *column_title,
1952 GncTreeViewAccountColumnSource
1954 GncTreeViewAccountColumnTextEdited
1957 GtkCellRenderer *renderer;
1959 g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view), NULL);
1961 renderer = gtk_cell_renderer_text_new();
1963 return gnc_tree_view_account_add_custom_column_renderer(
1964 account_view, column_title, col_source_cb, col_edited_cb, renderer);
1968 gnc_tree_view_account_add_custom_column_renderer(GncTreeViewAccount *account_view,
1969 const gchar *column_title,
1970 GncTreeViewAccountColumnSource
1972 GncTreeViewAccountColumnTextEdited
1974 GtkCellRenderer *renderer)
1976 GtkTreeViewColumn *column;
1978 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (account_view), NULL);
1980 g_object_set (G_OBJECT (renderer),
"xalign", 1.0, NULL);
1982 column = gtk_tree_view_column_new_with_attributes (column_title,
1986 gtva_setup_column_renderer_edited_cb(account_view, column,
1987 renderer, col_edited_cb);
1989 gtk_tree_view_column_set_cell_data_func (column, renderer,
1991 col_source_cb, NULL);
1998 #define FILTER_TREE_VIEW "types_tree_view" 2022 if (g_hash_table_size (fd->filter_override) > 0)
2025 test_acc = g_hash_table_lookup (fd->filter_override, account);
2026 if (test_acc != NULL)
2028 LEAVE(
" filter: override");
2035 LEAVE(
" hide: hidden");
2039 if (!fd->show_zero_total)
2041 total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
2044 LEAVE(
" hide: zero balance");
2049 if (!fd->show_unused)
2051 if (gnc_account_and_descendants_empty(account))
2053 LEAVE(
" hide: unused");
2059 result = (fd->visible_types & (1 << acct_type)) ? TRUE : FALSE;
2060 LEAVE(
" %s", result ?
"show" :
"hide");
2075 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2077 ENTER(
"button %p", button);
2078 fd->show_hidden = gtk_toggle_button_get_active(button);
2080 LEAVE(
"show_hidden %d", fd->show_hidden);
2094 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2096 ENTER(
"button %p", button);
2097 fd->show_zero_total = gtk_toggle_button_get_active(button);
2099 LEAVE(
"show_zero %d", fd->show_zero_total);
2113 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2115 ENTER(
"button %p", button);
2116 fd->show_unused = gtk_toggle_button_get_active(button);
2118 LEAVE(
"show_unused %d", fd->show_unused);
2133 g_return_if_fail(GTK_IS_BUTTON(button));
2135 ENTER(
"button %p", button);
2136 fd->visible_types = 0;
2137 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2139 LEAVE(
"types 0x%x", fd->visible_types);
2152 g_return_if_fail(GTK_IS_BUTTON(button));
2154 ENTER(
"button %p", button);
2155 fd->visible_types = -1;
2156 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2158 LEAVE(
"types 0x%x", fd->visible_types);
2172 ENTER(
"button %p", button);
2189 gppat_filter_visible_set_func (GtkTreeViewColumn *column,
2190 GtkCellRenderer *renderer,
2191 GtkTreeModel *model,
2199 gtk_tree_model_get(model, iter, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
2201 active = (fd->visible_types & (1 << type)) ? TRUE : FALSE;
2202 g_object_set (G_OBJECT (renderer),
"active", active, NULL);
2211 gppat_filter_visible_toggled_cb (GtkCellRendererToggle *renderer,
2215 GtkTreeModel *model = fd->model;
2220 ENTER(
"toggled %p", path_str);
2221 path = gtk_tree_path_new_from_string(path_str);
2223 if (gtk_tree_model_get_iter(model, &iter, path))
2225 gtk_tree_model_get(model, &iter, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
2226 fd->visible_types ^= (1 << type);
2229 gtk_tree_path_free(path);
2230 LEAVE(
"types 0x%x", fd->visible_types);
2250 g_return_if_fail(GTK_IS_DIALOG(dialog));
2252 ENTER(
"dialog %p, response %d", dialog, response);
2254 if (response != GTK_RESPONSE_OK)
2256 fd->visible_types = fd->original_visible_types;
2257 fd->show_hidden = fd->original_show_hidden;
2258 fd->show_zero_total = fd->original_show_zero_total;
2259 fd->show_unused = fd->original_show_unused;
2264 gptemp = (gpointer)fd->dialog;
2265 g_atomic_pointer_compare_and_exchange(&gptemp,
2266 (gpointer)dialog, NULL);
2267 fd->dialog = gptemp;
2268 gtk_widget_destroy(dialog);
2269 LEAVE(
"types 0x%x", fd->visible_types);
2275 GtkWidget *dialog, *button;
2277 GtkCellRenderer *renderer;
2278 GtkBuilder *builder;
2281 ENTER(
"(fd %p, page %p)", fd, page);
2285 gtk_window_present(GTK_WINDOW(fd->dialog));
2286 LEAVE(
"existing dialog");
2291 builder = gtk_builder_new();
2292 gnc_builder_add_from_file (builder,
"dialog-account.glade",
"account_filter_by_dialog");
2293 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"account_filter_by_dialog"));
2294 fd->dialog = dialog;
2295 gtk_window_set_transient_for(GTK_WINDOW(dialog),
2296 GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
2298 title = g_strdup_printf(_(
"Filter %s by..."),
2300 gtk_window_set_title(GTK_WINDOW(dialog), title);
2304 fd->original_visible_types = fd->visible_types;
2305 fd->original_show_hidden = fd->show_hidden;
2306 fd->original_show_zero_total = fd->show_zero_total;
2307 fd->original_show_unused = fd->show_unused;
2310 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_hidden"));
2311 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2313 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_zero"));
2314 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2315 fd->show_zero_total);
2316 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_unused"));
2317 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2321 view = GTK_TREE_VIEW(gtk_builder_get_object (builder, FILTER_TREE_VIEW));
2323 fd->model = gnc_tree_model_account_types_filter_using_mask
2325 gtk_tree_view_set_model(view, fd->model);
2326 g_object_unref (fd->model);
2328 renderer = gtk_cell_renderer_toggle_new();
2330 g_signal_connect(renderer,
"toggled",
2331 G_CALLBACK(gppat_filter_visible_toggled_cb), fd);
2333 gtk_tree_view_insert_column_with_data_func (view, -1, NULL, renderer,
2334 gppat_filter_visible_set_func, fd, NULL);
2336 gtk_tree_view_insert_column_with_attributes (view,
2337 -1, _(
"Account Types"), gtk_cell_renderer_text_new(),
2338 "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL);
2341 gtk_builder_connect_signals(builder, fd);
2342 g_object_unref(G_OBJECT(builder));
2345 gtk_widget_show_all(dialog);
2350 #define ACCT_COUNT "NumberOfOpenAccounts" 2351 #define ACCT_OPEN "OpenAccount%d" 2352 #define ACCT_SELECTED "SelectedAccount" 2353 #define SHOW_HIDDEN "ShowHidden" 2354 #define SHOW_ZERO "ShowZeroTotal" 2355 #define SHOW_UNUSED "ShowUnused" 2356 #define ACCT_TYPES "AccountTypes" 2360 #define SHOW_HIDDEN_ACCOUNTS "Show_Hidden" 2361 #define SHOW_ZERO_TOTALS "Show_ZeroTotal" 2362 #define SHOW_UNUSED_ACCOUNTS "Show_Unused" 2363 #define ACCOUNT_TYPES "Account_Types" 2369 const gchar *group_name;
2385 tree_save_expanded_row (GncTreeViewAccount *view,
2390 bar_t *bar = user_data;
2392 gchar *account_name;
2395 if (account == NULL)
2399 if (account_name == NULL)
2402 key = g_strdup_printf(ACCT_OPEN, ++bar->count);
2403 g_key_file_set_string(bar->key_file, bar->group_name, key, account_name);
2405 g_free(account_name);
2420 tree_save_selected_row (GncTreeViewAccount *view,
2424 bar_t *bar = user_data;
2425 gchar *account_name;
2428 if (account == NULL)
2432 if (account_name == NULL)
2435 g_key_file_set_string(bar->key_file, bar->group_name, ACCT_SELECTED,
2437 g_free(account_name);
2441 gnc_tree_view_account_save(GncTreeViewAccount *view,
2443 GKeyFile *key_file,
const gchar *group_name)
2447 g_return_if_fail (key_file != NULL);
2448 g_return_if_fail (group_name != NULL);
2450 ENTER(
"view %p, key_file %p, group_name %s", view, key_file,
2453 g_key_file_set_integer(key_file, group_name, ACCT_TYPES,
2455 g_key_file_set_boolean(key_file, group_name, SHOW_HIDDEN,
2457 g_key_file_set_boolean(key_file, group_name, SHOW_ZERO,
2458 fd->show_zero_total);
2459 g_key_file_set_boolean(key_file, group_name, SHOW_UNUSED,
2462 bar.key_file = key_file;
2463 bar.group_name = group_name;
2465 tree_save_selected_row(view, &bar);
2466 gtk_tree_view_map_expanded_rows(
2467 GTK_TREE_VIEW(view), (GtkTreeViewMappingFunc) tree_save_expanded_row,
2469 g_key_file_set_integer(key_file, group_name, ACCT_COUNT, bar.count);
2475 gnc_tree_view_account_save_filter (GncTreeViewAccount *view,
2478 const gchar *group_name)
2480 g_return_if_fail (key_file != NULL);
2481 g_return_if_fail (group_name != NULL);
2483 ENTER(
"view %p, key_file %p, group_name %s", view, key_file,
2486 g_key_file_set_integer (key_file, group_name, ACCOUNT_TYPES,
2488 g_key_file_set_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS,
2490 g_key_file_set_boolean (key_file, group_name, SHOW_ZERO_TOTALS,
2491 fd->show_zero_total);
2492 g_key_file_set_boolean (key_file, group_name, SHOW_UNUSED_ACCOUNTS,
2505 tree_restore_expanded_row (GncTreeViewAccount *view,
2506 const gchar *account_name)
2512 g_return_if_fail(book);
2528 tree_restore_selected_row (GncTreeViewAccount *view,
2529 const gchar *account_name)
2535 g_return_if_fail(book);
2543 gnc_tree_view_account_restore(GncTreeViewAccount *view,
2545 GKeyFile *key_file,
const gchar *group_name)
2547 GError *error = NULL;
2553 show = g_key_file_get_boolean(key_file, group_name, SHOW_HIDDEN, &error);
2556 g_warning(
"error reading group %s key %s: %s",
2557 group_name, SHOW_HIDDEN, error->message);
2558 g_error_free(error);
2562 fd->show_hidden = show;
2564 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO, &error);
2567 g_warning(
"error reading group %s key %s: %s",
2568 group_name, SHOW_ZERO, error->message);
2569 g_error_free(error);
2573 fd->show_zero_total = show;
2575 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED, &error);
2578 g_warning(
"error reading group %s key %s: %s",
2579 group_name, SHOW_UNUSED, error->message);
2580 g_error_free(error);
2584 fd->show_unused = show;
2586 i = g_key_file_get_integer(key_file, group_name, ACCT_TYPES, &error);
2589 g_warning(
"error reading group %s key %s: %s",
2590 group_name, ACCT_TYPES, error->message);
2591 g_error_free(error);
2595 fd->visible_types = i;
2598 count = g_key_file_get_integer(key_file, group_name, ACCT_COUNT, &error);
2601 for (i = 1; i <= count; i++)
2603 key = g_strdup_printf(ACCT_OPEN, i);
2604 value = g_key_file_get_string(key_file, group_name, key, &error);
2607 g_warning(
"error reading group %s key %s: %s",
2608 group_name, key, error->message);
2609 g_error_free(error);
2614 tree_restore_expanded_row(view, value);
2622 g_warning(
"error reading group %s key %s: %s",
2623 group_name, ACCT_COUNT, error->message);
2624 g_error_free(error);
2628 value = g_key_file_get_string(key_file, group_name, ACCT_SELECTED, NULL);
2631 tree_restore_selected_row(view, value);
2640 gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
2643 const gchar *group_name)
2645 GError *error = NULL;
2649 g_return_if_fail (key_file != NULL);
2650 g_return_if_fail (group_name != NULL);
2655 show = g_key_file_get_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS, &error);
2658 g_error_free (error);
2662 fd->show_hidden = show;
2664 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO_TOTALS, &error);
2667 g_error_free (error);
2671 fd->show_zero_total = show;
2673 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED_ACCOUNTS, &error);
2676 g_error_free (error);
2680 fd->show_unused = show;
2682 i = g_key_file_get_integer(key_file, group_name, ACCOUNT_TYPES, &error);
2685 g_error_free (error);
2689 fd->visible_types = i;
2694 gnc_tree_view_account_name_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_name)
2702 if (existing != NULL && existing != account)
2704 PERR(
"account with the same name [%s] already exists.", new_name);
2712 gnc_tree_view_account_code_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_code)
2720 gnc_tree_view_account_description_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_desc)
2728 gnc_tree_view_account_notes_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_notes)
2736 gtva_set_column_editor(GncTreeViewAccount *view,
2737 GtkTreeViewColumn *column,
2738 GncTreeViewAccountColumnTextEdited edited_cb)
2740 GList *renderers_orig, *renderers;
2741 GtkCellRenderer *renderer = NULL;
2745 for (renderers_orig = renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
2746 renderers && !GTK_IS_CELL_RENDERER_TEXT(renderers->data);
2747 renderers = renderers->next);
2749 renderer = GTK_CELL_RENDERER(renderers->data);
2750 g_list_free(renderers_orig);
2751 g_return_if_fail(renderer != NULL);
2752 gtva_setup_column_renderer_edited_cb(GNC_TREE_VIEW_ACCOUNT(view), column, renderer, edited_cb);
2756 gnc_tree_view_account_set_name_edited(GncTreeViewAccount *view,
2757 GncTreeViewAccountColumnTextEdited edited_cb)
2759 gtva_set_column_editor(view, view->name_column, edited_cb);
2763 gnc_tree_view_account_set_code_edited(GncTreeViewAccount *view,
2764 GncTreeViewAccountColumnTextEdited edited_cb)
2766 gtva_set_column_editor(view, view->code_column, edited_cb);
2770 gnc_tree_view_account_set_description_edited(GncTreeViewAccount *view,
2771 GncTreeViewAccountColumnTextEdited edited_cb)
2773 gtva_set_column_editor(view, view->desc_column, edited_cb);
2777 gnc_tree_view_account_set_notes_edited(GncTreeViewAccount *view,
2778 GncTreeViewAccountColumnTextEdited edited_cb)
2780 gtva_set_column_editor(view, view->notes_column, edited_cb);
2784 gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
2785 const gchar *key, GtkTreeIter *iter, gpointer search_data)
2787 gchar *normalized_key;
2788 gchar *case_normalized_key = NULL;
2789 gboolean match = FALSE;
2791 normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_NFC);
2793 case_normalized_key = g_utf8_casefold (normalized_key, -1);
2794 if (case_normalized_key)
2800 gchar *normalized_string;
2801 gchar *case_normalized_string = NULL;
2807 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_NAME,&str,-1);
2810 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_CODE,&str,-1);
2813 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,&str,-1);
2820 normalized_string = g_utf8_normalize (str, -1, G_NORMALIZE_NFC);
2821 if (normalized_string)
2822 case_normalized_string = g_utf8_casefold (normalized_string, -1);
2823 if (case_normalized_string&&NULL!=strstr(case_normalized_string,case_normalized_key))
2827 g_free (normalized_string);
2828 g_free (case_normalized_string);
2835 g_free (normalized_key);
2836 g_free (case_normalized_key);
2843 GFunc editing_started_cb, gpointer editing_cb_data)
2846 editing_started_cb, editing_cb_data);
2850 GFunc editing_finished_cb, gpointer editing_cb_data)
2853 editing_finished_cb, editing_cb_data);
2858 gnc_tree_view_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_tip,
2859 GtkTooltip *tooltip, gpointer user_data)
2861 GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
2862 GtkTreePath *path = NULL;
2863 GtkTreeViewColumn *column = NULL;
2864 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &x, &y);
2865 if (keyboard_tip || !gtk_tree_view_get_path_at_pos (tree_view, x, y, &path,
2866 &column, NULL, NULL))
2868 gtk_tree_path_free (path);
2873 gboolean show_tooltip =
false;
2874 GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
2876 if (gtk_tree_model_get_iter (model, &iter, path) && column)
2881 switch (gtk_tree_view_column_get_sort_column_id (column))
2883 case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT:
2884 gtk_tree_model_get (model, &iter,
2885 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT_EXPLANATION, &ttip,
2895 show_tooltip =
true;
2896 gtk_tooltip_set_text (tooltip, ttip);
2897 gtk_tree_view_set_tooltip_cell (tree_view, tooltip, path, column, NULL);
2903 gtk_tree_path_free (path);
2904 return show_tooltip;
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
void gnc_tree_view_account_get_view_info(GncTreeViewAccount *view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will copy the current con...
GtkTreeViewColumn * gnc_tree_view_account_add_property_column(GncTreeViewAccount *view, const gchar *column_title, const gchar *propname)
Add a new column to the set of columns in an account tree view.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
The instance data structure for a content plugin.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic 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.
GList * gnc_tree_view_account_get_selected_accounts(GncTreeViewAccount *view)
This function returns a list of the accounts associated with the selected items in the account tree v...
Account * gnc_tree_view_account_get_cursor_account(GncTreeViewAccount *view)
This function returns the account in the account tree view at the current location of the cursor...
void xaccAccountSetNotes(Account *acc, const char *str)
Set the account's notes.
void gnc_tree_view_account_set_editing_finished_cb(GncTreeViewAccount *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup the callback for when the user finishes editing the account tree so actions can be enabled like...
int safe_utf8_collate(const char *da, const char *db)
Collate two UTF-8 strings.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
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 th...
void gppat_filter_response_cb(GtkWidget *dialog, gint response, AccountFilterDialog *fd)
The Filter dialog was closed.
const char * xaccAccountGetCode(const Account *acc)
Get the account's accounting code.
common utilities for manipulating a GtkTreeView within gnucash
#define DEBUG(format, args...)
Print a debugging message.
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
Account * gnc_tree_model_account_get_account(GncTreeModelAccount *model, GtkTreeIter *iter)
Convert a model/iter pair to a gnucash account.
void xaccAccountSetCode(Account *acc, const char *str)
Set the account's accounting code.
void gppat_filter_select_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select all account types" button in the Filter dialog was clicked.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
stop here; the following types just aren't ready for prime time
void gnc_tree_view_account_expand_to_account(GncTreeViewAccount *view, Account *account)
This function forces the account tree expand whatever levels are necessary to make the specified acco...
void gnc_tree_view_account_column_add_color(GncTreeViewAccount *view, GtkTreeViewColumn *col)
Add the account color background data function to the GncTreeViewAccount column to show or not the co...
void gnc_tree_view_account_set_view_info(GncTreeViewAccount *view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will applies the settings...
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.
int gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b.
void gppat_filter_clear_all_cb(GtkWidget *button, AccountFilterDialog *fd)
The "clear all account types" button in the Filter dialog was clicked.
void gnc_tree_view_account_set_editing_started_cb(GncTreeViewAccount *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup the callback for when the user starts editing the account tree so actions can be disabled like ...
#define PERR(format, args...)
Log a serious error.
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.
#define ENTER(format, args...)
Print a function entry debugging message.
gboolean gnc_tree_model_account_get_iter_from_account(GncTreeModelAccount *model, Account *account, GtkTreeIter *iter)
Convert a model/account pair into a gtk_tree_model_iter.
gnc_commodity * gnc_default_report_currency(void)
Return the default currency for use in reports, as set by the user.
void gnc_tree_view_account_set_selected_accounts(GncTreeViewAccount *view, GList *account_list, gboolean show_last)
This function selects a set of accounts in the account tree view.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
void gppat_filter_show_hidden_toggled_cb(GtkToggleButton *button, AccountFilterDialog *fd)
The "show hidden" button in the Filter dialog changed state.
gboolean xaccAccountIsHidden(const Account *acc)
Should this account be "hidden".
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the s...
int xaccAccountOrder(const Account *aa, const Account *ab)
The xaccAccountOrder() subroutine defines a sorting order on accounts.
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.
GtkTreeModel implementation for gnucash account tree.
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 new pixbuf view column to a GncTreeView base view.
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.
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 t...
void gnc_tree_view_account_set_filter(GncTreeViewAccount *view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
This function attaches a filter function to the given account tree.
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...
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
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.
void gnc_tree_model_account_clear_cache(GncTreeModelAccount *model)
Clear the tree model account cached values.
Account handling public routines.
void gnc_tree_view_account_select_subaccounts(GncTreeViewAccount *view, Account *account)
This function selects all sub-accounts of an account in the account tree view.
void xaccAccountSetPlaceholder(Account *acc, gboolean val)
Set the "placeholder" flag for an account.
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
GtkTreeView implementation for gnucash account tree.
GtkTreeModel * gnc_tree_model_account_new(Account *root)
Create a new GtkTreeModel for manipulating gnucash accounts.
GtkTreeViewColumn * gnc_tree_view_account_add_custom_column(GncTreeViewAccount *account_view, const gchar *column_title, GncTreeViewAccountColumnSource col_source_cb, GncTreeViewAccountColumnTextEdited col_edited_cb)
Add a new custom column to the set of columns in an account tree view.
GtkTreeView * gnc_tree_view_account_new_with_root(Account *root, gboolean show_root)
Create a new account tree view.
const char * xaccAccountGetDescription(const Account *acc)
Get the account's description.
GtkTreeView * gnc_tree_view_account_new(gboolean show_root)
Create a new account tree view.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
General utilities for dealing with accounting periods.
gboolean gnc_plugin_page_account_tree_filter_accounts(Account *account, gpointer user_data)
This function tells the account tree view whether or not to filter out a particular account...
void gnc_tree_view_account_clear_model_cache(GncTreeViewAccount *view)
This function clears the tree model account cache so the values will be updated/refreshed.
Account * gnc_tree_view_account_get_account_from_iter(GtkTreeModel *s_model, GtkTreeIter *s_iter)
This function returns the account associated with the specified iter.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
This function returns the account associated with the specified path.
All type declarations for the whole Gnucash engine.
gboolean xaccAccountGetReconcileLastDate(const Account *acc, time64 *last_date)
DOCUMENT ME!
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
GtkTreeModel implementation to display account types in a GtkTreeView.
Generic api to store and retrieve preferences.
gboolean xaccAccountGetIsOpeningBalance(const Account *acc)
Get the "opening-balance" flag for an account.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
void gppat_filter_show_unused_toggled_cb(GtkToggleButton *button, AccountFilterDialog *fd)
The "show unused" button in the Filter dialog changed state.
void xaccAccountSetHidden(Account *acc, gboolean val)
Set the "hidden" flag for an account.
gint gnc_tree_view_account_count_children(GncTreeViewAccount *view, Account *account)
This function determines if an account in the account tree view has any visible children.
GtkTreePath * gnc_tree_model_account_get_path_from_account(GncTreeModelAccount *model, Account *account)
Convert a model/account pair into a gtk_tree_model_path.
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.
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Account * gnc_tree_view_account_get_selected_account(GncTreeViewAccount *view)
This function returns the account associated with the selected item in the account tree view...
gboolean(* gnc_tree_view_account_filter_func)(Account *account, gpointer data)
This is the description of a filter function used by the account tree.
#define LEAVE(format, args...)
Print a function exit debugging message.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void xaccAccountSetDescription(Account *acc, const char *str)
Set the account's description.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
The hidden root account of an account tree.
Commodity handling public routines.
The Credit card account is used to denote credit (e.g.
void gppat_filter_select_default_cb(GtkWidget *button, AccountFilterDialog *fd)
The "select default account types" button in the Filter dialog was clicked.
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.
const char * xaccAccountGetNotes(const Account *acc)
Get the account's notes.
void gppat_filter_show_zero_toggled_cb(GtkToggleButton *button, AccountFilterDialog *fd)
The "show zero totals" button in the Filter dialog changed state.