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.
This commit is contained in:
Robert Fewell 2020-11-03 14:05:38 +00:00
parent bf483696de
commit 48fe2ea60b
2 changed files with 37 additions and 5 deletions

View File

@ -926,7 +926,7 @@
<property name="halign">center</property>
<child>
<object class="GtkCheckButton" id="show_source_account_button">
<property name="label" translatable="yes">Show the _Account column</property>
<property name="label" translatable="yes">Show _Account column</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -940,6 +940,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_memo_column_button">
<property name="label" translatable="yes">Show _Memo column</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_matched_info_button">
<property name="label" translatable="yes">Show _matched information</property>
@ -952,7 +968,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@ -967,7 +983,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>

View File

@ -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);