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);
290 sort_by_earliest_date (GtkTreeModel *f_model, GtkTreeIter *f_iter1, GtkTreeIter *f_iter2,
293 const Account *account1, *account2;
294 sort_cb_setup (f_model, f_iter1, f_iter2, &account1, &account2);
299 date1 == INT64_MAX || date1 < date2 ? -1 : 1;
303 sort_by_last_reconcile_date (GtkTreeModel *f_model,
304 GtkTreeIter *f_iter1,
305 GtkTreeIter *f_iter2,
308 const Account *account1, *account2;
309 time64 account1_date = 0, account2_date = 0;
311 sort_cb_setup (f_model, f_iter1, f_iter2, &account1, &account2);
320 if (account1_date < account2_date)
322 else if (account1_date > account2_date)
329 sort_by_string (GtkTreeModel *f_model,
330 GtkTreeIter *f_iter1,
331 GtkTreeIter *f_iter2,
335 GtkTreeIter iter1, iter2;
336 const Account *account1, *account2;
338 gint column = GPOINTER_TO_INT(user_data);
341 model = sort_cb_setup_w_iters(f_model, f_iter1, f_iter2, &iter1, &iter2, &account1, &account2);
344 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter1, column, &str1, -1);
345 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter2, column, &str2, -1);
356 sort_by_code (GtkTreeModel *f_model,
357 GtkTreeIter *f_iter_a,
358 GtkTreeIter *f_iter_b,
361 const Account *account_a, *account_b;
363 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
370 sort_by_xxx_value (xaccGetBalanceInCurrencyFn fn,
372 GtkTreeModel *f_model,
373 GtkTreeIter *f_iter_a,
374 GtkTreeIter *f_iter_b,
377 const Account *account_a, *account_b;
379 gnc_numeric balance_a, balance_b;
383 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
386 balance_a = gnc_ui_account_get_balance_full(fn, account_a, recurse, NULL, cur);
387 balance_b = gnc_ui_account_get_balance_full(fn, account_b, recurse, NULL, cur);
396 sort_by_present_value (GtkTreeModel *f_model,
397 GtkTreeIter *f_iter_a,
398 GtkTreeIter *f_iter_b,
401 return sort_by_xxx_value (xaccAccountGetPresentBalanceInCurrency, TRUE,
402 f_model, f_iter_a, f_iter_b, user_data);
406 sort_by_balance_value (GtkTreeModel *f_model,
407 GtkTreeIter *f_iter_a,
408 GtkTreeIter *f_iter_b,
411 return sort_by_xxx_value (xaccAccountGetBalanceInCurrency, TRUE,
412 f_model, f_iter_a, f_iter_b, user_data);
416 sort_by_cleared_value (GtkTreeModel *f_model,
417 GtkTreeIter *f_iter_a,
418 GtkTreeIter *f_iter_b,
421 return sort_by_xxx_value (xaccAccountGetClearedBalanceInCurrency, TRUE,
422 f_model, f_iter_a, f_iter_b, user_data);
426 sort_by_reconciled_value (GtkTreeModel *f_model,
427 GtkTreeIter *f_iter_a,
428 GtkTreeIter *f_iter_b,
431 return sort_by_xxx_value (xaccAccountGetReconciledBalanceInCurrency, TRUE,
432 f_model, f_iter_a, f_iter_b, user_data);
436 sort_by_future_min_value (GtkTreeModel *f_model,
437 GtkTreeIter *f_iter_a,
438 GtkTreeIter *f_iter_b,
441 return sort_by_xxx_value (xaccAccountGetProjectedMinimumBalanceInCurrency, TRUE,
442 f_model, f_iter_a, f_iter_b, user_data);
446 sort_by_total_value (GtkTreeModel *f_model,
447 GtkTreeIter *f_iter_a,
448 GtkTreeIter *f_iter_b,
451 return sort_by_xxx_value (xaccAccountGetBalanceInCurrency, TRUE,
452 f_model, f_iter_a, f_iter_b, user_data);
456 sort_by_hidden (GtkTreeModel *f_model,
457 GtkTreeIter *f_iter_a,
458 GtkTreeIter *f_iter_b,
461 const Account *account_a, *account_b;
462 gboolean flag_a, flag_b;
465 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
473 else if (flag_a < flag_b)
479 sort_by_placeholder (GtkTreeModel *f_model,
480 GtkTreeIter *f_iter_a,
481 GtkTreeIter *f_iter_b,
484 const Account *account_a, *account_b;
485 gboolean flag_a, flag_b;
488 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
496 else if (flag_a < flag_b)
502 sort_by_opening_balance (GtkTreeModel *f_model,
503 GtkTreeIter *f_iter_a,
504 GtkTreeIter *f_iter_b,
507 const Account *account_a, *account_b;
508 gboolean flag_a, flag_b;
511 sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
519 else if (flag_a < flag_b)
525 sort_by_xxx_period_value (GtkTreeModel *f_model,
526 GtkTreeIter *f_iter_a,
527 GtkTreeIter *f_iter_b,
535 sort_cb_setup (f_model, f_iter_a, f_iter_b,
538 t1 = gnc_accounting_period_fiscal_start();
539 t2 = gnc_accounting_period_fiscal_end();
541 b1 = xaccAccountGetBalanceChangeForPeriod(acct1, t1, t2, recurse);
542 b2 = xaccAccountGetBalanceChangeForPeriod(acct2, t1, t2, recurse);
551 sort_by_balance_period_value (GtkTreeModel *f_model,
552 GtkTreeIter *f_iter_a,
553 GtkTreeIter *f_iter_b,
556 return sort_by_xxx_period_value (f_model, f_iter_a, f_iter_b, FALSE);
560 sort_by_total_period_value (GtkTreeModel *f_model,
561 GtkTreeIter *f_iter_a,
562 GtkTreeIter *f_iter_b,
565 return sort_by_xxx_period_value (f_model, f_iter_a, f_iter_b, TRUE);
581 tax_info_data_func (GtkTreeViewColumn *col,
582 GtkCellRenderer *renderer,
587 gchar *tax_info = NULL;
590 gtk_tree_model_get(model,
592 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
596 path = gtk_tree_model_get_path(model, iter);
597 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path))
598 g_object_set(renderer,
"text",
599 (tax_info == NULL ?
"" : tax_info), NULL);
602 gchar *tax_info_sub_acct = NULL;
604 gtk_tree_model_get(model,
606 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT,
609 if ((g_strcmp0 (tax_info_sub_acct,
"") == 0) ||
610 (tax_info_sub_acct == NULL))
611 g_object_set(renderer,
"text",
612 (tax_info == NULL ?
"" : tax_info), NULL);
615 if ((g_strcmp0 (tax_info,
"") == 0) ||
617 g_object_set(renderer,
"text",
618 (tax_info_sub_acct == NULL ?
"" : tax_info_sub_acct),
622 gchar *combined_tax_info;
623 combined_tax_info = g_strdup_printf (
"%s; %s",
624 (tax_info == NULL ?
"" : tax_info),
625 (tax_info_sub_acct == NULL ?
"" :
627 g_object_set(renderer,
"text", combined_tax_info, NULL);
628 g_free(combined_tax_info);
631 g_free(tax_info_sub_acct);
634 gtk_tree_path_free(path);
647 update_cell_renderers (GList *renderers, gchar *account_color)
649 GtkCellRenderer *cell;
653 for (node = renderers; node; node = node->next)
656 g_object_set (cell,
"cell-background", account_color, NULL);
668 acc_color_data_func (GtkTreeViewColumn *col,
669 GtkCellRenderer *renderer,
674 gchar *acc_color = NULL, *acc_cond_color = NULL;
680 gtk_tree_model_get(model,
682 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT,
687 if ((item) && (*item !=
'\0'))
688 acc_color = g_strstrip(g_strdup(item));
692 if (acc_color && (!gdk_rgba_parse(&color, acc_color)))
700 GncTreeViewAccount *view = data;
701 if (view->show_account_color)
702 acc_cond_color = acc_color;
704 column_name = g_object_get_data(G_OBJECT(col), PREF_NAME);
705 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
708 if (g_strcmp0(column_name,
"account-color") == 0)
709 update_cell_renderers (renderers, acc_color);
711 update_cell_renderers (renderers, acc_cond_color);
713 g_list_free (renderers);
723 gnc_tree_view_account_color_update (gpointer gsettings, gchar *key, gpointer user_data)
725 GncTreeViewAccount *view;
727 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(user_data));
729 if (g_strcmp0 (key, GNC_PREF_ACCOUNT_COLOR) == 0)
744 gtk_tree_view_column_set_cell_data_func (col, renderer, acc_color_data_func,
745 GTK_TREE_VIEW(view), NULL);
761 GtkTreeModel *model, *f_model, *s_model;
762 GtkTreePath *virtual_root_path = NULL;
763 const gchar *sample_type, *sample_commodity;
764 GtkTreeViewColumn *tax_info_column, *acc_color_column, *acc_balance_limit_column;
765 GtkCellRenderer *renderer;
766 GList *col_list = NULL, *node = NULL;
770 GncTreeViewAccount *view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT,
772 "name",
"gnc-id-account-tree", NULL);
775 view->show_account_color =
gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_COLOR);
782 virtual_root_path = gtk_tree_path_new_first ();
783 f_model = gtk_tree_model_filter_new (model, virtual_root_path);
786 g_object_unref(G_OBJECT(model));
787 if (virtual_root_path)
788 gtk_tree_path_free(virtual_root_path);
791 s_model = gtk_tree_model_sort_new_with_model(f_model);
792 g_object_unref(G_OBJECT(f_model));
793 gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
794 g_object_unref(G_OBJECT(s_model));
797 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
804 GNC_ICON_ACCOUNT,
"Expenses:Entertainment",
805 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
806 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
810 GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
811 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
816 GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
817 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
822 GNC_TREE_MODEL_ACCOUNT_COL_CODE,
823 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
827 "Sample account description.",
828 GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
829 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
833 GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
834 GNC_TREE_VIEW_COLUMN_COLOR_NONE,
835 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
839 SAMPLE_ACCOUNT_VALUE,
840 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
841 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
842 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
843 sort_by_present_value);
844 view->present_report_column
846 SAMPLE_ACCOUNT_VALUE,
847 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
848 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
849 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
850 sort_by_present_value);
853 SAMPLE_ACCOUNT_VALUE,
854 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
855 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
856 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
857 sort_by_balance_value);
858 view->balance_report_column
860 SAMPLE_ACCOUNT_VALUE,
861 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
862 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
863 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
864 sort_by_balance_value);
867 SAMPLE_ACCOUNT_VALUE,
868 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD,
869 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
870 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
871 sort_by_balance_period_value);
874 SAMPLE_ACCOUNT_VALUE,
875 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
876 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
877 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
878 sort_by_cleared_value);
879 view->cleared_report_column
881 SAMPLE_ACCOUNT_VALUE,
882 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
883 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
884 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
885 sort_by_cleared_value);
888 SAMPLE_ACCOUNT_VALUE,
889 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
890 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
891 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
892 sort_by_reconciled_value);
893 view->reconciled_report_column
895 SAMPLE_ACCOUNT_VALUE,
896 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
897 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
898 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
899 sort_by_reconciled_value);
903 GNC_TREE_MODEL_ACCOUNT_COL_EARLIEST_DATE,
904 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
905 sort_by_earliest_date);
908 "Last Reconcile Date",
909 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
910 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
911 sort_by_last_reconcile_date);
914 SAMPLE_ACCOUNT_VALUE,
915 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
916 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
917 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
918 sort_by_future_min_value);
919 view->future_min_report_column
921 SAMPLE_ACCOUNT_VALUE,
922 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
923 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
924 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
925 sort_by_future_min_value);
928 SAMPLE_ACCOUNT_VALUE,
929 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
930 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
931 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
932 sort_by_total_value);
933 view->total_report_column
935 SAMPLE_ACCOUNT_VALUE,
936 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
937 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
938 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
939 sort_by_total_value);
942 SAMPLE_ACCOUNT_VALUE,
943 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
944 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
945 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
946 sort_by_total_period_value);
952 GNC_TREE_VIEW_COLUMN_DATA_NONE,
953 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
957 g_object_set_data_full(G_OBJECT(acc_color_column), REAL_TITLE,
958 g_strdup(_(
"Account Color")), g_free);
961 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_color_column), _(
"Account Color"));
963 acc_balance_limit_column
965 C_(
"Column header for 'Balance Limit'",
"L"),
966 "account-balance-limit",
968 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT,
969 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
973 g_object_set_data_full(G_OBJECT(acc_balance_limit_column), REAL_TITLE,
974 g_strdup(_(
"Balance Limit")), g_free);
977 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (acc_balance_limit_column), _(
"Balance Limit"));
981 "Sample account notes.",
982 GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
983 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
989 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
990 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
994 gtk_tree_view_column_set_cell_data_func(tax_info_column,
1001 C_(
"Column header for 'Hidden'",
"H"),
1003 GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
1004 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1006 gnc_tree_view_account_hidden_toggled);
1009 C_(
"Column header for 'Placeholder'",
"P"),
1011 GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
1012 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1013 sort_by_placeholder,
1014 gnc_tree_view_account_placeholder_toggled);
1017 C_(
"Column header for 'Opening Balance'",
"O"),
1019 GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE,
1020 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
1021 sort_by_opening_balance,
1025 col_list = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
1026 for (node = col_list; node; node = node->next)
1029 gtk_tree_view_column_set_cell_data_func(node->data,
1031 acc_color_data_func,
1032 GTK_TREE_VIEW(view),
1035 g_list_free (col_list);
1038 gtva_update_column_names(view);
1042 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
1043 gnc_tree_view_account_filter_helper,
1048 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
1049 GNC_TREE_MODEL_ACCOUNT_COL_NAME,
1050 GTK_SORT_ASCENDING);
1053 gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(view), gnc_tree_view_search_compare, NULL, NULL);
1055 g_signal_connect (G_OBJECT(view),
"query-tooltip",
1056 G_CALLBACK(gnc_tree_view_tooltip_cb), NULL);
1058 gtk_widget_show(GTK_WIDGET(view));
1060 return GTK_TREE_VIEW(view);
1074 root = gnc_book_get_root_account (gnc_get_current_book ());
1082 #define debug_path(fn, path) { \ 1083 gchar *path_string = gtk_tree_path_to_string(path); \ 1084 fn("tree path %s", path_string); \ 1085 g_free(path_string); \ 1088 static GtkTreePath *
1089 gnc_tree_view_account_get_path_from_account (GncTreeViewAccount *view,
1092 GtkTreeModel *model, *f_model, *s_model;
1093 GtkTreePath *path, *f_path, *s_path;
1097 if (account == NULL)
1099 LEAVE(
"no account");
1104 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1105 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1106 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1115 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), path);
1116 gtk_tree_path_free(path);
1119 LEAVE(
"no filter path");
1124 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path);
1125 gtk_tree_path_free(f_path);
1126 debug_path(
LEAVE, s_path);
1131 gnc_tree_view_account_get_iter_from_account (GncTreeViewAccount *view,
1133 GtkTreeIter *s_iter)
1135 GtkTreeModel *model, *f_model, *s_model;
1136 GtkTreeIter iter, f_iter;
1138 g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view), FALSE);
1139 g_return_val_if_fail(account != NULL, FALSE);
1140 g_return_val_if_fail(s_iter != NULL, FALSE);
1145 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1146 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1147 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1149 GNC_TREE_MODEL_ACCOUNT(model), account, &iter))
1151 LEAVE(
"model_get_iter_from_account failed");
1156 gtk_tree_model_filter_convert_child_iter_to_iter (
1157 GTK_TREE_MODEL_FILTER(f_model), &f_iter, &iter);
1158 gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT(s_model),
1168 GtkTreeModel *s_model;
1174 if (account == NULL)
1176 LEAVE(
"no account");
1180 if (!gnc_tree_view_account_get_iter_from_account (view, account, &s_iter))
1182 LEAVE(
"view_get_iter_from_account failed");
1187 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1188 num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
1189 LEAVE(
"%d children", num_children);
1190 return num_children;
1196 GtkTreeModel *model, *f_model, *s_model;
1198 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
1199 f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(s_model));
1200 model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(f_model));
1215 AccountViewInfo *avi)
1217 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1218 g_return_if_fail(avi != NULL);
1229 AccountViewInfo *avi)
1232 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1233 g_return_if_fail(avi != NULL);
1238 view, gnc_tree_view_account_filter_by_view_info,
1245 gnc_tree_view_account_filter_helper (GtkTreeModel *model,
1250 GncTreeViewAccount *view = data;
1252 g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), FALSE);
1253 g_return_val_if_fail (iter != NULL, FALSE);
1256 GNC_TREE_MODEL_ACCOUNT(model), iter);
1258 if (view->filter_fn)
1259 return view->filter_fn(account, view->filter_data);
1274 GSourceFunc destroy)
1276 ENTER(
"view %p, filter func %p, data %p, destroy %p",
1277 view, func, data, destroy);
1279 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1281 if (view->filter_destroy)
1283 view->filter_destroy(view->filter_data);
1285 view->filter_destroy = destroy;
1286 view->filter_data = data;
1287 view->filter_fn = func;
1299 GtkTreeModel *f_model, *s_model;
1301 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1303 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1304 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1305 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
1309 gnc_tree_view_account_filter_by_view_info(
Account* acct, gpointer data)
1312 AccountViewInfo* avi = (AccountViewInfo*)data;
1314 g_return_val_if_fail(GNC_IS_ACCOUNT(acct), FALSE);
1317 if (!avi->include_type[acct_type])
return FALSE;
1332 GtkTreePath *s_path)
1334 GtkTreeModel *model, *f_model, *s_model;
1335 GtkTreePath *path, *f_path;
1339 ENTER(
"view %p", view);
1340 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1341 g_return_val_if_fail (s_path != NULL, NULL);
1343 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1344 f_path = gtk_tree_model_sort_convert_path_to_child_path (
1345 GTK_TREE_MODEL_SORT (s_model), s_path);
1348 LEAVE(
"no filter path");
1352 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1353 path = gtk_tree_model_filter_convert_path_to_child_path (
1354 GTK_TREE_MODEL_FILTER (f_model), f_path);
1355 gtk_tree_path_free(f_path);
1362 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1363 if (!gtk_tree_model_get_iter (model, &iter, path))
1369 account = iter.user_data;
1370 gtk_tree_path_free(path);
1378 GtkTreeIter *s_iter)
1380 GtkTreeModel *model, *f_model;
1381 GtkTreeIter iter, f_iter;
1384 g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
1385 g_return_val_if_fail (s_iter != NULL, NULL);
1387 ENTER(
"model %p, iter %p", s_model, s_iter);
1389 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
1392 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1393 gtk_tree_model_filter_convert_iter_to_child_iter (
1394 GTK_TREE_MODEL_FILTER(f_model), &iter, &f_iter);
1395 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1397 GNC_TREE_MODEL_ACCOUNT(model), &iter);
1410 GtkTreeSelection *selection;
1411 GtkTreeModel *f_model, *s_model;
1412 GtkTreeIter iter, f_iter, s_iter;
1414 GtkSelectionMode mode;
1416 ENTER(
"view %p", view);
1417 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1419 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1420 mode = gtk_tree_selection_get_mode(selection);
1421 if ((mode != GTK_SELECTION_SINGLE) && (mode != GTK_SELECTION_BROWSE))
1425 if (!gtk_tree_selection_get_selected (selection, &s_model, &s_iter))
1427 LEAVE(
"no account, get_selected failed");
1431 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1434 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1435 gtk_tree_model_filter_convert_iter_to_child_iter (
1436 GTK_TREE_MODEL_FILTER (f_model), &iter, &f_iter);
1438 account = iter.user_data;
1451 GtkTreeModel *model, *f_model, *s_model;
1452 GtkTreePath *path, *f_path, *s_path, *parent_path;
1453 GtkTreeSelection *selection;
1455 ENTER(
"view %p, account %p (%s)", view,
1457 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1460 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1461 gtk_tree_selection_unselect_all (selection);
1463 if (account == NULL)
1466 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1467 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1468 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1471 GNC_TREE_MODEL_ACCOUNT(model), account);
1477 debug_path(
DEBUG, path);
1479 f_path = gtk_tree_model_filter_convert_child_path_to_path (
1480 GTK_TREE_MODEL_FILTER (f_model), path);
1481 gtk_tree_path_free(path);
1484 LEAVE(
"no filter path");
1487 debug_path(
DEBUG, f_path);
1489 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1491 gtk_tree_path_free(f_path);
1494 LEAVE(
"no sort path");
1499 parent_path = gtk_tree_path_copy (s_path);
1500 if (gtk_tree_path_up (parent_path))
1505 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1507 gtk_tree_path_free(parent_path);
1509 gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), s_path, 0, FALSE);
1513 while (gtk_events_pending ())
1514 gtk_main_iteration ();
1515 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1516 debug_path(
LEAVE, s_path);
1517 gtk_tree_path_free(s_path);
1524 GncTreeViewAccount* view;
1533 get_selected_accounts_helper (GtkTreeModel *s_model,
1534 GtkTreePath *s_path,
1535 GtkTreeIter *s_iter,
1539 GtkTreeModel *f_model;
1540 GtkTreeIter iter, f_iter;
1543 gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
1546 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1547 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
1549 account = iter.user_data;
1552 if (gtvsi->view->filter_fn == NULL || gtvsi->view->filter_fn(account, gtvsi->view->filter_data))
1554 gtvsi->return_list = g_list_prepend (gtvsi->return_list, account);
1568 GtkTreeSelection *selection;
1571 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1573 info.return_list = NULL;
1575 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
1576 gtk_tree_selection_selected_foreach(selection, get_selected_accounts_helper, &info);
1577 info.return_list = g_list_reverse (info.return_list);
1578 return info.return_list;
1587 GList *account_list,
1590 GtkTreeModel *model, *f_model, *s_model;
1591 GtkTreePath *path, *f_path, *s_path, *parent_path;
1592 GtkTreeSelection *selection;
1596 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1598 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1599 f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
1600 model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
1603 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1604 gtk_tree_selection_unselect_all (selection);
1605 gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
1608 for (element = account_list; element; )
1610 account = element->data;
1611 element = g_list_next(element);
1613 if (account == NULL)
1632 f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
1634 gtk_tree_path_free(path);
1638 s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
1640 gtk_tree_path_free(f_path);
1645 parent_path = gtk_tree_path_copy (s_path);
1646 if (gtk_tree_path_up (parent_path))
1651 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
1653 gtk_tree_path_free(parent_path);
1655 gtk_tree_selection_select_path (selection, s_path);
1656 if (show_last && (element == NULL))
1657 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
1658 gtk_tree_path_free(s_path);
1669 GtkTreeModel *s_model;
1670 GtkTreeSelection *selection;
1671 GtkTreePath *sp_account, *sp_start, *sp_end;
1672 GtkTreeIter si_account, si_start, si_end;
1673 gboolean have_start, have_end = FALSE;
1678 g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view));
1680 if (account == NULL)
1682 LEAVE(
"no account");
1686 if (!gnc_tree_view_account_get_iter_from_account (view, account, &si_account))
1688 LEAVE(
"view_get_iter_from_account failed");
1693 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
1694 num_children = gtk_tree_model_iter_n_children(s_model, &si_account);
1695 if (num_children == 0)
1697 LEAVE(
"no children");
1702 sp_account = gtk_tree_model_get_path (s_model, &si_account);
1703 gtk_tree_view_expand_row (GTK_TREE_VIEW(view), sp_account, TRUE);
1706 have_start = gtk_tree_model_iter_nth_child(s_model, &si_start, &si_account, 0);
1707 si_end = si_account;
1708 while (num_children)
1710 GtkTreeIter tmp_iter = si_end;
1711 have_end = gtk_tree_model_iter_nth_child(s_model, &si_end, &tmp_iter,
1714 num_children = gtk_tree_model_iter_n_children(s_model, &si_end);
1719 if (have_start && have_end)
1721 sp_start = gtk_tree_model_get_path (s_model, &si_start);
1722 sp_end = gtk_tree_model_get_path (s_model, &si_end);
1725 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1726 gtk_tree_selection_select_range (selection, sp_start, sp_end);
1729 gtk_tree_path_free(sp_start);
1730 gtk_tree_path_free(sp_end);
1732 gtk_tree_path_free(sp_account);
1743 g_return_if_fail(view != NULL);
1744 g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view));
1745 ENTER(
"view %p, account %p", view, account);
1747 path = gnc_tree_view_account_get_path_from_account(view, account);
1750 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path);
1751 gtk_tree_path_free(path);
1763 GtkTreePath *s_path;
1766 ENTER(
"view %p", view);
1767 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1769 gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
1772 LEAVE(
"no account");
1777 gtk_tree_path_free(s_path);
1788 gtva_update_column_name (GtkTreeViewColumn *column,
1790 const gchar *mnemonic)
1794 g_return_if_fail(column);
1796 name = g_strdup_printf(fmt, mnemonic);
1797 gtk_tree_view_column_set_title(column, name);
1803 gtva_update_column_names (GncTreeViewAccount *view)
1807 gtva_update_column_name(view->present_report_column,
1809 _(
"Present (%s)"), mnemonic);
1810 gtva_update_column_name(view->balance_report_column,
1812 _(
"Balance (%s)"), mnemonic);
1813 gtva_update_column_name(view->cleared_report_column,
1815 _(
"Cleared (%s)"), mnemonic);
1816 gtva_update_column_name(view->reconciled_report_column,
1818 _(
"Reconciled (%s)"), mnemonic);
1819 gtva_update_column_name(view->future_min_report_column,
1821 _(
"Future Minimum (%s)"), mnemonic);
1822 gtva_update_column_name(view->total_report_column,
1824 _(
"Total (%s)"), mnemonic);
1831 gtva_currency_changed_cb (
void)
1833 const GList *views, *ptr;
1836 for (ptr = views; ptr; ptr = g_list_next(ptr))
1838 gtva_update_column_names (ptr->data);
1845 account_cell_property_data_func (GtkTreeViewColumn *tree_column,
1846 GtkCellRenderer *cell,
1847 GtkTreeModel *s_model,
1848 GtkTreeIter *s_iter,
1851 GncTreeViewAccount *view;
1853 gchar *
string = NULL;
1855 g_return_if_fail (GTK_IS_TREE_MODEL_SORT (s_model));
1859 string = g_strdup (
"");
1861 g_object_set (G_OBJECT (cell),
"text",
string,
"xalign", 0.0, NULL);
1864 view = g_object_get_data(G_OBJECT(tree_column),
"tree-view");
1866 if (GNC_IS_TREE_VIEW_ACCOUNT (view))
1867 acc_color_data_func (tree_column, cell, s_model, s_iter, view);
1873 const gchar *column_title,
1874 const gchar *propname)
1876 GtkCellRenderer *renderer;
1877 GtkTreeViewColumn *column;
1879 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), NULL);
1880 g_return_val_if_fail (propname != NULL, NULL);
1883 propname, NULL,
"Sample text",
1889 g_object_set (G_OBJECT (renderer),
"xalign", 1.0, NULL);
1892 g_object_set_data(G_OBJECT(column),
"tree-view", (gpointer)view);
1894 gtk_tree_view_column_set_cell_data_func (column, renderer,
1895 account_cell_property_data_func,
1896 g_strdup(propname), g_free);
1900 static void col_edited_helper(GtkCellRendererText *cell, gchar *path_string,
1901 gchar *new_text, gpointer _s_model)
1904 GtkTreeModel *s_model;
1906 GncTreeViewAccountColumnTextEdited col_edited_cb;
1907 GtkTreeViewColumn *col;
1909 col_edited_cb = g_object_get_data(G_OBJECT(cell),
1910 "column_edited_callback");
1911 col = GTK_TREE_VIEW_COLUMN(g_object_get_data(G_OBJECT(cell),
1913 s_model = GTK_TREE_MODEL(_s_model);
1915 if (!gtk_tree_model_get_iter_from_string(s_model, &s_iter, path_string))
1919 col_edited_cb(account, col, new_text);
1922 static void col_source_helper(GtkTreeViewColumn *col, GtkCellRenderer *cell,
1923 GtkTreeModel *s_model, GtkTreeIter *s_iter,
1924 gpointer _col_source_cb)
1928 GncTreeViewAccountColumnSource col_source_cb;
1930 g_return_if_fail (GTK_IS_TREE_MODEL_SORT (s_model));
1931 col_source_cb = (GncTreeViewAccountColumnSource) _col_source_cb;
1933 text = col_source_cb(account, col, cell);
1934 g_object_set (G_OBJECT (cell),
"text", text,
"xalign", 1.0, NULL);
1943 gtva_setup_column_renderer_edited_cb(GncTreeViewAccount *account_view,
1944 GtkTreeViewColumn *column,
1945 GtkCellRenderer *renderer,
1946 GncTreeViewAccountColumnTextEdited col_edited_cb)
1948 GtkTreeModel *s_model;
1950 if (col_edited_cb == NULL)
1952 g_object_set(G_OBJECT(renderer),
"editable", FALSE, NULL);
1953 g_object_set_data(G_OBJECT(renderer),
"column_edited_callback", col_edited_cb);
1954 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(account_view));
1955 g_signal_handlers_disconnect_by_func(G_OBJECT(renderer), col_edited_cb, s_model);
1956 g_object_set_data(G_OBJECT(renderer),
"column_view", column);
1960 g_object_set(G_OBJECT(renderer),
"editable", TRUE, NULL);
1961 g_object_set_data(G_OBJECT(renderer),
"column_edited_callback",
1963 s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(account_view));
1964 g_signal_connect(G_OBJECT(renderer),
"edited",
1965 (GCallback) col_edited_helper, s_model);
1966 g_object_set_data(G_OBJECT(renderer),
"column_view", column);
1972 const gchar *column_title,
1973 GncTreeViewAccountColumnSource
1975 GncTreeViewAccountColumnTextEdited
1978 GtkCellRenderer *renderer;
1980 g_return_val_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view), NULL);
1982 renderer = gtk_cell_renderer_text_new();
1984 return gnc_tree_view_account_add_custom_column_renderer(
1985 account_view, column_title, col_source_cb, col_edited_cb, renderer);
1989 gnc_tree_view_account_add_custom_column_renderer(GncTreeViewAccount *account_view,
1990 const gchar *column_title,
1991 GncTreeViewAccountColumnSource
1993 GncTreeViewAccountColumnTextEdited
1995 GtkCellRenderer *renderer)
1997 GtkTreeViewColumn *column;
1999 g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (account_view), NULL);
2001 g_object_set (G_OBJECT (renderer),
"xalign", 1.0, NULL);
2003 column = gtk_tree_view_column_new_with_attributes (column_title,
2007 gtva_setup_column_renderer_edited_cb(account_view, column,
2008 renderer, col_edited_cb);
2010 gtk_tree_view_column_set_cell_data_func (column, renderer,
2012 col_source_cb, NULL);
2019 #define FILTER_TREE_VIEW "types_tree_view" 2043 if (g_hash_table_size (fd->filter_override) > 0)
2046 test_acc = g_hash_table_lookup (fd->filter_override, account);
2047 if (test_acc != NULL)
2049 LEAVE(
" filter: override");
2056 LEAVE(
" hide: hidden");
2060 if (!fd->show_zero_total)
2062 total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
2065 LEAVE(
" hide: zero balance");
2070 if (!fd->show_unused)
2072 if (gnc_account_and_descendants_empty(account))
2074 LEAVE(
" hide: unused");
2080 result = (fd->visible_types & (1 << acct_type)) ? TRUE : FALSE;
2081 LEAVE(
" %s", result ?
"show" :
"hide");
2096 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2098 ENTER(
"button %p", button);
2099 fd->show_hidden = gtk_toggle_button_get_active(button);
2101 LEAVE(
"show_hidden %d", fd->show_hidden);
2115 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2117 ENTER(
"button %p", button);
2118 fd->show_zero_total = gtk_toggle_button_get_active(button);
2120 LEAVE(
"show_zero %d", fd->show_zero_total);
2134 g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
2136 ENTER(
"button %p", button);
2137 fd->show_unused = gtk_toggle_button_get_active(button);
2139 LEAVE(
"show_unused %d", fd->show_unused);
2154 g_return_if_fail(GTK_IS_BUTTON(button));
2156 ENTER(
"button %p", button);
2157 fd->visible_types = 0;
2158 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2160 LEAVE(
"types 0x%x", fd->visible_types);
2173 g_return_if_fail(GTK_IS_BUTTON(button));
2175 ENTER(
"button %p", button);
2176 fd->visible_types = -1;
2177 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(fd->model));
2179 LEAVE(
"types 0x%x", fd->visible_types);
2193 ENTER(
"button %p", button);
2210 gppat_filter_visible_set_func (GtkTreeViewColumn *column,
2211 GtkCellRenderer *renderer,
2212 GtkTreeModel *model,
2220 gtk_tree_model_get(model, iter, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
2222 active = (fd->visible_types & (1 << type)) ? TRUE : FALSE;
2223 g_object_set (G_OBJECT (renderer),
"active", active, NULL);
2232 gppat_filter_visible_toggled_cb (GtkCellRendererToggle *renderer,
2236 GtkTreeModel *model = fd->model;
2241 ENTER(
"toggled %p", path_str);
2242 path = gtk_tree_path_new_from_string(path_str);
2244 if (gtk_tree_model_get_iter(model, &iter, path))
2246 gtk_tree_model_get(model, &iter, GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
2247 fd->visible_types ^= (1 << type);
2250 gtk_tree_path_free(path);
2251 LEAVE(
"types 0x%x", fd->visible_types);
2271 g_return_if_fail(GTK_IS_DIALOG(dialog));
2273 ENTER(
"dialog %p, response %d", dialog, response);
2275 if (response != GTK_RESPONSE_OK)
2277 fd->visible_types = fd->original_visible_types;
2278 fd->show_hidden = fd->original_show_hidden;
2279 fd->show_zero_total = fd->original_show_zero_total;
2280 fd->show_unused = fd->original_show_unused;
2285 gptemp = (gpointer)fd->dialog;
2286 g_atomic_pointer_compare_and_exchange(&gptemp,
2287 (gpointer)dialog, NULL);
2288 fd->dialog = gptemp;
2289 gtk_widget_destroy(dialog);
2290 LEAVE(
"types 0x%x", fd->visible_types);
2296 GtkWidget *dialog, *button;
2298 GtkCellRenderer *renderer;
2299 GtkBuilder *builder;
2302 ENTER(
"(fd %p, page %p)", fd, page);
2306 gtk_window_present(GTK_WINDOW(fd->dialog));
2307 LEAVE(
"existing dialog");
2312 builder = gtk_builder_new();
2313 gnc_builder_add_from_file (builder,
"dialog-account.glade",
"account_filter_by_dialog");
2314 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"account_filter_by_dialog"));
2315 fd->dialog = dialog;
2316 gtk_window_set_transient_for(GTK_WINDOW(dialog),
2317 GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
2319 title = g_strdup_printf(_(
"Filter %s by..."),
2321 gtk_window_set_title(GTK_WINDOW(dialog), title);
2325 fd->original_visible_types = fd->visible_types;
2326 fd->original_show_hidden = fd->show_hidden;
2327 fd->original_show_zero_total = fd->show_zero_total;
2328 fd->original_show_unused = fd->show_unused;
2331 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_hidden"));
2332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2334 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_zero"));
2335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2336 fd->show_zero_total);
2337 button = GTK_WIDGET(gtk_builder_get_object (builder,
"show_unused"));
2338 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2342 view = GTK_TREE_VIEW(gtk_builder_get_object (builder, FILTER_TREE_VIEW));
2344 fd->model = gnc_tree_model_account_types_filter_using_mask
2346 gtk_tree_view_set_model(view, fd->model);
2347 g_object_unref (fd->model);
2349 renderer = gtk_cell_renderer_toggle_new();
2351 g_signal_connect(renderer,
"toggled",
2352 G_CALLBACK(gppat_filter_visible_toggled_cb), fd);
2354 gtk_tree_view_insert_column_with_data_func (view, -1, NULL, renderer,
2355 gppat_filter_visible_set_func, fd, NULL);
2357 gtk_tree_view_insert_column_with_attributes (view,
2358 -1, _(
"Account Types"), gtk_cell_renderer_text_new(),
2359 "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL);
2362 gtk_builder_connect_signals(builder, fd);
2363 g_object_unref(G_OBJECT(builder));
2366 gtk_widget_show_all(dialog);
2371 #define ACCT_COUNT "NumberOfOpenAccounts" 2372 #define ACCT_OPEN "OpenAccount%d" 2373 #define ACCT_SELECTED "SelectedAccount" 2374 #define SHOW_HIDDEN "ShowHidden" 2375 #define SHOW_ZERO "ShowZeroTotal" 2376 #define SHOW_UNUSED "ShowUnused" 2377 #define ACCT_TYPES "AccountTypes" 2381 #define SHOW_HIDDEN_ACCOUNTS "Show_Hidden" 2382 #define SHOW_ZERO_TOTALS "Show_ZeroTotal" 2383 #define SHOW_UNUSED_ACCOUNTS "Show_Unused" 2384 #define ACCOUNT_TYPES "Account_Types" 2390 const gchar *group_name;
2406 tree_save_expanded_row (GncTreeViewAccount *view,
2411 bar_t *bar = user_data;
2413 gchar *account_name;
2416 if (account == NULL)
2420 if (account_name == NULL)
2423 key = g_strdup_printf(ACCT_OPEN, ++bar->count);
2424 g_key_file_set_string(bar->key_file, bar->group_name, key, account_name);
2426 g_free(account_name);
2441 tree_save_selected_row (GncTreeViewAccount *view,
2445 bar_t *bar = user_data;
2446 gchar *account_name;
2449 if (account == NULL)
2453 if (account_name == NULL)
2456 g_key_file_set_string(bar->key_file, bar->group_name, ACCT_SELECTED,
2458 g_free(account_name);
2462 gnc_tree_view_account_save(GncTreeViewAccount *view,
2464 GKeyFile *key_file,
const gchar *group_name)
2468 g_return_if_fail (key_file != NULL);
2469 g_return_if_fail (group_name != NULL);
2471 ENTER(
"view %p, key_file %p, group_name %s", view, key_file,
2474 g_key_file_set_integer(key_file, group_name, ACCT_TYPES,
2476 g_key_file_set_boolean(key_file, group_name, SHOW_HIDDEN,
2478 g_key_file_set_boolean(key_file, group_name, SHOW_ZERO,
2479 fd->show_zero_total);
2480 g_key_file_set_boolean(key_file, group_name, SHOW_UNUSED,
2483 bar.key_file = key_file;
2484 bar.group_name = group_name;
2486 tree_save_selected_row(view, &bar);
2487 gtk_tree_view_map_expanded_rows(
2488 GTK_TREE_VIEW(view), (GtkTreeViewMappingFunc) tree_save_expanded_row,
2490 g_key_file_set_integer(key_file, group_name, ACCT_COUNT, bar.count);
2496 gnc_tree_view_account_save_filter (GncTreeViewAccount *view,
2499 const gchar *group_name)
2501 g_return_if_fail (key_file != NULL);
2502 g_return_if_fail (group_name != NULL);
2504 ENTER(
"view %p, key_file %p, group_name %s", view, key_file,
2507 g_key_file_set_integer (key_file, group_name, ACCOUNT_TYPES,
2509 g_key_file_set_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS,
2511 g_key_file_set_boolean (key_file, group_name, SHOW_ZERO_TOTALS,
2512 fd->show_zero_total);
2513 g_key_file_set_boolean (key_file, group_name, SHOW_UNUSED_ACCOUNTS,
2526 tree_restore_expanded_row (GncTreeViewAccount *view,
2527 const gchar *account_name)
2533 g_return_if_fail(book);
2549 tree_restore_selected_row (GncTreeViewAccount *view,
2550 const gchar *account_name)
2556 g_return_if_fail(book);
2564 gnc_tree_view_account_restore(GncTreeViewAccount *view,
2566 GKeyFile *key_file,
const gchar *group_name)
2568 GError *error = NULL;
2574 show = g_key_file_get_boolean(key_file, group_name, SHOW_HIDDEN, &error);
2577 g_warning(
"error reading group %s key %s: %s",
2578 group_name, SHOW_HIDDEN, error->message);
2579 g_error_free(error);
2583 fd->show_hidden = show;
2585 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO, &error);
2588 g_warning(
"error reading group %s key %s: %s",
2589 group_name, SHOW_ZERO, error->message);
2590 g_error_free(error);
2594 fd->show_zero_total = show;
2596 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED, &error);
2599 g_warning(
"error reading group %s key %s: %s",
2600 group_name, SHOW_UNUSED, error->message);
2601 g_error_free(error);
2605 fd->show_unused = show;
2607 i = g_key_file_get_integer(key_file, group_name, ACCT_TYPES, &error);
2610 g_warning(
"error reading group %s key %s: %s",
2611 group_name, ACCT_TYPES, error->message);
2612 g_error_free(error);
2616 fd->visible_types = i;
2619 count = g_key_file_get_integer(key_file, group_name, ACCT_COUNT, &error);
2622 for (i = 1; i <= count; i++)
2624 key = g_strdup_printf(ACCT_OPEN, i);
2625 value = g_key_file_get_string(key_file, group_name, key, &error);
2628 g_warning(
"error reading group %s key %s: %s",
2629 group_name, key, error->message);
2630 g_error_free(error);
2635 tree_restore_expanded_row(view, value);
2643 g_warning(
"error reading group %s key %s: %s",
2644 group_name, ACCT_COUNT, error->message);
2645 g_error_free(error);
2649 value = g_key_file_get_string(key_file, group_name, ACCT_SELECTED, NULL);
2652 tree_restore_selected_row(view, value);
2661 gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
2664 const gchar *group_name)
2666 GError *error = NULL;
2670 g_return_if_fail (key_file != NULL);
2671 g_return_if_fail (group_name != NULL);
2676 show = g_key_file_get_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS, &error);
2679 g_error_free (error);
2683 fd->show_hidden = show;
2685 show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO_TOTALS, &error);
2688 g_error_free (error);
2692 fd->show_zero_total = show;
2694 show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED_ACCOUNTS, &error);
2697 g_error_free (error);
2701 fd->show_unused = show;
2703 i = g_key_file_get_integer(key_file, group_name, ACCOUNT_TYPES, &error);
2706 g_error_free (error);
2710 fd->visible_types = i;
2715 gnc_tree_view_account_name_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_name)
2723 if (existing != NULL && existing != account)
2725 PERR(
"account with the same name [%s] already exists.", new_name);
2733 gnc_tree_view_account_code_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_code)
2741 gnc_tree_view_account_description_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_desc)
2749 gnc_tree_view_account_notes_edited_cb(
Account *account, GtkTreeViewColumn *col,
const gchar *new_notes)
2757 gtva_set_column_editor(GncTreeViewAccount *view,
2758 GtkTreeViewColumn *column,
2759 GncTreeViewAccountColumnTextEdited edited_cb)
2761 GList *renderers_orig, *renderers;
2762 GtkCellRenderer *renderer = NULL;
2766 for (renderers_orig = renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
2767 renderers && !GTK_IS_CELL_RENDERER_TEXT(renderers->data);
2768 renderers = renderers->next);
2770 renderer = GTK_CELL_RENDERER(renderers->data);
2771 g_list_free(renderers_orig);
2772 g_return_if_fail(renderer != NULL);
2773 gtva_setup_column_renderer_edited_cb(GNC_TREE_VIEW_ACCOUNT(view), column, renderer, edited_cb);
2777 gnc_tree_view_account_set_name_edited(GncTreeViewAccount *view,
2778 GncTreeViewAccountColumnTextEdited edited_cb)
2780 gtva_set_column_editor(view, view->name_column, edited_cb);
2784 gnc_tree_view_account_set_code_edited(GncTreeViewAccount *view,
2785 GncTreeViewAccountColumnTextEdited edited_cb)
2787 gtva_set_column_editor(view, view->code_column, edited_cb);
2791 gnc_tree_view_account_set_description_edited(GncTreeViewAccount *view,
2792 GncTreeViewAccountColumnTextEdited edited_cb)
2794 gtva_set_column_editor(view, view->desc_column, edited_cb);
2798 gnc_tree_view_account_set_notes_edited(GncTreeViewAccount *view,
2799 GncTreeViewAccountColumnTextEdited edited_cb)
2801 gtva_set_column_editor(view, view->notes_column, edited_cb);
2805 gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
2806 const gchar *key, GtkTreeIter *iter, gpointer search_data)
2808 gchar *normalized_key;
2809 gchar *case_normalized_key = NULL;
2810 gboolean match = FALSE;
2812 normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_NFC);
2814 case_normalized_key = g_utf8_casefold (normalized_key, -1);
2815 if (case_normalized_key)
2821 gchar *normalized_string;
2822 gchar *case_normalized_string = NULL;
2828 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_NAME,&str,-1);
2831 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_CODE,&str,-1);
2834 gtk_tree_model_get(model,iter,GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,&str,-1);
2841 normalized_string = g_utf8_normalize (str, -1, G_NORMALIZE_NFC);
2842 if (normalized_string)
2843 case_normalized_string = g_utf8_casefold (normalized_string, -1);
2844 if (case_normalized_string&&NULL!=strstr(case_normalized_string,case_normalized_key))
2848 g_free (normalized_string);
2849 g_free (case_normalized_string);
2856 g_free (normalized_key);
2857 g_free (case_normalized_key);
2864 GFunc editing_started_cb, gpointer editing_cb_data)
2867 editing_started_cb, editing_cb_data);
2871 GFunc editing_finished_cb, gpointer editing_cb_data)
2874 editing_finished_cb, editing_cb_data);
2879 gnc_tree_view_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_tip,
2880 GtkTooltip *tooltip, gpointer user_data)
2882 GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
2883 GtkTreePath *path = NULL;
2884 GtkTreeViewColumn *column = NULL;
2885 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &x, &y);
2886 if (keyboard_tip || !gtk_tree_view_get_path_at_pos (tree_view, x, y, &path,
2887 &column, NULL, NULL))
2889 gtk_tree_path_free (path);
2894 gboolean show_tooltip =
false;
2895 GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
2897 if (gtk_tree_model_get_iter (model, &iter, path) && column)
2902 switch (gtk_tree_view_column_get_sort_column_id (column))
2904 case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT:
2905 gtk_tree_model_get (model, &iter,
2906 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT_EXPLANATION, &ttip,
2916 show_tooltip =
true;
2917 gtk_tooltip_set_text (tooltip, ttip);
2918 gtk_tree_view_set_tooltip_cell (tree_view, tooltip, path, column, NULL);
2924 gtk_tree_path_free (path);
2925 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.
gint 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.
time64 gnc_account_get_earliest_date(const Account *account)
Returns the date of the earliest split in the account, or INT64_MAX.
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.