38 #include <glib/gi18n.h>
42 #include "dialog-utils.h"
50 #include "app-utils/gnc-component-manager.h"
52 #define GNC_PREFS_GROUP "dialogs.import.generic.transaction-list"
60 GdkColor color_back_red;
61 GdkColor color_back_green;
62 GdkColor color_back_yellow;
64 GNCTransactionProcessedCB transaction_processed_cb;
70 DOWNLOADED_COL_DATE = 0,
71 DOWNLOADED_COL_ACCOUNT,
72 DOWNLOADED_COL_AMOUNT,
73 DOWNLOADED_COL_DESCRIPTION,
75 DOWNLOADED_COL_ACTION_ADD,
76 DOWNLOADED_COL_ACTION_CLEAR,
77 DOWNLOADED_COL_ACTION_UPDATE,
78 DOWNLOADED_COL_ACTION_INFO,
79 DOWNLOADED_COL_ACTION_PIXBUF,
85 #define COLOR_RED "brown1"
86 #define COLOR_YELLOW "gold"
87 #define COLOR_GREEN "DarkSeaGreen1"
92 void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data);
94 void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data);
115 model = gtk_tree_view_get_model(info->view);
116 if (gtk_tree_model_get_iter_first(model, &iter))
120 gtk_tree_model_get(model, &iter,
121 DOWNLOADED_COL_DATA, &trans_info,
124 if (info->transaction_processed_cb)
126 info->transaction_processed_cb(trans_info,
133 while (gtk_tree_model_iter_next (model, &iter));
137 if (!(info->dialog == NULL))
139 gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->dialog));
141 gtk_widget_destroy (GTK_WIDGET (info->dialog));
149 on_matcher_ok_clicked (GtkButton *button,
154 GtkTreeRowReference *ref;
157 GSList *refs_list = NULL;
163 model = gtk_tree_view_get_model(info->view);
164 if (!gtk_tree_model_get_iter_first(model, &iter))
169 gnc_suspend_gui_refresh();
173 gtk_tree_model_get(model, &iter,
174 DOWNLOADED_COL_DATA, &trans_info,
179 path = gtk_tree_model_get_path(model, &iter);
180 ref = gtk_tree_row_reference_new(model, path);
181 refs_list = g_slist_append(refs_list, ref);
182 gtk_tree_path_free(path);
184 if (info->transaction_processed_cb)
186 info->transaction_processed_cb(trans_info,
192 while (gtk_tree_model_iter_next (model, &iter));
195 gnc_resume_gui_refresh();
202 on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
209 on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
211 GtkWidget *help_dialog = user_data;
213 gtk_widget_destroy(help_dialog);
221 GtkWidget *help_dialog, *box;
223 builder = gtk_builder_new();
224 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"textbuffer2");
225 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"textbuffer3");
226 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"textbuffer4");
227 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"textbuffer5");
228 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"matcher_help");
230 box = GTK_WIDGET(gtk_builder_get_object (builder,
"red"));
231 gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_red);
232 box = GTK_WIDGET(gtk_builder_get_object (builder,
"yellow"));
233 gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_yellow);
234 box = GTK_WIDGET(gtk_builder_get_object (builder,
"green"));
235 gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_green);
237 help_dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"matcher_help"));
238 gtk_window_set_transient_for(GTK_WINDOW(help_dialog),
239 GTK_WINDOW(info->dialog));
242 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, help_dialog);
244 g_object_unref(G_OBJECT(builder));
246 gtk_widget_show(help_dialog);
257 g_assert (trans_info);
262 _(
"Destination account for the auto-balance split."),
274 automatch_store_transactions(info, model, iter, trans_info);
286 gnc_gen_trans_add_toggled_cb (GtkCellRendererToggle *cell_renderer,
294 model = gtk_tree_view_get_model(gui->view);
295 if (!gtk_tree_model_get_iter_from_string(model, &iter, path))
297 gtk_tree_model_get(model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
308 refresh_model_row(gui, model, &iter, trans_info);
312 gnc_gen_trans_clear_toggled_cb (GtkCellRendererToggle *cell_renderer,
320 model = gtk_tree_view_get_model(gui->view);
321 if (!gtk_tree_model_get_iter_from_string(model, &iter, path))
323 gtk_tree_model_get(model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
334 refresh_model_row(gui, model, &iter, trans_info);
338 gnc_gen_trans_update_toggled_cb (GtkCellRendererToggle *cell_renderer,
346 model = gtk_tree_view_get_model(gui->view);
347 if (!gtk_tree_model_get_iter_from_string(model, &iter, path))
349 gtk_tree_model_get(model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
360 refresh_model_row(gui, model, &iter, trans_info);
364 gnc_gen_trans_row_activated_cb (GtkTreeView *view,
366 GtkTreeViewColumn *column,
373 model = gtk_tree_view_get_model(gui->view);
374 if (!gtk_tree_model_get_iter(model, &iter, path))
376 gtk_tree_model_get(model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
383 run_account_picker_dialog (gui, model, &iter, trans_info);
386 case GNCImport_CLEAR:
387 case GNCImport_UPDATE:
388 run_match_dialog (gui, trans_info);
394 PERR(
"I don't know what to do! (Yet...)");
397 refresh_model_row(gui, model, &iter, trans_info);
401 gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
407 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
409 gtk_tree_selection_unselect_iter(selection, &iter);
412 static GtkTreeViewColumn *
413 add_text_column(GtkTreeView *view,
const gchar *title,
int col_num)
415 GtkCellRenderer *renderer;
416 GtkTreeViewColumn *column;
418 renderer = gtk_cell_renderer_text_new();
419 g_object_set(G_OBJECT(renderer),
420 "foreground",
"black",
421 "foreground-set", TRUE,
423 column = gtk_tree_view_column_new_with_attributes
426 "background", DOWNLOADED_COL_COLOR,
428 gtk_tree_view_column_set_sort_column_id(column, col_num);
429 g_object_set(G_OBJECT(column),
433 gtk_tree_view_append_column(view, column);
437 static GtkTreeViewColumn *
438 add_toggle_column(GtkTreeView *view,
const gchar *title,
int col_num,
439 GCallback cb_fn, gpointer cb_arg)
441 GtkCellRenderer *renderer;
442 GtkTreeViewColumn *column;
444 renderer = gtk_cell_renderer_toggle_new();
445 column = gtk_tree_view_column_new_with_attributes
448 "cell-background", DOWNLOADED_COL_COLOR,
450 gtk_tree_view_column_set_sort_column_id(column, col_num);
451 g_object_set(G_OBJECT(column),
454 g_signal_connect(renderer,
"toggled", cb_fn, cb_arg);
455 gtk_tree_view_append_column(view, column);
461 gboolean show_account,
462 gboolean show_update)
466 GtkCellRenderer *renderer;
467 GtkTreeViewColumn *column;
468 GtkTreeSelection *selection;
471 store = gtk_list_store_new(NUM_DOWNLOADED_COLS,
472 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
473 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN,
474 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING,
475 GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_STRING);
476 gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
477 g_object_unref(store);
480 add_text_column(view, _(
"Date"), DOWNLOADED_COL_DATE);
481 column = add_text_column(view, _(
"Account"), DOWNLOADED_COL_ACCOUNT);
482 gtk_tree_view_column_set_visible(column, show_account);
483 add_text_column(view, _(
"Amount"), DOWNLOADED_COL_AMOUNT);
484 add_text_column(view, _(
"Description"), DOWNLOADED_COL_DESCRIPTION);
485 add_text_column(view, _(
"Memo"), DOWNLOADED_COL_MEMO);
486 add_toggle_column(view, _(
"A"), DOWNLOADED_COL_ACTION_ADD,
487 G_CALLBACK(gnc_gen_trans_add_toggled_cb), info);
488 column = add_toggle_column(view, _(
"U+R"), DOWNLOADED_COL_ACTION_UPDATE,
489 G_CALLBACK(gnc_gen_trans_update_toggled_cb), info);
490 gtk_tree_view_column_set_visible(column, show_update);
491 add_toggle_column(view, _(
"R"), DOWNLOADED_COL_ACTION_CLEAR,
492 G_CALLBACK(gnc_gen_trans_clear_toggled_cb), info);
495 renderer = gtk_cell_renderer_pixbuf_new();
496 g_object_set(renderer,
"xalign", 0.0, NULL);
497 column = gtk_tree_view_column_new_with_attributes(_(
"Info"), renderer,
498 "pixbuf", DOWNLOADED_COL_ACTION_PIXBUF,
499 "cell-background", DOWNLOADED_COL_COLOR,
501 renderer = gtk_cell_renderer_text_new();
502 g_object_set(G_OBJECT(renderer),
503 "foreground",
"black",
504 "foreground-set", TRUE,
506 gtk_tree_view_column_pack_start(column, renderer, TRUE);
507 gtk_tree_view_column_set_attributes(column, renderer,
508 "text", DOWNLOADED_COL_ACTION_INFO,
509 "background", DOWNLOADED_COL_COLOR,
511 gtk_tree_view_column_set_sort_column_id(column, DOWNLOADED_COL_ACTION_INFO);
512 g_object_set(G_OBJECT(column),
516 gtk_tree_view_append_column(info->view, column);
519 selection = gtk_tree_view_get_selection(info->view);
520 g_signal_connect(info->view,
"row-activated",
521 G_CALLBACK(gnc_gen_trans_row_activated_cb), info);
522 g_signal_connect(selection,
"changed",
523 G_CALLBACK(gnc_gen_trans_row_changed_cb), info);
527 const gchar* heading,
528 gboolean all_from_same_account,
529 gint match_date_hardlimit)
533 GtkWidget *heading_label;
534 GtkWidget *box, *pbox;
535 gboolean show_update;
544 builder = gtk_builder_new();
545 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"transaction_matcher");
546 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"transaction_matcher_content");
547 info->dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"transaction_matcher"));
548 g_assert (info->dialog != NULL);
551 pbox = GTK_WIDGET(gtk_builder_get_object (builder,
"transaction_matcher_vbox"));
552 box = GTK_WIDGET(gtk_builder_get_object (builder,
"transaction_matcher_content"));
553 gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
556 info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder,
"downloaded_view"));
557 g_assert (info->view != NULL);
560 gnc_gen_trans_init_view(info, all_from_same_account, show_update);
561 heading_label = GTK_WIDGET(gtk_builder_get_object (builder,
"heading_label"));
562 g_assert (heading_label != NULL);
569 gdk_color_parse(COLOR_RED, &info->color_back_red);
570 gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow);
571 gdk_color_parse(COLOR_GREEN, &info->color_back_green);
574 gtk_label_set_text (GTK_LABEL (heading_label), heading);
576 gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->dialog));
577 gtk_widget_show_all (GTK_WIDGET (info->dialog));
579 info->transaction_processed_cb = NULL;
582 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
584 g_object_unref(G_OBJECT(builder));
594 const gchar* heading,
595 gboolean all_from_same_account,
596 gint match_date_hardlimit)
600 GtkWidget *heading_label;
602 gboolean show_update;
611 builder = gtk_builder_new();
612 gnc_builder_add_from_file (builder,
"dialog-import.glade",
"transaction_matcher_content");
615 PERR(
"Error opening the glade builder interface");
618 box = GTK_WIDGET(gtk_builder_get_object (builder,
"transaction_matcher_content"));
619 gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);
622 info->view = GTK_TREE_VIEW(gtk_builder_get_object (builder,
"downloaded_view"));
623 g_assert (info->view != NULL);
626 gnc_gen_trans_init_view(info, all_from_same_account, show_update);
627 heading_label = GTK_WIDGET(gtk_builder_get_object (builder,
"heading_label"));
628 g_assert (heading_label != NULL);
631 gdk_color_parse(COLOR_RED, &info->color_back_red);
632 gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow);
633 gdk_color_parse(COLOR_GREEN, &info->color_back_green);
636 gtk_label_set_text (GTK_LABEL (heading_label), heading);
638 info->transaction_processed_cb = NULL;
641 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, info);
643 g_object_unref(G_OBJECT(builder));
650 on_matcher_ok_clicked (NULL, info);
658 GNCTransactionProcessedCB trans_processed_cb,
661 info->user_data = user_data;
662 info->transaction_processed_cb = trans_processed_cb;
670 result = gtk_dialog_run (GTK_DIALOG (info->dialog));
686 GtkTreeSelection *selection;
687 gchar *tmp, *imbalance, *text, *color;
688 const gchar *ro_text;
695 store = GTK_LIST_STORE(model);
696 gtk_list_store_set(store, iter, DOWNLOADED_COL_DATA, info, -1);
702 gtk_list_store_set(store, iter, DOWNLOADED_COL_ACCOUNT, ro_text, -1);
706 gtk_list_store_set(store, iter, DOWNLOADED_COL_DATE, text, -1);
710 ro_text = xaccPrintAmount
712 gnc_split_amount_print_info(split, TRUE)
714 gtk_list_store_set(store, iter, DOWNLOADED_COL_AMOUNT, ro_text, -1);
718 gtk_list_store_set(store, iter, DOWNLOADED_COL_DESCRIPTION, ro_text, -1);
722 gtk_list_store_set(store, iter, DOWNLOADED_COL_MEMO, ro_text, -1);
727 ro_text = text = color = NULL;
733 ro_text = _(
"New, already balanced");
745 gnc_commodity_print_info
759 g_strdup_printf(_(
"New, transfer %s to (manual) \"%s\""),
767 g_strdup_printf(_(
"New, transfer %s to (auto) \"%s\""),
775 color = COLOR_YELLOW;
778 g_strdup_printf(_(
"New, UNBALANCED (need acct to transfer %s)!"),
784 case GNCImport_CLEAR:
790 ro_text = _(
"Reconcile (manual) match");
794 ro_text = _(
"Reconcile (auto) match");
800 ro_text = _(
"Match missing!");
803 case GNCImport_UPDATE:
809 ro_text = _(
"Update and reconcile (manual) match");
813 ro_text = _(
"Update and reconcile (auto) match");
819 ro_text = _(
"Match missing!");
824 ro_text = _(
"Do not import (no action selected)");
828 ro_text =
"WRITEME, this is an unknown action";
832 gtk_list_store_set(store, iter,
833 DOWNLOADED_COL_COLOR, color,
834 DOWNLOADED_COL_ACTION_INFO, ro_text ? ro_text : text,
840 gtk_list_store_set(store, iter,
841 DOWNLOADED_COL_ACTION_ADD,
847 gtk_list_store_set(store, iter,
848 DOWNLOADED_COL_ACTION_PIXBUF,
852 GTK_WIDGET(gui->view)),
856 gtk_list_store_set(store, iter,
857 DOWNLOADED_COL_ACTION_CLEAR,
863 gtk_list_store_set(store, iter,
864 DOWNLOADED_COL_ACTION_PIXBUF,
868 GTK_WIDGET(gui->view)),
872 gtk_list_store_set(store, iter,
873 DOWNLOADED_COL_ACTION_UPDATE,
879 gtk_list_store_set(store, iter,
880 DOWNLOADED_COL_ACTION_PIXBUF,
884 GTK_WIDGET(gui->view)),
888 selection = gtk_tree_view_get_selection(gui->view);
889 gtk_tree_selection_unselect_all(selection);
917 model = gtk_tree_view_get_model(gui->view);
918 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
919 refresh_model_row (gui, model, &iter, transaction_info);
934 refresh_model_row(info, model, iter, trans_info);
void gnc_import_match_picker_run_and_close(GNCImportTransInfo *transaction_info)
GNCImportTransInfo * gnc_import_TransInfo_new(Transaction *trans, GncImportMatchMap *matchmap)
time64 xaccTransGetDate(const Transaction *trans)
utility functions for the GnuCash UI
GNCImportSettings * gnc_import_Settings_new(void)
void gnc_import_TransInfo_delete(GNCImportTransInfo *info)
gnc_numeric gnc_numeric_neg(gnc_numeric a)
void gnc_import_TransInfo_set_ref_id(GNCImportTransInfo *info, guint32 ref_id)
void gnc_import_Settings_delete(GNCImportSettings *settings)
Generic importer backend interface.
Split * gnc_import_TransInfo_get_fsplit(const GNCImportTransInfo *info)
GdkPixbuf * gen_probability_pixbuf(gint score_original, GNCImportSettings *settings, GtkWidget *widget)
Account * gnc_import_select_account(GtkWidget *parent, const gchar *account_online_id_value, gboolean auto_create, const gchar *account_human_description, const gnc_commodity *new_account_default_commodity, GNCAccountType new_account_default_type, Account *default_selection, gboolean *ok_pressed)
void on_matcher_help_clicked(GtkButton *button, gpointer user_data)
Transaction matcher main window.
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
void gnc_gen_trans_list_add_tp_cb(GNCImportMainMatcher *info, GNCTransactionProcessedCB trans_processed_cb, gpointer user_data)
Generic and very flexible account matcher/picker.
void gnc_import_TransInfo_set_destacc(GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
Import preference handling. User preference interface for transaction matching (for both the gui and ...
#define PERR(format, args...)
GNCImportMainMatcher * gnc_gen_trans_list_new(GtkWidget *parent, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans)
void gnc_import_TransInfo_init_matches(GNCImportTransInfo *trans_info, GNCImportSettings *settings)
gboolean gnc_gen_trans_list_run(GNCImportMainMatcher *info)
GNCImportAction gnc_import_TransInfo_get_action(const GNCImportTransInfo *info)
char * qof_print_date(time64 secs)
gint gnc_import_MatchInfo_get_probability(const GNCImportMatchInfo *info)
gchar * gnc_account_get_full_name(const Account *account)
The transaction match picker dialog interface.
GtkWidget * gnc_gen_trans_list_widget(GNCImportMainMatcher *info)
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
void gnc_gen_trans_assist_start(GNCImportMainMatcher *info)
gboolean gnc_import_process_trans_item(GncImportMatchMap *matchmap, GNCImportTransInfo *trans_info)
void gnc_import_TransInfo_set_action(GNCImportTransInfo *info, GNCImportAction action)
void gnc_import_Settings_set_match_date_hardlimit(GNCImportSettings *s, gint m)
gboolean gnc_import_TransInfo_refresh_destacc(GNCImportTransInfo *transaction_info, GncImportMatchMap *matchmap)
const char * xaccTransGetDescription(const Transaction *trans)
gboolean gnc_import_exists_online_id(Transaction *trans)
All type declarations for the whole Gnucash engine.
void gnc_gen_trans_list_add_trans_with_ref_id(GNCImportMainMatcher *gui, Transaction *trans, guint32 ref_id)
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
gboolean gnc_import_TransInfo_get_match_selected_manually(const GNCImportTransInfo *info)
Account * xaccSplitGetAccount(const Split *s)
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
void gnc_gen_trans_list_delete(GNCImportMainMatcher *info)
Account * gnc_import_TransInfo_get_destacc(const GNCImportTransInfo *info)
const char * xaccSplitGetMemo(const Split *split)
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
const char * xaccAccountGetName(const Account *acc)
gboolean gnc_import_Settings_get_action_skip_enabled(GNCImportSettings *settings)
gboolean gnc_import_TransInfo_is_balanced(const GNCImportTransInfo *info)
GNCImportMainMatcher * gnc_gen_trans_assist_new(GtkWidget *parent, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
const gchar * QofLogModule
gnc_numeric xaccSplitGetAmount(const Split *split)
gboolean gnc_import_TransInfo_get_destacc_selected_manually(const GNCImportTransInfo *info)