Hey all, I finally finished implementing everything I mentioned back in early 2009, except the KvpFrame stuff. It's been hard to find time to work on this, and the KvpFrame issue isn't really any more of a problem as a result of my changes, so I think I will draw the line here. I ended up making automatched transactions yellow, like unbalanced transactions, since the user is expected to pick a destination in both cases. The idea is that the user will go through and review all of the automatched transactions, switching them to manual one by one using the A column checkbox, untill all of the items in the dialog are green.
I make a special case for unbalanced rows, which are checked, not inconsistent, and cannot be toggled to manual using the "A" column checkbox. They can still be switched to a state where the destination account is manually set to the Imbalance account, through the picker dialog. One quirk of doing it this way is that these items sort with manually set items instead of with automatched items, despite being yellow. I would just as soon have unbalanced rows work exactly the same way as other automatched accounts, but I figured that the dialog discourages setting Imbalance as the destination account, so the behaviour I chose is meant to continue that. Patches are attached. On Wed, Feb 11, 2009 at 9:00 PM, Simon Ruggier <simo...@gmail.com> wrote: > On Wed, Feb 11, 2009 at 1:20 AM, David Reiser <dbrei...@earthlink.net> wrote: >> Sorry for my screw-up. And thank you very much for taking the time to track >> down these bugs. > > No problem, and I appreciate that you took the time to test my patch. > > As mentioned before, I do intend to make the following changes when I > get the chance, so comments are welcome: > - make automatched transactions a different colour (suggestions > welcome :) probably blue, or a different shade of green), and update > the help dialog to reflect this, of course > - change the add checkbox behaviour to allow the user to quickly > change an automatched transaction to manual (this should be quick), > and also mention this in the help dialogue > - try to decrement token counts in KvpFrames so that the token counts > match the account data >
From c0065bbc460f452924f6f9b292d2b98c0046c083 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Sat, 9 Jan 2010 21:22:04 -0500 Subject: [PATCH 1/7] import-main-matcher.c: remove stray comment --- src/import-export/import-main-matcher.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 414415e..7d51075 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -707,7 +707,6 @@ refresh_model_row (GNCImportMainMatcher *gui, if (text) g_free(text); - /* Set the pixmaps */ gtk_list_store_set(store, iter, DOWNLOADED_COL_ACTION_ADD, gnc_import_TransInfo_get_action(info) == GNCImport_ADD, -- 1.7.1
From edf32bf8f00e012dc4133fb23f8dea1473c07ba1 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Wed, 11 Feb 2009 23:39:23 -0500 Subject: [PATCH 2/7] Don't bother caching parsed colors in struct _main_matcher_info It's not that expensive to just parse them whenever a dialog is requested. --- src/import-export/import-main-matcher.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 7d51075..0eda05b 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -49,9 +49,6 @@ struct _main_matcher_info GtkWidget *dialog; GtkTreeView *view; GNCImportSettings *user_settings; - GdkColor color_back_red; - GdkColor color_back_green; - GdkColor color_back_yellow; int selected_row; }; @@ -187,6 +184,17 @@ on_matcher_help_close_clicked (GtkButton *button, } static void +gladexml_widget_set_color(GladeXML *xml, + const char *widget_name, + const char *color_name) +{ + GtkWidget *widget = glade_xml_get_widget (xml, widget_name); + GdkColor color; + gdk_color_parse(color_name, &color); + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color); +} + +static void on_matcher_help_clicked (GtkButton *button, gpointer user_data) { @@ -196,12 +204,9 @@ on_matcher_help_clicked (GtkButton *button, xml = gnc_glade_xml_new ("generic-import.glade", "matcher_help"); - box = glade_xml_get_widget (xml, "red"); - gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_red); - box = glade_xml_get_widget (xml, "yellow"); - gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_yellow); - box = glade_xml_get_widget (xml, "green"); - gtk_widget_modify_bg(box, GTK_STATE_NORMAL, &info->color_back_green); + gladexml_widget_set_color (xml, "red", COLOR_RED); + gladexml_widget_set_color (xml, "yellow", COLOR_YELLOW); + gladexml_widget_set_color (xml, "green", COLOR_GREEN); help_dialog = glade_xml_get_widget (xml, "matcher_help"); gtk_window_set_transient_for(GTK_WINDOW(help_dialog), @@ -534,11 +539,6 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, G_CALLBACK(on_matcher_help_clicked), info); - /*Initialise the colors */ - gdk_color_parse(COLOR_RED, &info->color_back_red); - gdk_color_parse(COLOR_YELLOW, &info->color_back_yellow); - gdk_color_parse(COLOR_GREEN, &info->color_back_green); - if (heading) gtk_label_set_text (GTK_LABEL (heading_label), heading); -- 1.7.1
From a56a68d865fc0501510c285fee76cb066f1eea48 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Fri, 1 Jan 2010 06:59:04 -0500 Subject: [PATCH 3/7] Import dialog: Change imbalanced transaction colour from gold to yellow --- src/import-export/import-main-matcher.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 0eda05b..39d4cca 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -70,7 +70,7 @@ enum downloaded_cols }; #define COLOR_RED "brown1" -#define COLOR_YELLOW "gold" +#define COLOR_YELLOW "yellow" #define COLOR_GREEN "DarkSeaGreen1" static QofLogModule log_module = GNC_MOD_IMPORT; -- 1.7.1
From 99c3373c808130888c187589926c15641e573975 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Fri, 20 Feb 2009 22:49:38 -0500 Subject: [PATCH 4/7] Import dialog: Extend the "A" column checkbox behaviour This change makes it possible to rerun the automatching algorithm when the user manually sets a destination account, providing potentially better matches, without accidentally changing a match that the user has already verified to be correct. The "A" column checkboxes are extended such that when an "A" checkbox is clicked for a row marked with "(auto)", the row transaction is changed to "(manual)", without altering the destination account. When the checkbox is clicked for a row marked as "(manual)", in addition to disabling the checkbox (and the add action), the row is reset to "(auto)" if the destination account is the same as what would have been automatched. This allows the user to undo the transition from auto to manual without also accidentally resetting manually selected destination accounts. --- src/import-export/import-backend.c | 39 +++++++++++++++---------------- src/import-export/import-backend.h | 15 ++++++++++- src/import-export/import-main-matcher.c | 28 +++++++++++++++++++--- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/import-export/import-backend.c b/src/import-export/import-backend.c index e9e4ded..cbb1d6b 100644 --- a/src/import-export/import-backend.c +++ b/src/import-export/import-backend.c @@ -1115,40 +1115,39 @@ gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info, } -/* Try to automatch a transaction to a destination account if the */ -/* transaction hasn't already been manually assigned to another account */ +/* Try to automatch a transaction to a destination account. */ gboolean gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info, - GncImportMatchMap *matchmap) + GncImportMatchMap *matchmap, + gboolean reset_manual_destacc) { Account *orig_destacc; Account *new_destacc = NULL; g_assert(transaction_info); + if (gnc_import_TransInfo_get_destacc_selected_manually(transaction_info) + && !reset_manual_destacc) + return FALSE; + orig_destacc = gnc_import_TransInfo_get_destacc(transaction_info); + /* Try to find the destination account for this transaction based on prior ones */ + new_destacc = matchmap_find_destination(matchmap, transaction_info); - /* if we haven't manually selected a destination account for this transaction */ - if (gnc_import_TransInfo_get_destacc_selected_manually(transaction_info) == FALSE) + if(gnc_import_TransInfo_get_destacc_selected_manually(transaction_info)) { - /* Try to find the destination account for this transaction based on prior ones */ - new_destacc = matchmap_find_destination(matchmap, transaction_info); - gnc_import_TransInfo_set_destacc(transaction_info, new_destacc, FALSE); + /* Don't change the destacc if the user manually selected a different + destination that the automatched one. */ + if (new_destacc != orig_destacc) + return FALSE; } - else + else /* automatched */ { - new_destacc = orig_destacc; + if (new_destacc == orig_destacc) + return FALSE; } - /* account has changed */ - if (new_destacc != orig_destacc) - { - return TRUE; - } - else /* account is the same */ - { - return FALSE; - } + gnc_import_TransInfo_set_destacc(transaction_info, new_destacc, FALSE); + return TRUE; } - /** @} */ diff --git a/src/import-export/import-backend.h b/src/import-export/import-backend.h index a64e747..01e97b5 100644 --- a/src/import-export/import-backend.h +++ b/src/import-export/import-backend.h @@ -217,10 +217,21 @@ gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info, Account *acc, gboolean selected_manually); -/** Try to automatch a given transaction to a destination account */ +/** + * Try to automatch a given transaction to a destination account. + * + * @param reset_manual_destacc If false, manually set destination accounts are + * skipped. If true, and if the destination account is manually set to the same + * account that would be automatched, then it will be reset to an automatch. + * Manually set destinations that are different from the automatched + * destination are always skipped. + * + * @return TRUE if transaction_info was changed + */ gboolean gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info, - GncImportMatchMap *matchmap); + GncImportMatchMap *matchmap, + gboolean reset_manual_destacc); /** Returns if the currently selected destination account for auto-matching was selected by the user. */ gboolean diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 39d4cca..e22c526 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -269,10 +269,30 @@ gnc_gen_trans_add_toggled_cb (GtkCellRendererToggle *cell_renderer, return; gtk_tree_model_get(model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1); - if ( gnc_import_TransInfo_get_action(trans_info) == GNCImport_ADD - && gnc_import_Settings_get_action_skip_enabled (gui->user_settings) == TRUE) + if (gnc_import_TransInfo_get_action(trans_info) == GNCImport_ADD) { - gnc_import_TransInfo_set_action(trans_info, GNCImport_SKIP); + /* automatched transaction that the user wants to manually select */ + if ( !gnc_import_TransInfo_is_balanced(trans_info) + && gnc_import_TransInfo_get_destacc (trans_info) != NULL + && !gnc_import_TransInfo_get_destacc_selected_manually(trans_info)) + { + gnc_import_TransInfo_set_destacc( + trans_info, + gnc_import_TransInfo_get_destacc(trans_info), + TRUE + ); + automatch_store_transactions(gui, model, &iter, trans_info); + } + else + { + /* + Reset the destination account to automatically selected, if it + looks like it was change to manual by this function (see above). + */ + gnc_import_TransInfo_refresh_destacc(trans_info, NULL, TRUE); + if(gnc_import_Settings_get_action_skip_enabled (gui->user_settings)==TRUE) + gnc_import_TransInfo_set_action(trans_info, GNCImport_SKIP); + } } else { @@ -782,7 +802,7 @@ automatch_store_transactions (GNCImportMainMatcher *info, GNCImportTransInfo *trans_info) { /* returns TRUE if we changed this row, so update it */ - if (gnc_import_TransInfo_refresh_destacc(trans_info, NULL)) + if (gnc_import_TransInfo_refresh_destacc(trans_info, NULL, FALSE)) { refresh_model_row(info, model, iter, trans_info); } -- 1.7.1
From 8f34f00e329b9fb66d73b7f732a5129d4d473227 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Fri, 1 Jan 2010 07:29:31 -0500 Subject: [PATCH 5/7] Import dialog: Make automatic and unbalanced selections the same color This change renames the COLOR_* macros to reflect their meaning instead of what colors they are defined to. Automatched transactions are given the same color as imbalanced transactions, to encourage the user to verify each one. The transaction import help dialog is modified to document the new meaning, and explain how to quickly switch transactions from auto to manual. --- src/import-export/generic-import.glade | 16 ++++++++-------- src/import-export/import-main-matcher.c | 31 +++++++++++++++++++------------ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/import-export/generic-import.glade b/src/import-export/generic-import.glade index da62b50..c5fa78b 100644 --- a/src/import-export/generic-import.glade +++ b/src/import-export/generic-import.glade @@ -1017,7 +1017,7 @@ click "OK".</property> <property name="wrap_mode">word</property> <property name="cursor_visible">False</property> <property name="accepts_tab">False</property> - <property name="text" translatable="yes">This transaction will be imported balanced (you may still want to double check the match or destination account).</property> + <property name="text" translatable="yes">This transaction has been manually verified by you, and will be imported balanced.</property> </widget> </child> </widget> @@ -1071,7 +1071,7 @@ click "OK".</property> <property name="wrap_mode">word</property> <property name="cursor_visible">False</property> <property name="accepts_tab">False</property> - <property name="text" translatable="yes">This transaction probably requires your intervention or it will be imported unbalanced.</property> + <property name="text" translatable="yes">This transaction will be imported, but has not been verified by you. It is either unbalanced, or the current best guess for is selected as the destination. The guess may be revised as you edit transactions in this dialog unless you either explicitly select an account, or indicate that the current guess is correct by clicking on the checkbox under "A".</property> </widget> </child> </widget> @@ -1222,13 +1222,13 @@ click "OK".</property> </packing> </child> <child> - <widget class="GtkEventBox" id="red"> + <widget class="GtkEventBox" id="skip"> <property name="visible">True</property> <child> <widget class="GtkLabel" id="label847802"> <property name="visible">True</property> <property name="xpad">12</property> - <property name="label" translatable="yes">Red</property> + <property name="label" translatable="yes">Skip</property> </widget> </child> </widget> @@ -1240,13 +1240,13 @@ click "OK".</property> </packing> </child> <child> - <widget class="GtkEventBox" id="yellow"> + <widget class="GtkEventBox" id="auto"> <property name="visible">True</property> <child> <widget class="GtkLabel" id="label847803"> <property name="visible">True</property> <property name="xpad">12</property> - <property name="label" translatable="yes">Yellow</property> + <property name="label" translatable="yes">Auto</property> </widget> </child> </widget> @@ -1258,13 +1258,13 @@ click "OK".</property> </packing> </child> <child> - <widget class="GtkEventBox" id="green"> + <widget class="GtkEventBox" id="manual"> <property name="visible">True</property> <child> <widget class="GtkLabel" id="label847804"> <property name="visible">True</property> <property name="xpad">12</property> - <property name="label" translatable="yes">Green</property> + <property name="label" translatable="yes">Manual</property> </widget> </child> </widget> diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index e22c526..261722a 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -69,9 +69,15 @@ enum downloaded_cols NUM_DOWNLOADED_COLS }; -#define COLOR_RED "brown1" -#define COLOR_YELLOW "yellow" -#define COLOR_GREEN "DarkSeaGreen1" +#define COLOR_SKIP "brown1" +#define COLOR_AUTO "yellow" +#define COLOR_MANUAL "DarkSeaGreen1" +/* + Reconcile (auto) is still marked with the manual color, because it + will not change as automatch information is updated, unlike + GNCImport_ADD transactions. +*/ +#define COLOR_CLEAR "DarkSeaGreen1" static QofLogModule log_module = GNC_MOD_IMPORT; @@ -204,9 +210,9 @@ on_matcher_help_clicked (GtkButton *button, xml = gnc_glade_xml_new ("generic-import.glade", "matcher_help"); - gladexml_widget_set_color (xml, "red", COLOR_RED); - gladexml_widget_set_color (xml, "yellow", COLOR_YELLOW); - gladexml_widget_set_color (xml, "green", COLOR_GREEN); + gladexml_widget_set_color (xml, "skip", COLOR_SKIP); + gladexml_widget_set_color (xml, "auto", COLOR_AUTO); + gladexml_widget_set_color (xml, "manual", COLOR_MANUAL); help_dialog = glade_xml_get_widget (xml, "matcher_help"); gtk_window_set_transient_for(GTK_WINDOW(help_dialog), @@ -638,7 +644,7 @@ refresh_model_row (GNCImportMainMatcher *gui, if (gnc_import_TransInfo_is_balanced(info) == TRUE) { ro_text = _("New, already balanced"); - color = COLOR_GREEN; + color = COLOR_MANUAL; } else { @@ -654,12 +660,12 @@ refresh_model_row (GNCImportMainMatcher *gui, TRUE) )); if (gnc_import_TransInfo_get_destacc (info) != NULL) { - color = COLOR_GREEN; tmp = gnc_account_get_full_name (gnc_import_TransInfo_get_destacc (info)); if (gnc_import_TransInfo_get_destacc_selected_manually(info) == TRUE) { + color = COLOR_MANUAL; text = /* Translators: %1$s is the amount to be transferred. %2$s is the destination account. */ @@ -668,6 +674,7 @@ refresh_model_row (GNCImportMainMatcher *gui, } else { + color = COLOR_AUTO; text = /* Translators: %1$s is the amount to be transferred. %2$s is the destination account. */ @@ -679,7 +686,7 @@ refresh_model_row (GNCImportMainMatcher *gui, } else { - color = COLOR_YELLOW; + color = COLOR_AUTO; text = /* Translators: %s is the amount to be transferred. */ g_strdup_printf(_("New, UNBALANCED (need acct to transfer %s)!"), @@ -691,7 +698,7 @@ refresh_model_row (GNCImportMainMatcher *gui, case GNCImport_CLEAR: if (gnc_import_TransInfo_get_selected_match(info)) { - color = COLOR_GREEN; + color = COLOR_CLEAR; if (gnc_import_TransInfo_get_match_selected_manually(info) == TRUE) { ro_text = _("Reconcile (manual) match"); @@ -703,7 +710,7 @@ refresh_model_row (GNCImportMainMatcher *gui, } else { - color = COLOR_RED; + color = COLOR_SKIP; ro_text = _("Match missing!"); } break; @@ -712,7 +719,7 @@ refresh_model_row (GNCImportMainMatcher *gui, ro_text = "NOT SUPPORTED YET!"; break; case GNCImport_SKIP: - color = COLOR_RED; + color = COLOR_SKIP; ro_text = _("Do not import (no action selected)"); break; default: -- 1.7.1
From a11990d17b2f3558ccc98899f60c33a1a629f742 Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Sun, 15 Aug 2010 16:59:07 -0700 Subject: [PATCH 6/7] Import dialog: Show inconsistent "A" checkbox for automatched rows This change uses the inconsistent state for checkboxes in the add column of rows whose transactions are being added and have a destination account, but haven't been manually matched. This should hint to the user that they can click on the checkbox to mark the transaction's destination account as manually selected. --- src/import-export/import-main-matcher.c | 94 ++++++++++++++++++++++++++++--- 1 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 261722a..57691af 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -52,6 +52,53 @@ struct _main_matcher_info int selected_row; }; +/* + The following enum and function allow the inconsistent state of toggles to be represented in the data model. +*/ +typedef enum _toggle_state { + TOGGLE_STATE_INACTIVE = FALSE, + TOGGLE_STATE_INCONSISTENT, + TOGGLE_STATE_ACTIVE +} GNCToggleState; + +static void +toggle_state_data_func (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + int col_num = GPOINTER_TO_INT(data); + GNCToggleState state; + gboolean active, inconsistent; + active = FALSE; + inconsistent = FALSE; + + gtk_tree_model_get(tree_model, iter, + col_num, &state, + -1); + + switch (state) { + case TOGGLE_STATE_INACTIVE: + inconsistent = FALSE; + active = FALSE; + break; + case TOGGLE_STATE_INCONSISTENT: + inconsistent = TRUE; + active = TRUE; + break; + case TOGGLE_STATE_ACTIVE: + inconsistent = FALSE; + active = TRUE; + break; + } + + g_object_set(cell, + "active", active, + "inconsistent", inconsistent, + NULL); +} + enum downloaded_cols { DOWNLOADED_COL_DATE = 0, @@ -277,7 +324,8 @@ gnc_gen_trans_add_toggled_cb (GtkCellRendererToggle *cell_renderer, if (gnc_import_TransInfo_get_action(trans_info) == GNCImport_ADD) { - /* automatched transaction that the user wants to manually select */ + /* Automatched transaction that the user wants to manually select. This + should show up in the UI as a checkbox in the inconsistent state. */ if ( !gnc_import_TransInfo_is_balanced(trans_info) && gnc_import_TransInfo_get_destacc (trans_info) != NULL && !gnc_import_TransInfo_get_destacc_selected_manually(trans_info)) @@ -431,9 +479,14 @@ add_text_column(GtkTreeView *view, const gchar *title, int col_num) return column; } +/** + * \param func If NULL, then col_num points to a column that stores the column's + * "active" attribute. Otherwise, col_num contains the column that will be + * interpreted by func to set attributes on the GtkCellRenderer. + */ static GtkTreeViewColumn * -add_toggle_column(GtkTreeView *view, const gchar *title, int col_num, - GCallback cb_fn, gpointer cb_arg) +add_toggle_column_special_state(GtkTreeView *view, const gchar *title, int col_num, + GCallback cb_fn, gpointer cb_arg, GtkTreeCellDataFunc func) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; @@ -441,9 +494,14 @@ add_toggle_column(GtkTreeView *view, const gchar *title, int col_num, renderer = gtk_cell_renderer_toggle_new(); column = gtk_tree_view_column_new_with_attributes (title, renderer, - "active", col_num, "cell-background", DOWNLOADED_COL_COLOR, NULL); + + if (func != NULL) + gtk_tree_view_column_set_cell_data_func(column, renderer, func, GINT_TO_POINTER(col_num), NULL); + else + gtk_tree_view_column_add_attribute(column, renderer, "active", col_num); + gtk_tree_view_column_set_sort_column_id(column, col_num); g_object_set(G_OBJECT(column), "reorderable", TRUE, @@ -453,6 +511,13 @@ add_toggle_column(GtkTreeView *view, const gchar *title, int col_num, return column; } +static GtkTreeViewColumn * +add_toggle_column(GtkTreeView *view, const gchar *title, int col_num, + GCallback cb_fn, gpointer cb_arg) +{ + return add_toggle_column_special_state(view, title, col_num, cb_fn, cb_arg, NULL); +} + static void gnc_gen_trans_init_view (GNCImportMainMatcher *info, gboolean show_account, @@ -467,7 +532,7 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info, view = info->view; store = gtk_list_store_new(NUM_DOWNLOADED_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_STRING); gtk_tree_view_set_model(view, GTK_TREE_MODEL(store)); @@ -480,8 +545,14 @@ gnc_gen_trans_init_view (GNCImportMainMatcher *info, add_text_column(view, _("Amount"), DOWNLOADED_COL_AMOUNT); add_text_column(view, _("Description"), DOWNLOADED_COL_DESCRIPTION); add_text_column(view, _("Memo"), DOWNLOADED_COL_MEMO); - add_toggle_column(view, _("A"), DOWNLOADED_COL_ACTION_ADD, - G_CALLBACK(gnc_gen_trans_add_toggled_cb), info); + add_toggle_column_special_state( + view, + _("A"), + DOWNLOADED_COL_ACTION_ADD, + G_CALLBACK(gnc_gen_trans_add_toggled_cb), + info, + &toggle_state_data_func + ); add_toggle_column(view, _("R"), DOWNLOADED_COL_ACTION_CLEAR, G_CALLBACK(gnc_gen_trans_clear_toggled_cb), info); column = add_toggle_column(view, _("Edit"), DOWNLOADED_COL_ACTION_EDIT, @@ -599,6 +670,7 @@ refresh_model_row (GNCImportMainMatcher *gui, GtkTreeSelection *selection; gchar *tmp, *imbalance, *text, *color; const gchar *ro_text; + GNCToggleState column_add_state; g_assert (gui); g_assert (model); g_assert (info); @@ -638,6 +710,7 @@ refresh_model_row (GNCImportMainMatcher *gui, /* Action informations */ ro_text = text = color = NULL; + column_add_state = TOGGLE_STATE_INACTIVE; switch (gnc_import_TransInfo_get_action(info)) { case GNCImport_ADD: @@ -645,6 +718,7 @@ refresh_model_row (GNCImportMainMatcher *gui, { ro_text = _("New, already balanced"); color = COLOR_MANUAL; + column_add_state = TOGGLE_STATE_ACTIVE; } else { @@ -666,6 +740,7 @@ refresh_model_row (GNCImportMainMatcher *gui, == TRUE) { color = COLOR_MANUAL; + column_add_state = TOGGLE_STATE_ACTIVE; text = /* Translators: %1$s is the amount to be transferred. %2$s is the destination account. */ @@ -675,6 +750,7 @@ refresh_model_row (GNCImportMainMatcher *gui, else { color = COLOR_AUTO; + column_add_state = TOGGLE_STATE_INCONSISTENT; text = /* Translators: %1$s is the amount to be transferred. %2$s is the destination account. */ @@ -687,6 +763,7 @@ refresh_model_row (GNCImportMainMatcher *gui, else { color = COLOR_AUTO; + column_add_state = TOGGLE_STATE_ACTIVE; text = /* Translators: %s is the amount to be transferred. */ g_strdup_printf(_("New, UNBALANCED (need acct to transfer %s)!"), @@ -736,8 +813,9 @@ refresh_model_row (GNCImportMainMatcher *gui, gtk_list_store_set(store, iter, DOWNLOADED_COL_ACTION_ADD, - gnc_import_TransInfo_get_action(info) == GNCImport_ADD, + column_add_state, -1); + if (gnc_import_TransInfo_get_action(info) == GNCImport_SKIP) { /*Show the best match's confidence pixmap in the info column*/ -- 1.7.1
From 7088e736cf4e799e3edf6e6e3f76e2a349719f6c Mon Sep 17 00:00:00 2001 From: Simon Ruggier <simo...@gmail.com> Date: Sun, 8 Feb 2009 02:52:54 -0500 Subject: [PATCH 7/7] Repair automatch_store_transactions The automatch_store_transactions function seems to have been broken in the process of being ported from GtkCList to GtkTreeModel APIs. This change restores it to the intended behaviour of retrying an automatch for every row in the GtkTreeModel. The result is that when a user manually sets a destination account, all automatched destination accounts in the import dialog will be automatched again. This can potentially save a lot of manual selection, if the user is importing a lot of transactions of a new type in the same dialog. --- src/import-export/import-main-matcher.c | 36 +++++++++++++++++++------------ 1 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 57691af..961c6c2 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -131,9 +131,7 @@ static QofLogModule log_module = GNC_MOD_IMPORT; /* Local prototypes */ static void automatch_store_transactions(GNCImportMainMatcher *info, - GtkTreeModel *model, - GtkTreeIter *iter, - GNCImportTransInfo *trans_info); + GtkTreeModel *model); static void refresh_model_row(GNCImportMainMatcher *gui, GtkTreeModel *model, GtkTreeIter *iter, GNCImportTransInfo *info); @@ -297,7 +295,7 @@ run_account_picker_dialog (GNCImportMainMatcher *info, TRUE); /* Iterate through the transactions in a given clist to auto match them */ - automatch_store_transactions(info, model, iter, trans_info); + automatch_store_transactions(info, model); } } @@ -335,7 +333,7 @@ gnc_gen_trans_add_toggled_cb (GtkCellRendererToggle *cell_renderer, gnc_import_TransInfo_get_destacc(trans_info), TRUE ); - automatch_store_transactions(gui, model, &iter, trans_info); + automatch_store_transactions(gui, model); } else { @@ -879,18 +877,28 @@ void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans) return; }/* end gnc_import_add_trans() */ -/* Iterate through the rows of the clist and try to automatch each of them */ +/** + * Iterate through the rows of the GtkTreeView and try to automatch each of + * them. + */ static void automatch_store_transactions (GNCImportMainMatcher *info, - GtkTreeModel *model, - GtkTreeIter *iter, - GNCImportTransInfo *trans_info) + GtkTreeModel *model) { - /* returns TRUE if we changed this row, so update it */ - if (gnc_import_TransInfo_refresh_destacc(trans_info, NULL, FALSE)) - { - refresh_model_row(info, model, iter, trans_info); - } + GtkTreeIter iter; + GNCImportTransInfo *trans_info; + if (!gtk_tree_model_get_iter_first(model, &iter)) + return; + do { + gtk_tree_model_get(model, &iter, + DOWNLOADED_COL_DATA, &trans_info, + -1); + /* returns TRUE if we changed this row, so update it */ + if(gnc_import_TransInfo_refresh_destacc(trans_info, NULL, FALSE)) + { + refresh_model_row(info, model, &iter, trans_info); + } + } while(gtk_tree_model_iter_next(model, &iter)); } /** @} */ -- 1.7.1
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel