From 48fe2ea60b8549249c4811069dd9cc71cc2f259a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 3 Nov 2020 14:05:38 +0000 Subject: [PATCH] Add option to hide memo column on import-main-matcher This has stemmed from cstim's PR #810 which I have added here after refactoring the gnc_gen_trans_list_new function in previous commit. --- gnucash/gtkbuilder/dialog-import.glade | 22 ++++++++++++++++++--- gnucash/import-export/import-main-matcher.c | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/gnucash/gtkbuilder/dialog-import.glade b/gnucash/gtkbuilder/dialog-import.glade index 71f7dac7b5..76d6a6e497 100644 --- a/gnucash/gtkbuilder/dialog-import.glade +++ b/gnucash/gtkbuilder/dialog-import.glade @@ -926,7 +926,7 @@ center - Show the _Account column + Show _Account column True True False @@ -940,6 +940,22 @@ 0 + + + Show _Memo column + True + True + False + center + True + True + + + False + True + 1 + + Show _matched information @@ -952,7 +968,7 @@ False True - 1 + 2 @@ -967,7 +983,7 @@ False True - 2 + 3 diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c index 26ffa744a8..d30c9b3dd0 100644 --- a/gnucash/import-export/import-main-matcher.c +++ b/gnucash/import-export/import-main-matcher.c @@ -69,6 +69,7 @@ struct _main_matcher_info gpointer user_data; GNCImportPendingMatches *pending_matches; GtkTreeViewColumn *account_column; + GtkTreeViewColumn *memo_column; GtkWidget *show_account_column; GtkWidget *show_matched_info; GtkWidget *reconcile_after_close; @@ -1040,7 +1041,7 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info, gtk_tree_view_column_set_visible (info->account_column, show_account); add_text_column (view, _("Amount"), DOWNLOADED_COL_AMOUNT, FALSE); add_text_column (view, _("Description"), DOWNLOADED_COL_DESCRIPTION, FALSE); - add_text_column (view, _("Memo"), DOWNLOADED_COL_MEMO, TRUE); + info->memo_column = add_text_column (view, _("Memo"), DOWNLOADED_COL_MEMO, TRUE); add_toggle_column (view, C_("Column header for 'Adding transaction'", "A"), DOWNLOADED_COL_ACTION_ADD, G_CALLBACK(gnc_gen_trans_add_toggled_cb), info); @@ -1096,6 +1097,14 @@ show_account_column_toggled_cb (GtkToggleButton *togglebutton, gtk_toggle_button_get_active (togglebutton)); } +static void +show_memo_column_toggled_cb (GtkToggleButton *togglebutton, + GNCImportMainMatcher *info) +{ + gtk_tree_view_column_set_visible (info->memo_column, + gtk_toggle_button_get_active (togglebutton)); +} + static void show_matched_info_toggled_cb (GtkToggleButton *togglebutton, GNCImportMainMatcher *info) @@ -1123,7 +1132,7 @@ gnc_gen_trans_common_setup (GNCImportMainMatcher *info, { GtkStyleContext *stylectxt; GdkRGBA color; - GtkWidget *heading_label; + GtkWidget *heading_label, *button; gboolean show_update; info->pending_matches = gnc_import_PendingMatches_new (); @@ -1145,6 +1154,11 @@ gnc_gen_trans_common_setup (GNCImportMainMatcher *info, g_signal_connect (G_OBJECT(info->show_account_column), "toggled", G_CALLBACK(show_account_column_toggled_cb), info); + button = GTK_WIDGET(gtk_builder_get_object (builder, "show_memo_column_button")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE); + g_signal_connect (G_OBJECT(button), "toggled", + G_CALLBACK(show_memo_column_toggled_cb), info); + info->show_matched_info = GTK_WIDGET(gtk_builder_get_object (builder, "show_matched_info_button")); g_signal_connect (G_OBJECT(info->show_matched_info), "toggled", G_CALLBACK(show_matched_info_toggled_cb), info); @@ -1158,6 +1172,7 @@ gnc_gen_trans_common_setup (GNCImportMainMatcher *info, g_assert (heading_label != NULL); if (heading) + gtk_label_set_text (GTK_LABEL(heading_label), heading); info->transaction_processed_cb = NULL; @@ -1596,6 +1611,7 @@ refresh_model_row (GNCImportMainMatcher *gui, GtkTreePath *path = gtk_tree_model_get_path (model, iter); gtk_tree_view_column_set_visible (gui->account_column, TRUE); + gtk_tree_view_column_set_visible (gui->memo_column, TRUE); gtk_tree_view_expand_row (GTK_TREE_VIEW(gui->view), path, TRUE); gtk_tree_path_free (path);