From e2d570f13f04558ea72666d12a1c5b9e0914502a Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 2 Apr 2024 23:04:35 +0800 Subject: [PATCH] [import-main-matcher.cpp] show separate warning column with tooltip ... instead of tacking on the end of the "Additional Comments" column --- gnucash/import-export/import-main-matcher.cpp | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp index 1fd12e59e16..57a9c721537 100644 --- a/gnucash/import-export/import-main-matcher.cpp +++ b/gnucash/import-export/import-main-matcher.cpp @@ -40,7 +40,9 @@ #include #include +#include #include +#include #include "import-main-matcher.h" @@ -116,6 +118,7 @@ enum downloaded_cols DOWNLOADED_COL_ACTION_UPDATE, DOWNLOADED_COL_ACTION_INFO, DOWNLOADED_COL_ACTION_PIXBUF, + DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP, DOWNLOADED_COL_DATA, DOWNLOADED_COL_COLOR, DOWNLOADED_COL_ENABLE, @@ -1559,7 +1562,7 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, //memo stuff G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, - GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_STRING, + GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); gtk_tree_view_set_model (view, GTK_TREE_MODEL(store)); g_object_unref (store); @@ -1983,6 +1986,7 @@ refresh_model_row (GNCImportMainMatcher *gui, ro_text = text = NULL; const gchar *color = NULL; bool show_pixbuf = true; + std::vector warnings; switch (gnc_import_TransInfo_get_action (info)) { case GNCImport_ADD: @@ -2039,9 +2043,7 @@ refresh_model_row (GNCImportMainMatcher *gui, { static const char* recn_date_warning = N_("The import date is earlier \ than destination account reconcile date. Further reconciliation may be difficult."); - auto newtext = g_strdup_printf ("%s %s", text, _(recn_date_warning)); - g_free (text); - text = newtext; + warnings.emplace_back (_(recn_date_warning)); } g_free (acct_full_name); @@ -2151,6 +2153,19 @@ than destination account reconcile date. Further reconciliation may be difficult DOWNLOADED_COL_ACTION_ADD, gnc_import_TransInfo_get_action (info) == GNCImport_ADD, -1); + + if (gnc_import_TransInfo_get_action (info) == GNCImport_ADD && !warnings.empty()) + { + auto pixbuf = gen_warning_pixbuf (); + auto warnings_str = std::accumulate (warnings.begin(), warnings.end(), std::string{}, + [](const std::string& a, const std::string& b) + { return a.empty() ? b : a + "\n" + b; }); + gtk_tree_store_set (store, iter, + DOWNLOADED_COL_ACTION_PIXBUF, pixbuf, + DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP, warnings_str.c_str(), + -1); + } + if (gnc_import_TransInfo_get_action (info) == GNCImport_SKIP) { /*If skipping the row, there is no best match's confidence pixmap*/ @@ -2495,6 +2510,10 @@ query_tooltip_tree_view_cb (GtkWidget *widget, gint x, gint y, -1); break; default: + if (!g_strcmp0 (gtk_tree_view_column_get_title (column), _("Info"))) + gtk_tree_model_get (model, &iter, + DOWNLOADED_COL_ACTION_PIXBUF_TOOLTIP, &tooltip_text, + -1); break; }