gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Wed Jul 26 11:32:52 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/2da8e5ed (commit)
via https://github.com/Gnucash/gnucash/commit/b93627eb (commit)
via https://github.com/Gnucash/gnucash/commit/e9f52d53 (commit)
via https://github.com/Gnucash/gnucash/commit/818e27de (commit)
from https://github.com/Gnucash/gnucash/commit/41724687 (commit)
commit 2da8e5eda817175f3228b808f04ac930e47be7e5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jul 17 14:02:49 2023 +0800
[import-main-matcher.cpp] compact update_child_row
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 7db69bd547..5ec961b489 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1857,36 +1857,23 @@ update_child_row (GNCImportMatchInfo *sel_match, GtkTreeModel *model, GtkTreeIte
else
gtk_tree_model_iter_nth_child (model, &child, iter, 0);
- gchar *text = qof_print_date (xaccTransGetDate (sel_match->trans));
- gtk_tree_store_set (store, &child, DOWNLOADED_COL_DATE_TXT, text, -1);
- g_free (text);
+ auto account_str = (xaccTransCountSplits (sel_match->trans) == 2)
+ ? xaccAccountGetName (xaccSplitGetAccount (xaccSplitGetOtherSplit (sel_match->split)))
+ : _("-- Split Transaction --");
+ auto amount_str = xaccPrintAmount (xaccSplitGetAmount (sel_match->split), gnc_split_amount_print_info (sel_match->split, true));
+ auto date = qof_print_date (xaccTransGetDate (sel_match->trans));
- if (xaccTransCountSplits (sel_match->trans) == 2)
- gtk_tree_store_set (store, &child, DOWNLOADED_COL_ACCOUNT, xaccAccountGetName (
- xaccSplitGetAccount (xaccSplitGetOtherSplit (sel_match->split))), -1);
- else
- gtk_tree_store_set (store, &child, DOWNLOADED_COL_ACCOUNT, _("-- Split Transaction --"), -1);
-
- const gchar *ro_text = xaccPrintAmount (xaccSplitGetAmount (sel_match->split),
- gnc_split_amount_print_info (sel_match->split, true));
-
- gtk_tree_store_set (store, &child,
- DOWNLOADED_COL_AMOUNT, ro_text,
- -1);
-
- const gchar *memo = xaccSplitGetMemo (sel_match->split);
gtk_tree_store_set (store, &child,
- DOWNLOADED_COL_MEMO, memo,
+ DOWNLOADED_COL_ACCOUNT, account_str,
+ DOWNLOADED_COL_DATE_TXT, date,
+ DOWNLOADED_COL_AMOUNT, amount_str,
+ DOWNLOADED_COL_MEMO, xaccSplitGetMemo (sel_match->split),
DOWNLOADED_COL_MEMO_STYLE, PANGO_STYLE_NORMAL,
- -1);
-
- const gchar *desc = xaccTransGetDescription (sel_match->trans);
- gtk_tree_store_set (store, &child,
- DOWNLOADED_COL_DESCRIPTION, desc,
+ DOWNLOADED_COL_DESCRIPTION, xaccTransGetDescription (sel_match->trans),
DOWNLOADED_COL_DESCRIPTION_STYLE, PANGO_STYLE_NORMAL,
+ DOWNLOADED_COL_ENABLE, false,
-1);
-
- gtk_tree_store_set (store, &child, DOWNLOADED_COL_ENABLE, false, -1);
+ g_free (date);
}
static gchar *
commit b93627ebcbfed1a059efd151df3aae3202dbae11
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jul 16 23:01:33 2023 +0800
[import-match-picker.cpp] compact match_update_match_model
rewrite using forloop instead of while when scanning GList.
diff --git a/gnucash/import-export/import-match-picker.cpp b/gnucash/import-export/import-match-picker.cpp
index 1a331fe09f..732012b698 100644
--- a/gnucash/import-export/import-match-picker.cpp
+++ b/gnucash/import-export/import-match-picker.cpp
@@ -157,115 +157,60 @@ downloaded_transaction_append(GNCImportMatchPicker * matcher,
static void
match_update_match_model (GNCImportMatchPicker *matcher)
{
- GNCImportMatchInfo * match_info;
- GtkTreeIter iter;
- gboolean show_reconciled;
- gchar reconciled;
- GtkListStore *match_store;
- GList * list_element;
- gchar *text;
- const gchar *ro_text;
- GNCImportPendingMatchType pending_match_type;
+ g_return_if_fail (matcher);
- show_reconciled = gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON(matcher->reconciled_chk));
+ auto show_reconciled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(matcher->reconciled_chk));
/* Now rewrite the "match" model based on that trans. */
- match_store = GTK_LIST_STORE(gtk_tree_view_get_model(matcher->match_view));
+ auto match_store = GTK_LIST_STORE(gtk_tree_view_get_model(matcher->match_view));
gtk_list_store_clear(match_store);
- list_element = g_list_first (gnc_import_TransInfo_get_match_list
- (matcher->selected_trans_info));
- while (list_element != NULL)
+
+ for (auto n = gnc_import_TransInfo_get_match_list (matcher->selected_trans_info); n; n = g_list_next (n))
{
- match_info = static_cast<GNCImportMatchInfo*>(list_element->data);
+ auto match_info = static_cast<GNCImportMatchInfo*>(n->data);
+ auto split = gnc_import_MatchInfo_get_split (match_info);
+ auto reconciled = xaccSplitGetReconcile (split);
/* Skip this match if reconciled and we're not showing those */
- reconciled = xaccSplitGetReconcile
- (gnc_import_MatchInfo_get_split(match_info));
if (show_reconciled == FALSE && reconciled != NREC)
- {
- list_element = g_list_next (list_element);
continue;
- }
- gtk_list_store_append(match_store, &iter);
+ auto probability = gnc_import_MatchInfo_get_probability (match_info);
+ auto trans = xaccSplitGetParent (split);
+ auto match_type = gnc_import_PendingMatches_get_match_type (matcher->pending_matches, match_info);
/* Print fields. */
-
- /* Probability */
- text = g_strdup_printf("%d", gnc_import_MatchInfo_get_probability (match_info));
- gtk_list_store_set(match_store, &iter, MATCHER_COL_CONFIDENCE, text, -1);
- g_free(text);
-
- /* Date */
- text =
- qof_print_date
- ( xaccTransGetDate
- ( xaccSplitGetParent
- ( gnc_import_MatchInfo_get_split(match_info) ) ));
- gtk_list_store_set(match_store, &iter, MATCHER_COL_DATE, text, -1);
- g_free(text);
-
- /* Amount */
- ro_text =
- xaccPrintAmount( xaccSplitGetAmount ( gnc_import_MatchInfo_get_split(match_info) ),
- gnc_split_amount_print_info(gnc_import_MatchInfo_get_split(match_info), TRUE)
- );
- gtk_list_store_set(match_store, &iter, MATCHER_COL_AMOUNT, ro_text, -1);
-
- /*Description*/
- ro_text = xaccTransGetDescription
- ( xaccSplitGetParent( gnc_import_MatchInfo_get_split(match_info)) );
- gtk_list_store_set(match_store, &iter, MATCHER_COL_DESCRIPTION, ro_text, -1);
-
- /*Split memo*/
- ro_text = xaccSplitGetMemo(gnc_import_MatchInfo_get_split(match_info) );
- gtk_list_store_set(match_store, &iter, MATCHER_COL_MEMO, ro_text, -1);
-
- /*Reconciled*/
- ro_text = gnc_get_reconcile_str (reconciled);
- gtk_list_store_set (match_store, &iter, MATCHER_COL_RECONCILED, ro_text,
+ auto confidence = g_strdup_printf ("%d", probability);
+ auto date = qof_print_date (xaccTransGetDate (trans));
+ auto amount = xaccPrintAmount (xaccSplitGetAmount (split), gnc_split_amount_print_info (split, true));
+ auto description = xaccTransGetDescription (trans);
+ auto memo = xaccSplitGetMemo (split);
+ auto pixbuf = probability ? gen_probability_pixbuf (probability, matcher->user_settings,
+ GTK_WIDGET(matcher->match_view)) : nullptr;
+ auto pending_str = (match_type == GNCImportPending_MANUAL || match_type == GNCImportPending_AUTO)
+ ? g_strdup_printf ("%s (%s)", gnc_get_reconcile_str (CREC), gnc_import_PendingMatches_get_type_str (match_type))
+ : nullptr;
+
+ GtkTreeIter iter;
+ gtk_list_store_append (match_store, &iter);
+ gtk_list_store_set (match_store, &iter,
+ MATCHER_COL_DATE, date,
+ MATCHER_COL_CONFIDENCE, confidence,
+ MATCHER_COL_CONFIDENCE_PIXBUF, pixbuf,
+ MATCHER_COL_AMOUNT, amount,
+ MATCHER_COL_DESCRIPTION, description,
+ MATCHER_COL_MEMO, memo,
+ MATCHER_COL_RECONCILED, gnc_get_reconcile_str (reconciled),
+ MATCHER_COL_INFO_PTR, match_info,
+ MATCHER_COL_PENDING, pending_str,
-1);
-
- /*Pending Action*/
- pending_match_type = gnc_import_PendingMatches_get_match_type
- (matcher->pending_matches, match_info);
-
- /* If it has a pending match mark it cleared, otherwise leave alone */
- if (pending_match_type == GNCImportPending_MANUAL ||
- pending_match_type == GNCImportPending_AUTO)
- {
- ro_text = gnc_get_reconcile_str (CREC);
- text = g_strdup_printf("%s (%s)",
- ro_text,
- gnc_import_PendingMatches_get_type_str
- (pending_match_type));
-
- gtk_list_store_set (match_store, &iter, MATCHER_COL_PENDING, text, -1);
- g_free (text);
- }
-
- gtk_list_store_set(match_store, &iter, MATCHER_COL_INFO_PTR, match_info, -1);
- if (gnc_import_MatchInfo_get_probability(match_info) != 0)
- {
- gtk_list_store_set(match_store, &iter,
- MATCHER_COL_CONFIDENCE_PIXBUF,
- gen_probability_pixbuf(gnc_import_MatchInfo_get_probability(match_info),
- matcher->user_settings,
- GTK_WIDGET(matcher->match_view)),
- -1);
- }
-
- if (match_info ==
- gnc_import_TransInfo_get_selected_match (matcher->selected_trans_info))
- {
- GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection(matcher->match_view);
- gtk_tree_selection_select_iter(selection, &iter);
- }
+ if (match_info == gnc_import_TransInfo_get_selected_match (matcher->selected_trans_info))
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (matcher->match_view), &iter);
- list_element = g_list_next(list_element);
+ g_free (confidence);
+ g_free (date);
+ g_free (pending_str);
}
}
commit e9f52d53bb2be827e182a3014d804cbb40280b9d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jul 16 23:13:53 2023 +0800
[import-match-picker.cpp] compact downloaded_transaction_append
diff --git a/gnucash/import-export/import-match-picker.cpp b/gnucash/import-export/import-match-picker.cpp
index 673129a0c9..1a331fe09f 100644
--- a/gnucash/import-export/import-match-picker.cpp
+++ b/gnucash/import-export/import-match-picker.cpp
@@ -95,27 +95,21 @@ static void
downloaded_transaction_append(GNCImportMatchPicker * matcher,
GNCImportTransInfo * transaction_info)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- Transaction *trans;
- Split *split;
- gchar *text;
- const gchar *ro_text;
- gboolean found = FALSE;
- GNCImportTransInfo *local_info;
-
- g_assert(matcher);
- g_assert(transaction_info);
+ g_return_if_fail (matcher);
+ g_return_if_fail (transaction_info);
- /*DEBUG("Begin");*/
+ auto found = false;
+ auto store = GTK_LIST_STORE(gtk_tree_view_get_model(matcher->downloaded_view));
+ auto split = gnc_import_TransInfo_get_fsplit(transaction_info);
+ auto trans = gnc_import_TransInfo_get_trans(transaction_info);
/* Has the transaction already been added? */
- store = GTK_LIST_STORE(gtk_tree_view_get_model(matcher->downloaded_view));
+ GtkTreeIter iter;
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
{
do
{
+ GNCImportTransInfo *local_info;
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
DOWNLOADED_COL_INFO_PTR, &local_info,
-1);
@@ -130,44 +124,34 @@ downloaded_transaction_append(GNCImportMatchPicker * matcher,
if (!found)
gtk_list_store_append(store, &iter);
- split = gnc_import_TransInfo_get_fsplit(transaction_info);
- trans = gnc_import_TransInfo_get_trans(transaction_info);
-
- /*Account*/
- ro_text = xaccAccountGetName(xaccSplitGetAccount(split));
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_ACCOUNT, ro_text, -1);
-
- /*Date*/
- text = qof_print_date(xaccTransGetDate(trans));
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_DATE, text, -1);
- g_free(text);
-
- /*Amount*/
- ro_text = xaccPrintAmount(xaccSplitGetAmount(split),
- gnc_split_amount_print_info(split, TRUE));
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_AMOUNT, ro_text, -1);
-
- /*Description*/
- ro_text = xaccTransGetDescription(trans);
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_DESCRIPTION, ro_text, -1);
-
- /*Memo*/
- ro_text = xaccSplitGetMemo(split);
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_MEMO, ro_text, -1);
+ auto account = xaccAccountGetName(xaccSplitGetAccount(split));
+ auto date = qof_print_date(xaccTransGetDate(trans));
+ auto amount = g_strdup (xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE)));
+ auto desc = xaccTransGetDescription(trans);
+ auto memo = xaccSplitGetMemo(split);
/*Imbalance*/
/* Assume that the importer won't create a transaction that involves two or more
currencies and no non-currency commodity. In that case can use the simpler
value imbalance check. */
- ro_text = xaccPrintAmount(xaccTransGetImbalanceValue(trans),
- gnc_commodity_print_info (xaccTransGetCurrency (trans), TRUE));
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_BALANCED, ro_text, -1);
-
- gtk_list_store_set(store, &iter, DOWNLOADED_COL_INFO_PTR,
- transaction_info, -1);
-
- selection = gtk_tree_view_get_selection(matcher->downloaded_view);
- gtk_tree_selection_select_iter(selection, &iter);
+ auto imbalance = g_strdup (xaccPrintAmount (xaccTransGetImbalanceValue(trans),
+ gnc_commodity_print_info (xaccTransGetCurrency (trans), TRUE)));
+
+ gtk_list_store_set (store, &iter,
+ DOWNLOADED_COL_ACCOUNT, account,
+ DOWNLOADED_COL_DATE, date,
+ DOWNLOADED_COL_AMOUNT, amount,
+ DOWNLOADED_COL_DESCRIPTION, desc,
+ DOWNLOADED_COL_MEMO, memo,
+ DOWNLOADED_COL_BALANCED, imbalance,
+ DOWNLOADED_COL_INFO_PTR, transaction_info,
+ -1);
+
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection(matcher->downloaded_view), &iter);
+
+ g_free (date);
+ g_free (amount);
+ g_free (imbalance);
}
static void
commit 818e27de0346e406c57a1398b421fa2ec4092d34
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jul 17 13:11:34 2023 +0800
[import-main-matcher.cpp] rename override to override_widget
to avoid clashing with the cpp "override" specifier.
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index ea00d9f770..7db69bd547 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -947,15 +947,15 @@ match_func (GtkEntryCompletion *completion, const char *entry_str,
typedef struct
{
GtkWidget *entry;
- GObject *override;
+ GObject *override_widget;
bool *can_edit;
GHashTable *hash;
const char *initial;
} EntryInfo;
-static void override_clicked (GtkWidget *widget, EntryInfo *entryinfo)
+static void override_widget_clicked (GtkWidget *widget, EntryInfo *entryinfo)
{
- gtk_widget_set_visible (GTK_WIDGET (entryinfo->override), false);
+ gtk_widget_set_visible (GTK_WIDGET (entryinfo->override_widget), false);
gtk_widget_set_sensitive (entryinfo->entry, true);
gtk_entry_set_text (GTK_ENTRY (entryinfo->entry), "");
gtk_widget_grab_focus (entryinfo->entry);
@@ -967,19 +967,19 @@ setup_entry (EntryInfo *entryinfo)
{
bool sensitive = *entryinfo->can_edit;
GtkWidget *entry = entryinfo->entry;
- GtkWidget *override = GTK_WIDGET (entryinfo->override);
+ GtkWidget *override_widget = GTK_WIDGET (entryinfo->override_widget);
GHashTable *hash = entryinfo->hash;
const char *initial = entryinfo->initial;
gtk_widget_set_sensitive (entry, sensitive);
- gtk_widget_set_visible (override, !sensitive);
+ gtk_widget_set_visible (override_widget, !sensitive);
if (sensitive && initial && *initial)
gtk_entry_set_text (GTK_ENTRY (entry), initial);
else if (!sensitive)
{
gtk_entry_set_text (GTK_ENTRY (entry), _("Click Edit to modify"));
- g_signal_connect (override, "clicked", G_CALLBACK (override_clicked),
+ g_signal_connect (override_widget, "clicked", G_CALLBACK (override_widget_clicked),
entryinfo);
}
Summary of changes:
gnucash/import-export/import-main-matcher.cpp | 49 +++---
gnucash/import-export/import-match-picker.cpp | 211 +++++++++-----------------
2 files changed, 88 insertions(+), 172 deletions(-)
More information about the gnucash-changes
mailing list