From fad17da72b7f90a185cbe1381e17c7b51a5e0052 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 11 Dec 2018 10:38:59 +0000 Subject: [PATCH 01/14] Bug 796887 - Remove account slot key color if there is no valid color If an existing account colour was specified and subsequently removed the color key would be "Not Set". Change this to remove the key when the colour is changed to default, i.e. removed. --- gnucash/gnome-utils/dialog-account.c | 64 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c index a23429e940..e3c075d5d2 100644 --- a/gnucash/gnome-utils/dialog-account.c +++ b/gnucash/gnome-utils/dialog-account.c @@ -230,12 +230,13 @@ gnc_account_to_ui(AccountWindow *aw) string = xaccAccountGetColor (account); - if ((string == NULL) || (g_strcmp0 ("Not Set", string) == 0)) + if (!string) string = DEFAULT_COLOR; - if (gdk_rgba_parse(&color, string)) - { - gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color); - } + + if (!gdk_rgba_parse (&color, string)) + gdk_rgba_parse (&color, DEFAULT_COLOR); + + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color); commodity = xaccAccountGetCommodity (account); gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit), @@ -380,12 +381,19 @@ gnc_ui_to_account(AccountWindow *aw) gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(aw->color_entry_button), &color ); string = gdk_rgba_to_string(&color); + if (g_strcmp0 (string, DEFAULT_COLOR) == 0) - string = "Not Set"; + string = NULL; old_string = xaccAccountGetColor (account); - if (g_strcmp0 (string, old_string) != 0) - xaccAccountSetColor (account, string); + + if (!string && old_string) + xaccAccountSetColor (account, ""); // remove entry + else + { + if (g_strcmp0 (string, old_string) != 0) + xaccAccountSetColor (account, string); // update entry + } commodity = (gnc_commodity *) gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit)); @@ -2094,16 +2102,24 @@ default_color_button_cb (GtkButton *button, gpointer user_data) static void update_account_color (Account *acc, const gchar *old_color, const gchar *new_color, gboolean replace) { - // check to see if the color has been changed - if (g_strcmp0 (new_color, old_color) != 0) + PINFO("Account is '%s', old_color is '%s', new_color is '%s', replace is %d", + xaccAccountGetName (acc), old_color, new_color, replace); + + // have a new color, update if we can + if (new_color) { - if ((old_color == NULL) || (g_strcmp0 (old_color, "Not Set") == 0) || (replace == TRUE)) + if (!old_color || replace) { - xaccAccountBeginEdit (acc); - xaccAccountSetColor (acc, new_color); - xaccAccountCommitEdit (acc); + // check to see if the color is different from old one + if (g_strcmp0 (new_color, old_color) != 0) + xaccAccountSetColor (acc, new_color); } } + else // change from a color to default one, remove color entry if we can + { + if (old_color && replace) + xaccAccountSetColor (acc, ""); // remove entry + } } void @@ -2114,7 +2130,7 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account) GtkWidget *color_label, *color_button, *over_write, *color_button_default; gchar *string; const char *color_string; - gchar *old_color_string; + gchar *old_color_string = NULL; GdkRGBA color; gint response; @@ -2144,14 +2160,16 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account) color_string = xaccAccountGetColor (account); // get existing account color - old_color_string = g_strdup (color_string); // save the old color string - - if ((color_string == NULL) || (g_strcmp0 (color_string, "Not Set") == 0)) + if (!color_string) color_string = DEFAULT_COLOR; + else + old_color_string = g_strdup (color_string); // save the old color string + + if (!gdk_rgba_parse (&color, color_string)) + gdk_rgba_parse (&color, DEFAULT_COLOR); // set the color chooser to account color - if (gdk_rgba_parse (&color, color_string)) - gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(color_button), &color); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(color_button), &color); /* default to cancel */ gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); @@ -2175,18 +2193,18 @@ gnc_account_cascade_color_dialog (GtkWidget *window, Account *account) new_color_string = gdk_rgba_to_string (&new_color); if (g_strcmp0 (new_color_string, DEFAULT_COLOR) == 0) - new_color_string = "Not Set"; + new_color_string = NULL; // check/update selected account update_account_color (account, old_color_string, new_color_string, replace); - if (accounts != NULL) + if (accounts) { for (acct = accounts; acct; acct = g_list_next(acct)) { const char *string = xaccAccountGetColor (acct->data); - // check/update sub-account + // check/update sub-accounts update_account_color (acct->data, string, new_color_string, replace); } g_list_free (accounts); From 7a1f981b0c180ec678870d1c26126393a81661bf Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 11 Dec 2018 10:45:14 +0000 Subject: [PATCH 02/14] Change the sensitivity of the Cascade colour menu option Enable the cascade colour menu setting only when the account being cascaded from has sub-accounts. --- gnucash/gnome/gnc-plugin-page-account-tree.c | 5 ++++- gnucash/ui/gnc-plugin-page-account-tree-ui.xml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 529c4a5442..41a28cc9ef 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -228,7 +228,7 @@ static GtkActionEntry gnc_plugin_page_account_tree_actions [] = G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account) }, { - "ColorCascadeAccountAction", NULL, N_("_Cascade Account Color..."), NULL, + "EditColorCascadeAccountAction", NULL, N_("_Cascade Account Color..."), NULL, N_("Cascade selected account color"), G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_color_account) }, @@ -1072,6 +1072,9 @@ gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, g_object_set (G_OBJECT(action), "sensitive", is_readwrite && sensitive && subaccounts, NULL); + action = gtk_action_group_get_action (action_group, "EditColorCascadeAccountAction"); + g_object_set (G_OBJECT(action), "sensitive", subaccounts, NULL); + gnc_plugin_update_actions (action_group, actions_requiring_account_rw, "sensitive", is_readwrite && sensitive); gnc_plugin_update_actions (action_group, actions_requiring_account_always, diff --git a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml index c07f440531..2584cceed8 100644 --- a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml +++ b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml @@ -5,7 +5,7 @@ - + @@ -46,7 +46,7 @@ - + From 43beeca079725d1193d06feb686724b61d2fc76e Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 11 Dec 2018 10:47:15 +0000 Subject: [PATCH 03/14] Change the way colours are imported by the CSV account tree importer When importing the account tree CSV file, change the importing of colours so that only valid colours for accounts are updated, invalid colours will result in the account color key slot being removed. --- gnucash/import-export/csv-imp/csv-account-import.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gnucash/import-export/csv-imp/csv-account-import.c b/gnucash/import-export/csv-imp/csv-account-import.c index e0affa39ad..804f11928a 100644 --- a/gnucash/import-export/csv-imp/csv-account-import.c +++ b/gnucash/import-export/csv-imp/csv-account-import.c @@ -283,6 +283,8 @@ csv_account_import (CsvImportInfo *info) { if (gdk_rgba_parse (&testcolor, color)) xaccAccountSetColor (acc, color); + else + xaccAccountSetColor (acc, ""); } if (g_strcmp0 (hidden, "T") == 0) @@ -323,6 +325,8 @@ csv_account_import (CsvImportInfo *info) { if (gdk_rgba_parse (&testcolor, color)) xaccAccountSetColor (acc, color); + else + xaccAccountSetColor (acc, ""); } if (g_strcmp0 (notes, "") != 0) From 5c524c31b2c953087b70305c24547960e0d5e585 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 22 Dec 2018 18:07:55 +0000 Subject: [PATCH 04/14] Add routine to fix Account Color being set to "Not Set" Previously the account color slot has been populated with "Not Set" when any field for the account has been edited and saved. This routine should run once and remove all such entries. --- gnucash/gnome-utils/gnc-file.c | 7 ++++++ libgnucash/engine/Scrub.c | 46 ++++++++++++++++++++++++++++++---- libgnucash/engine/Scrub.h | 5 ++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/gnucash/gnome-utils/gnc-file.c b/gnucash/gnome-utils/gnc-file.c index 2eefc34a69..0f8e0e4bd3 100644 --- a/gnucash/gnome-utils/gnc-file.c +++ b/gnucash/gnome-utils/gnc-file.c @@ -45,6 +45,7 @@ #include "gnc-window.h" #include "gnc-plugin-file-history.h" #include "qof.h" +#include "Scrub.h" #include "TransLog.h" #include "gnc-session.h" #include "gnc-state.h" @@ -1023,6 +1024,12 @@ RESTART: gnc_warning_dialog(parent, "%s", message); g_free ( message ); } + + // Fix account color slots being set to 'Not Set', should run once on a book + qof_event_suspend(); + xaccAccountScrubColorNotSet (gnc_get_current_book()); + qof_event_resume(); + return TRUE; } diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c index d6ff1075ff..38aa240569 100644 --- a/libgnucash/engine/Scrub.c +++ b/libgnucash/engine/Scrub.c @@ -1114,15 +1114,15 @@ xaccTransScrubCurrency (Transaction *trans) } else { - gnc_commodity *currency = xaccAccountGetCommodity(split->acc); + gnc_commodity *currency = xaccAccountGetCommodity(split->acc); PWARN ("setting to split=\"%s\" account=\"%s\" commodity=\"%s\"", split->memo, xaccAccountGetName(split->acc), gnc_commodity_get_mnemonic(currency)); - xaccTransBeginEdit (trans); - xaccTransSetCurrency (trans, currency); - xaccTransCommitEdit (trans); - return; + xaccTransBeginEdit (trans); + xaccTransSetCurrency (trans, currency); + xaccTransCommitEdit (trans); + return; } } } @@ -1354,6 +1354,42 @@ xaccAccountScrubKvp (Account *account) /* ================================================================ */ +void +xaccAccountScrubColorNotSet (QofBook *book) +{ + GValue value_s = G_VALUE_INIT; + + // get the run-once value + qof_instance_get_kvp (QOF_INSTANCE (book), &value_s, 1, "remove-color-not-set-slots"); + + if (G_VALUE_HOLDS_STRING (&value_s) && (strcmp(g_value_get_string (&value_s), "true") == 0)) + return; + else + { + GValue value_b = G_VALUE_INIT; + Account *root = gnc_book_get_root_account (book); + GList *accts = gnc_account_get_descendants_sorted (root); + GList *ptr; + + for (ptr = accts; ptr; ptr = g_list_next (ptr)) + { + const gchar *color = xaccAccountGetColor (ptr->data); + + if (g_strcmp0 (color, "Not Set") == 0) + xaccAccountSetColor (ptr->data, ""); + } + g_list_free (accts); + + g_value_init (&value_b, G_TYPE_BOOLEAN); + g_value_set_boolean (&value_b, TRUE); + + // set the run-once value + qof_instance_set_kvp (QOF_INSTANCE (book), &value_b, 1, "remove-color-not-set-slots"); + } +} + +/* ================================================================ */ + Account * xaccScrubUtilityGetOrMakeAccount (Account *root, gnc_commodity * currency, const char *accname, GNCAccountType acctype, diff --git a/libgnucash/engine/Scrub.h b/libgnucash/engine/Scrub.h index d57fadf1d7..9536f8c34b 100644 --- a/libgnucash/engine/Scrub.h +++ b/libgnucash/engine/Scrub.h @@ -145,6 +145,11 @@ void xaccAccountTreeScrubQuoteSources (Account *root, gnc_commodity_table *table /** Removes empty "notes", "placeholder", and "hbci" KVP slots from Accounts. */ void xaccAccountScrubKvp (Account *account); +/** Remove color slots that have a "Not Set" value, since 2.4.0, fixed in 3.4 + * This should only be run once on a book + */ +void xaccAccountScrubColorNotSet (QofBook *book); + /** Changes Transaction date_posted timestamps from 00:00 local to 11:00 UTC. * 11:00 UTC is the same day local time in almost all timezones, the exceptions * being the -12, +13, and +14 timezones along the International Date Line. If From a8d0270e5adf87093b843d84beac5c04103e3fdf Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 11 Dec 2018 12:57:30 +0000 Subject: [PATCH 05/14] Disallow tabs in GtkTextView in glade files Disallow the use of tabs in all glade GtkTextView's. This is mainly used for notes fields and showing log entries. Some views were not editable but for consistency the setting was also added to them. --- gnucash/gtkbuilder/assistant-csv-account-import.glade | 1 + gnucash/gtkbuilder/dialog-customer.glade | 1 + gnucash/gtkbuilder/dialog-invoice.glade | 2 ++ gnucash/gtkbuilder/dialog-lot-viewer.glade | 1 + gnucash/gtkbuilder/dialog-order.glade | 2 ++ gnucash/gtkbuilder/dialog-tax-info.glade | 1 + gnucash/gtkbuilder/dialog-totd.glade | 1 + gnucash/gtkbuilder/dialog-vendor.glade | 1 + gnucash/gtkbuilder/gnc-plugin-page-budget.glade | 1 + gnucash/import-export/aqb/dialog-ab.glade | 1 + 10 files changed, 12 insertions(+) diff --git a/gnucash/gtkbuilder/assistant-csv-account-import.glade b/gnucash/gtkbuilder/assistant-csv-account-import.glade index 4d2a5bd548..17aa12fb87 100644 --- a/gnucash/gtkbuilder/assistant-csv-account-import.glade +++ b/gnucash/gtkbuilder/assistant-csv-account-import.glade @@ -329,6 +329,7 @@ Cancel to abort. False 2 2 + False diff --git a/gnucash/gtkbuilder/dialog-customer.glade b/gnucash/gtkbuilder/dialog-customer.glade index 39be9776c3..382da5e439 100644 --- a/gnucash/gtkbuilder/dialog-customer.glade +++ b/gnucash/gtkbuilder/dialog-customer.glade @@ -541,6 +541,7 @@ True True word + False diff --git a/gnucash/gtkbuilder/dialog-invoice.glade b/gnucash/gtkbuilder/dialog-invoice.glade index d06ffc1555..602dacc088 100644 --- a/gnucash/gtkbuilder/dialog-invoice.glade +++ b/gnucash/gtkbuilder/dialog-invoice.glade @@ -475,6 +475,7 @@ True True word + False @@ -1247,6 +1248,7 @@ True True word + False diff --git a/gnucash/gtkbuilder/dialog-lot-viewer.glade b/gnucash/gtkbuilder/dialog-lot-viewer.glade index c8c1062f90..556fccc72b 100644 --- a/gnucash/gtkbuilder/dialog-lot-viewer.glade +++ b/gnucash/gtkbuilder/dialog-lot-viewer.glade @@ -169,6 +169,7 @@ True True Enter any notes you want to make about this lot. + False word diff --git a/gnucash/gtkbuilder/dialog-order.glade b/gnucash/gtkbuilder/dialog-order.glade index f1f584d2e7..e9707a0f98 100644 --- a/gnucash/gtkbuilder/dialog-order.glade +++ b/gnucash/gtkbuilder/dialog-order.glade @@ -446,6 +446,7 @@ True True word + False notes_buffer @@ -847,6 +848,7 @@ True False word + False text_buffer diff --git a/gnucash/gtkbuilder/dialog-tax-info.glade b/gnucash/gtkbuilder/dialog-tax-info.glade index b3f85b8818..c9774ab739 100644 --- a/gnucash/gtkbuilder/dialog-tax-info.glade +++ b/gnucash/gtkbuilder/dialog-tax-info.glade @@ -604,6 +604,7 @@ True False word + False diff --git a/gnucash/gtkbuilder/dialog-totd.glade b/gnucash/gtkbuilder/dialog-totd.glade index 2206248386..17896d66e0 100644 --- a/gnucash/gtkbuilder/dialog-totd.glade +++ b/gnucash/gtkbuilder/dialog-totd.glade @@ -125,6 +125,7 @@ 6 False word + False 5 5 False diff --git a/gnucash/gtkbuilder/dialog-vendor.glade b/gnucash/gtkbuilder/dialog-vendor.glade index 15643d346f..56050ba048 100644 --- a/gnucash/gtkbuilder/dialog-vendor.glade +++ b/gnucash/gtkbuilder/dialog-vendor.glade @@ -536,6 +536,7 @@ True True word + False diff --git a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade index aa2b171a7a..1a313c302a 100644 --- a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade +++ b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade @@ -291,6 +291,7 @@ True True word + False diff --git a/gnucash/import-export/aqb/dialog-ab.glade b/gnucash/import-export/aqb/dialog-ab.glade index b17e235e6d..a6a4dbfea3 100644 --- a/gnucash/import-export/aqb/dialog-ab.glade +++ b/gnucash/import-export/aqb/dialog-ab.glade @@ -242,6 +242,7 @@ True False word + False From 952761afa61fade522e1b9dc04aae0c34634ad0b Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:11:33 +0000 Subject: [PATCH 06/14] Bug 796945 - Search Search Criteria window does not scroll when added criteria exceed a certain amount Add the criteria grid to a viewport and scroll window as suggested in bug report. Also needed to add the hiding of the new scroll window as required. --- gnucash/gnome-search/dialog-search.c | 20 +++---- gnucash/gtkbuilder/dialog-search.glade | 82 +++++++++++++++----------- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/gnucash/gnome-search/dialog-search.c b/gnucash/gnome-search/dialog-search.c index 7db05bbe70..aa4c70398d 100644 --- a/gnucash/gnome-search/dialog-search.c +++ b/gnucash/gnome-search/dialog-search.c @@ -73,6 +73,7 @@ struct _GNCSearchWindow GtkWidget *grouping_combo; GtkWidget *match_all_label; GtkWidget *criteria_table; + GtkWidget *criteria_scroll_window; GtkWidget *result_hbox; /* The "results" sub-window widgets */ @@ -548,6 +549,7 @@ static void gnc_search_dialog_reset_widgets (GNCSearchWindow *sw) { gboolean sens = (sw->q != NULL); + gboolean crit_list_vis = FALSE; gtk_widget_set_sensitive(GTK_WIDGET(sw->narrow_rb), sens); gtk_widget_set_sensitive(GTK_WIDGET(sw->add_rb), sens); @@ -560,17 +562,12 @@ gnc_search_dialog_reset_widgets (GNCSearchWindow *sw) } if (sw->crit_list) - { - gtk_widget_set_sensitive(sw->grouping_combo, TRUE); - gtk_widget_hide(sw->match_all_label); - } - else - { - gtk_widget_set_sensitive(sw->grouping_combo, FALSE); - gtk_widget_show(sw->match_all_label); - } -} + crit_list_vis = TRUE; + gtk_widget_set_sensitive(sw->grouping_combo, crit_list_vis); + gtk_widget_set_visible (sw->criteria_scroll_window, crit_list_vis); + gtk_widget_set_visible (sw->match_all_label, !crit_list_vis); +} static gboolean gnc_search_dialog_crit_ok (GNCSearchWindow *sw) @@ -691,6 +688,7 @@ remove_element (GtkWidget *button, GNCSearchWindow *sw) { gtk_widget_set_sensitive(sw->grouping_combo, FALSE); gtk_widget_show(sw->match_all_label); + gtk_widget_hide(sw->criteria_scroll_window); } } @@ -986,6 +984,7 @@ gnc_search_dialog_add_criterion (GNCSearchWindow *sw) /* no match-all situation anymore */ gtk_widget_set_sensitive(sw->grouping_combo, TRUE); gtk_widget_hide(sw->match_all_label); + gtk_widget_show(sw->criteria_scroll_window); } /* create a new criterion element */ new_sct = gnc_search_core_type_new_type_name @@ -1154,6 +1153,7 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw, const gchar *title) /* Grab the search-table widget */ sw->criteria_table = GTK_WIDGET(gtk_builder_get_object (builder, "criteria_table")); + sw->criteria_scroll_window = GTK_WIDGET(gtk_builder_get_object (builder, "criteria_scroll_window")); /* Set the type label */ label = GTK_WIDGET(gtk_builder_get_object (builder, "type_label")); diff --git a/gnucash/gtkbuilder/dialog-search.glade b/gnucash/gtkbuilder/dialog-search.glade index 64fd788780..400e8e1d12 100644 --- a/gnucash/gtkbuilder/dialog-search.glade +++ b/gnucash/gtkbuilder/dialog-search.glade @@ -1,5 +1,5 @@ - + @@ -235,36 +235,51 @@ - + True - False - 3 - - - - - - - - - - - - - - - - - - + True + never + etched-in - - - - - - - + + True + False + etched-in + + + True + False + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -284,8 +299,8 @@ - False - False + True + True 1 @@ -298,6 +313,7 @@ True False + start True @@ -441,8 +457,8 @@ - True - True + False + False 2 From bd0e532415f87a6f93a96df221e57ef6547aee1f Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:14:12 +0000 Subject: [PATCH 07/14] Remove some white space and tabs in dialog-search.c --- gnucash/gnome-search/dialog-search.c | 63 +++++++--------------------- 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/gnucash/gnome-search/dialog-search.c b/gnucash/gnome-search/dialog-search.c index aa4c70398d..a77099dfea 100644 --- a/gnucash/gnome-search/dialog-search.c +++ b/gnucash/gnome-search/dialog-search.c @@ -40,7 +40,7 @@ #include "engine-helpers.h" #include "qofbookslots.h" -#include "Transaction.h" /* for the SPLIT_* and TRANS_* */ +#include "Transaction.h" /* for the SPLIT_* and TRANS_* */ #include "dialog-search.h" #include "search-core-type.h" @@ -166,7 +166,6 @@ gnc_search_callback_button_execute (GNCSearchCallbackButton *cb, } } - static void gnc_search_dialog_result_clicked (GtkButton *button, GNCSearchWindow *sw) { @@ -176,7 +175,6 @@ gnc_search_dialog_result_clicked (GtkButton *button, GNCSearchWindow *sw) gnc_search_callback_button_execute (cb, sw); } - static void gnc_search_dialog_select_buttons_enable (GNCSearchWindow *sw, gint selected) { @@ -219,7 +217,6 @@ gnc_search_dialog_select_buttons_enable (GNCSearchWindow *sw, gint selected) } } - static void gnc_search_dialog_select_cb (GtkButton *button, GNCSearchWindow *sw) { @@ -238,7 +235,6 @@ gnc_search_dialog_select_cb (GtkButton *button, GNCSearchWindow *sw) gnc_search_dialog_destroy (sw); } - static void gnc_search_dialog_select_row_cb (GNCQueryView *qview, gpointer item, @@ -249,7 +245,6 @@ gnc_search_dialog_select_row_cb (GNCQueryView *qview, gnc_search_dialog_select_buttons_enable(sw, number_of_rows); } - static void gnc_search_dialog_double_click_cb (GNCQueryView *qview, gpointer item, @@ -267,7 +262,6 @@ gnc_search_dialog_double_click_cb (GNCQueryView *qview, /* If we get here, then nothing to do for a double-click */ } - static void gnc_search_dialog_init_result_view (GNCSearchWindow *sw) { @@ -290,7 +284,6 @@ gnc_search_dialog_init_result_view (GNCSearchWindow *sw) G_CALLBACK(gnc_search_dialog_double_click_cb), sw); } - static void gnc_search_dialog_display_results (GNCSearchWindow *sw) { @@ -376,14 +369,12 @@ gnc_search_dialog_display_results (GNCSearchWindow *sw) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sw->new_rb), TRUE); } - static void match_combo_changed (GtkComboBoxText *combo_box, GNCSearchWindow *sw) { sw->grouping = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box)); } - static void search_type_cb (GtkToggleButton *button, GNCSearchWindow *sw) { @@ -396,7 +387,6 @@ search_type_cb (GtkToggleButton *button, GNCSearchWindow *sw) } } - static void search_active_only_cb (GtkToggleButton *button, GNCSearchWindow *sw) { @@ -410,24 +400,24 @@ create_query_fragment (QofIdTypeConst search_for, GNCSearchParam *param, QofQuer { GNCSearchParamKind kind = gnc_search_param_get_kind (param); QofQuery *q = qof_query_create_for (search_for); - + if (kind == SEARCH_PARAM_ELEM) { /* The "op" parameter below will be ignored since q has no terms. */ qof_query_add_term (q, gnc_search_param_get_param_path (GNC_SEARCH_PARAM_SIMPLE (param)), pdata, QOF_QUERY_OR); - } + } else { GList *plist = gnc_search_param_get_search (GNC_SEARCH_PARAM_COMPOUND (param)); - + for ( ; plist; plist = plist->next) { QofQuery *new_q; GNCSearchParam *param2 = plist->data; - QofQuery *q2 = create_query_fragment (search_for, param2, + QofQuery *q2 = create_query_fragment (search_for, param2, qof_query_core_predicate_copy (pdata)); - new_q = qof_query_merge (q, q2, kind == SEARCH_PARAM_ANY ? + new_q = qof_query_merge (q, q2, kind == SEARCH_PARAM_ANY ? QOF_QUERY_OR : QOF_QUERY_AND); qof_query_destroy (q); qof_query_destroy (q2); @@ -490,19 +480,19 @@ search_update_query (GNCSearchWindow *sw) switch (sw->search_type) { - case 0: /* New */ + case 0: /* New */ new_q = qof_query_merge (sw->start_q, q, QOF_QUERY_AND); qof_query_destroy (q); break; - case 1: /* Refine */ + case 1: /* Refine */ new_q = qof_query_merge (sw->q, q, QOF_QUERY_AND); qof_query_destroy (q); break; - case 2: /* Add */ + case 2: /* Add */ new_q = qof_query_merge (sw->q, q, QOF_QUERY_OR); qof_query_destroy (q); break; - case 3: /* Delete */ + case 3: /* Delete */ q2 = qof_query_invert (q); new_q = qof_query_merge (sw->q, q2, QOF_QUERY_AND); qof_query_destroy (q2); @@ -528,7 +518,6 @@ search_update_query (GNCSearchWindow *sw) sw->q = new_q; } - static void gnc_search_dialog_show_close_cancel (GNCSearchWindow *sw) { @@ -544,7 +533,6 @@ gnc_search_dialog_show_close_cancel (GNCSearchWindow *sw) } } - static void gnc_search_dialog_reset_widgets (GNCSearchWindow *sw) { @@ -589,7 +577,6 @@ gnc_search_dialog_crit_ok (GNCSearchWindow *sw) return ret; } - static void search_find_cb (GtkButton *button, GNCSearchWindow *sw) { @@ -614,7 +601,6 @@ search_find_cb (GtkButton *button, GNCSearchWindow *sw) gnc_search_dialog_display_results (sw); } - static void search_new_item_cb (GtkButton *button, GNCSearchWindow *sw) { @@ -648,7 +634,6 @@ search_new_item_cb (GtkButton *button, GNCSearchWindow *sw) } } - static void search_cancel_cb (GtkButton *button, GNCSearchWindow *sw) { @@ -656,14 +641,12 @@ search_cancel_cb (GtkButton *button, GNCSearchWindow *sw) gnc_search_dialog_destroy (sw); } - static void search_help_cb (GtkButton *button, GNCSearchWindow *sw) { gnc_gnome_help (HF_HELP, HL_FIND_TRANSACTIONS); } - static void remove_element (GtkWidget *button, GNCSearchWindow *sw) { @@ -692,7 +675,6 @@ remove_element (GtkWidget *button, GNCSearchWindow *sw) } } - static void attach_element (GtkWidget *element, GNCSearchWindow *sw, int row) { @@ -718,10 +700,9 @@ attach_element (GtkWidget *element, GNCSearchWindow *sw, int row) g_object_set (remove, "margin", 0, NULL); gtk_widget_show (remove); - data->button = remove; /* Save the button for later */ + data->button = remove; /* Save the button for later */ } - static void combo_box_changed (GtkComboBox *combo_box, struct _crit_data *data) { @@ -774,7 +755,6 @@ combo_box_changed (GtkComboBox *combo_box, struct _crit_data *data) gnc_search_core_type_editable_enters (newelem); } - static void search_clear_criteria (GNCSearchWindow *sw) { @@ -790,7 +770,6 @@ search_clear_criteria (GNCSearchWindow *sw) } } - static GtkWidget * get_comb_box_widget (GNCSearchWindow *sw, struct _crit_data *data) { @@ -1009,14 +988,12 @@ gnc_search_dialog_add_criterion (GNCSearchWindow *sw) } } - static void add_criterion (GtkWidget *button, GNCSearchWindow *sw) { gnc_search_dialog_add_criterion (sw); } - static int gnc_search_dialog_close_cb (GtkDialog *dialog, GNCSearchWindow *sw) { @@ -1049,7 +1026,6 @@ gnc_search_dialog_close_cb (GtkDialog *dialog, GNCSearchWindow *sw) return FALSE; } - static void refresh_handler (GHashTable *changes, gpointer data) { @@ -1062,7 +1038,6 @@ refresh_handler (GHashTable *changes, gpointer data) gnc_search_dialog_display_results (sw); } - static void close_handler (gpointer data) { @@ -1073,7 +1048,6 @@ close_handler (gpointer data) /* DRH: should sw be freed here? */ } - static const gchar * type_label_to_new_button(const gchar* type_label) { @@ -1125,7 +1099,6 @@ type_label_to_new_button(const gchar* type_label) } } - static void gnc_search_dialog_init_widgets (GNCSearchWindow *sw, const gchar *title) { @@ -1272,7 +1245,6 @@ gnc_search_dialog_init_widgets (GNCSearchWindow *sw, const gchar *title) g_object_unref(G_OBJECT(builder)); } - void gnc_search_dialog_destroy (GNCSearchWindow *sw) { @@ -1282,7 +1254,6 @@ gnc_search_dialog_destroy (GNCSearchWindow *sw) gnc_close_gui_component (sw->component_id); } - void gnc_search_dialog_raise (GNCSearchWindow *sw) { @@ -1356,7 +1327,6 @@ gnc_search_dialog_create (GtkWindow *parent, return sw; } - /* Register an on-close signal with the Search Dialog */ guint gnc_search_dialog_connect_on_close (GNCSearchWindow *sw, GCallback func, @@ -1371,7 +1341,6 @@ guint gnc_search_dialog_connect_on_close (GNCSearchWindow *sw, } - /* Un-register the signal handlers with the Search Dialog */ void gnc_search_dialog_disconnect (GNCSearchWindow *sw, gpointer user_data) { @@ -1382,7 +1351,6 @@ void gnc_search_dialog_disconnect (GNCSearchWindow *sw, gpointer user_data) 0, 0, NULL, NULL, user_data); } - /* Clear all callbacks with this Search Window */ void gnc_search_dialog_set_select_cb (GNCSearchWindow *sw, GNCSearchSelectedCB selected_cb, @@ -1441,7 +1409,6 @@ get_params_list (QofIdTypeConst type) return list; } - static GList * get_display_list (QofIdTypeConst type) { @@ -1463,7 +1430,6 @@ do_nothing (GtkWindow *dialog, gpointer *a, gpointer b) return; } - void gnc_search_dialog_test (void) { @@ -1490,8 +1456,7 @@ gnc_search_dialog_test (void) /* (keep the line break below to avoid a translator comment) */ gnc_search_dialog_create (NULL, GNC_ID_SPLIT, _("Find Transaction"), - params, display, - NULL, NULL, buttons, NULL, NULL, NULL, NULL, - NULL, NULL, NULL); + params, display, + NULL, NULL, buttons, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); } - From 82d0fa187bc25e66b2f4b7d2e8c741cc40c4d021 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:20:00 +0000 Subject: [PATCH 08/14] Add some space to the budget options Add some space to the budget options on the left so they are not right next to the border. Also add a note to specify where the visibility of accounts is found. --- .../gtkbuilder/gnc-plugin-page-budget.glade | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade index 1a313c302a..da3c11e75d 100644 --- a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade +++ b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade @@ -1,5 +1,5 @@ - + @@ -245,6 +245,7 @@ True False start + 5 Budget Name: @@ -271,6 +272,7 @@ False start start + 5 Notes: @@ -318,6 +320,7 @@ True False start + 5 Number of Periods: @@ -346,6 +349,7 @@ True False start + 5 Budget Period: @@ -384,6 +388,18 @@ 0 + + + True + False + Note: Use View->'Filter By...' to control visible accounts. + + + False + True + 2 + + From c47e6aefe30991e5fd7447e4cf2cf47208974a97 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:23:04 +0000 Subject: [PATCH 09/14] Add a couple of defines for the tree view grid lines --- gnucash/gnome-utils/dialog-utils.c | 4 ++-- gnucash/gnome-utils/dialog-utils.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome-utils/dialog-utils.c b/gnucash/gnome-utils/dialog-utils.c index d4de3961fa..caf2b26aaf 100644 --- a/gnucash/gnome-utils/dialog-utils.c +++ b/gnucash/gnome-utils/dialog-utils.c @@ -337,8 +337,8 @@ GtkTreeViewGridLines gnc_tree_view_get_grid_lines_pref (void) { GtkTreeViewGridLines grid_lines; - gboolean h_lines = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, "grid-lines-horizontal"); - gboolean v_lines = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, "grid-lines-vertical"); + gboolean h_lines = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_HORIZONTAL); + gboolean v_lines = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_VERTICAL); if (h_lines) { diff --git a/gnucash/gnome-utils/dialog-utils.h b/gnucash/gnome-utils/dialog-utils.h index 1a93f79634..908b7e6aae 100644 --- a/gnucash/gnome-utils/dialog-utils.h +++ b/gnucash/gnome-utils/dialog-utils.h @@ -29,6 +29,9 @@ #include #include "qof.h" +#define GNC_PREF_GRID_LINES_HORIZONTAL "grid-lines-horizontal" +#define GNC_PREF_GRID_LINES_VERTICAL "grid-lines-vertical" + void gnc_set_label_color (GtkWidget *label, gnc_numeric value); /********************************************************************\ From 0ac2aa802138518d43c83f17e91c7f5477d5fae8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:23:51 +0000 Subject: [PATCH 10/14] Enable the GncTreeView to track the grid line preferences With these changes when the preferences for showing horizontal or vertical grid lines are changed it will update the GncTreeView immediately. --- gnucash/gnome-utils/gnc-tree-view.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnucash/gnome-utils/gnc-tree-view.c b/gnucash/gnome-utils/gnc-tree-view.c index cd93a18330..de8a0f66fa 100644 --- a/gnucash/gnome-utils/gnc-tree-view.c +++ b/gnucash/gnome-utils/gnc-tree-view.c @@ -44,6 +44,7 @@ #include "gnc-gobject-utils.h" #include "gnc-cell-renderer-date.h" #include "gnc-state.h" +#include "gnc-prefs.h" #include "dialog-utils.h" /* The actual state key for a particular column visibility. This is @@ -223,6 +224,13 @@ gnc_tree_view_class_init (GncTreeViewClass *klass) gtkwidget_class->destroy = gnc_tree_view_destroy; } +static void +gnc_tree_view_update_grid_lines (gpointer prefs, gchar* pref, gpointer user_data) +{ + GncTreeView *view = user_data; + gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ()); +} + /** Initialize a new instance of a base gnucash tree view. This * function allocates and initializes the object private storage * space. It also adds the new object to a list (for memory tracking @@ -274,6 +282,10 @@ gnc_tree_view_init (GncTreeView *view, GncTreeViewClass *klass) // Set grid lines option to preference gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ()); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_HORIZONTAL, + gnc_tree_view_update_grid_lines, view); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_VERTICAL, + gnc_tree_view_update_grid_lines, view); /* Create the last column which contains the column selection * widget. gnc_tree_view_add_text_column will do most of the @@ -348,6 +360,11 @@ gnc_tree_view_destroy (GtkWidget *widget) view = GNC_TREE_VIEW (widget); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_HORIZONTAL, + gnc_tree_view_update_grid_lines, view); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_VERTICAL, + gnc_tree_view_update_grid_lines, view); + priv = GNC_TREE_VIEW_GET_PRIVATE(view); if (priv->state_section) From ca57ff50438967c89289631cd84c40a14ad74785 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 13 Dec 2018 13:28:25 +0000 Subject: [PATCH 11/14] Make the grid lines of totals Budget tree view track the preferences Make the grid lines of the totals tree view track the preferences to match the account tree view above it. --- gnucash/gnome/gnc-budget-view.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c index 5aed86e7de..0b36e96c16 100644 --- a/gnucash/gnome/gnc-budget-view.c +++ b/gnucash/gnome/gnc-budget-view.c @@ -54,6 +54,7 @@ #include "gnc-gobject-utils.h" #include "gnc-gtk-utils.h" #include "gnc-icons.h" +#include "gnc-prefs.h" #include "gnc-session.h" #include "gnc-tree-view-account.h" @@ -215,7 +216,6 @@ gnc_budget_view_class_init(GncBudgetViewClass *klass) g_type_class_add_private(klass, sizeof(GncBudgetViewPrivate)); } - static void gnc_budget_view_init(GncBudgetView *budget_view) { @@ -262,16 +262,30 @@ gnc_budget_view_init(GncBudgetView *budget_view) LEAVE(""); } +static void +gbv_treeview_update_grid_lines (gpointer prefs, gchar* pref, gpointer user_data) +{ + GtkTreeView *view = user_data; + gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ()); +} static void gnc_budget_view_finalize(GObject *object) { GncBudgetView *view; + GncBudgetViewPrivate *priv; ENTER("object %p", object); view = GNC_BUDGET_VIEW(object); g_return_if_fail(GNC_IS_BUDGET_VIEW(view)); + priv = GNC_BUDGET_VIEW_GET_PRIVATE(view); + + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_HORIZONTAL, + gbv_treeview_update_grid_lines, priv->totals_tree_view); + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_VERTICAL, + gbv_treeview_update_grid_lines, priv->totals_tree_view); + G_OBJECT_CLASS(gnc_budget_view_parent_class)->finalize(object); LEAVE(" "); } @@ -457,6 +471,10 @@ gbv_create_widget(GncBudgetView *view) // Set grid lines option to preference gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(totals_tree_view), gnc_tree_view_get_grid_lines_pref ()); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_HORIZONTAL, + gbv_treeview_update_grid_lines, totals_tree_view); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_GRID_LINES_VERTICAL, + gbv_treeview_update_grid_lines, totals_tree_view); PINFO("Number of Created totals columns is %d", gtk_tree_view_get_n_columns (totals_tree_view)); From 9e3f50f9e739cc901d3169c46d9a35d2006ae25e Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 19 Dec 2018 17:25:20 +0000 Subject: [PATCH 12/14] The preference, use formal accounting labels does not update the header With a register open and you change preference 'use formal accounting labels' it does not update the register header so add a call back for the preference. --- gnucash/gnome/gnc-split-reg.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c index 56b1257583..85996e1909 100644 --- a/gnucash/gnome/gnc-split-reg.c +++ b/gnucash/gnome/gnc-split-reg.c @@ -358,6 +358,13 @@ gnc_split_reg_init( GNCSplitReg *gsr ) gsr->read_only = FALSE; } +static void +gnc_split_reg_pref_acc_labels (gpointer prefs, gchar *pref, gpointer user_data) +{ + GNCSplitReg *gsr = user_data; + gnucash_register_refresh_from_prefs (gsr->reg); +} + static void gnc_split_reg_init2( GNCSplitReg *gsr ) { @@ -369,6 +376,11 @@ gnc_split_reg_init2( GNCSplitReg *gsr ) /* ordering is important here... setup_status before create_table */ gsr_create_table( gsr ); gsr_setup_table( gsr ); + + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_ACCOUNTING_LABELS, + gnc_split_reg_pref_acc_labels, + gsr); } static @@ -451,6 +463,11 @@ gnc_split_reg_dispose(GObject *obj) g_free (gsr->filter_text); gsr->filter_text = NULL; + gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, + GNC_PREF_ACCOUNTING_LABELS, + gnc_split_reg_pref_acc_labels, + gsr); + if (gsr->reg) { g_signal_handlers_disconnect_by_data (gsr->reg, gsr); From 3363736f9c70b1620042819e4363da2e37651e21 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 20 Dec 2018 10:58:28 +0000 Subject: [PATCH 13/14] Bug 796978 - Deleting a split of same account as register cancels the transaction without warning When autocomplete is used, one of the splits takes on the reference to the blank_split and if you delete this split the whole transaction is removed. This change compares the split that is about to be deleted to the blank_split and if the same moves the reference to another split. --- gnucash/gnome/gnc-split-reg.c | 4 ++ gnucash/register/ledger-core/split-register.c | 43 +++++++++++++++++++ gnucash/register/ledger-core/split-register.h | 8 ++++ 3 files changed, 55 insertions(+) diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c index 85996e1909..97ecec119a 100644 --- a/gnucash/gnome/gnc-split-reg.c +++ b/gnucash/gnome/gnc-split-reg.c @@ -1305,6 +1305,10 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data ) trans = xaccSplitGetParent(split); cursor_class = gnc_split_register_get_current_cursor_class (reg); + /* test for blank_split reference pointing to split */ + if (gnc_split_register_is_blank_split (reg, split)) + gnc_split_register_change_blank_split_ref (reg, split); + /* Deleting the blank split just cancels */ { Split *blank_split = gnc_split_register_get_blank_split (reg); diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c index c3bfd49d8c..c874365c51 100644 --- a/gnucash/register/ledger-core/split-register.c +++ b/gnucash/register/ledger-core/split-register.c @@ -1024,6 +1024,49 @@ gnc_split_register_paste_current (SplitRegister *reg) LEAVE(" "); } +gboolean +gnc_split_register_is_blank_split (SplitRegister *reg, Split *split) +{ + SRInfo *info = gnc_split_register_get_info (reg); + Split *current_blank_split = xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ()); + + if (split == current_blank_split) + return TRUE; + + return FALSE; +} + +void +gnc_split_register_change_blank_split_ref (SplitRegister *reg, Split *split) +{ + SRInfo *info = gnc_split_register_get_info (reg); + Split *current_blank_split = xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ()); + Split *pref_split = NULL; // has the same account as incoming split + Split *other_split = NULL; // other split + Split *s; + Account *blank_split_account = xaccSplitGetAccount (current_blank_split); + Transaction *trans = xaccSplitGetParent (split); + int i = 0; + + // loop through splitlist looking for splits other than the blank_split + while ((s = xaccTransGetSplit (trans, i)) != NULL) + { + if (s != current_blank_split) + { + if (blank_split_account == xaccSplitGetAccount (s)) + pref_split = s; // prefer same account + else + other_split = s; // any other split + } + i++; + } + // now change the saved blank split reference + if (pref_split != NULL) + info->blank_split_guid = *xaccSplitGetGUID (pref_split); + else if (other_split != NULL) + info->blank_split_guid = *xaccSplitGetGUID (other_split); +} + void gnc_split_register_delete_current_split (SplitRegister *reg) { diff --git a/gnucash/register/ledger-core/split-register.h b/gnucash/register/ledger-core/split-register.h index 5aa3a37aef..68a29183e3 100644 --- a/gnucash/register/ledger-core/split-register.h +++ b/gnucash/register/ledger-core/split-register.h @@ -539,6 +539,14 @@ const char * gnc_split_register_get_debit_string (SplitRegister *reg); /** Return the credit string used in the register. */ const char * gnc_split_register_get_credit_string (SplitRegister *reg); +/** Return TRUE if split is the blank_split. */ +gboolean gnc_split_register_is_blank_split (SplitRegister *reg, Split *split); + +/** Change the blank_split reference from pointing to split to another + * split of the transaction. This is used when deleting a split after an + * autocomplete as the blank_split reference will be pointing to one of + * the splits so it does not cancel the whole transaction */ +void gnc_split_register_change_blank_split_ref (SplitRegister *reg, Split *split); /** Pop up the exchange-rate dialog, maybe, for the current split. * If force_dialog is TRUE, the forces the dialog to to be called. From db663a298eeacc9ddedcf363a5229d73ca8b9784 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 20 Dec 2018 14:36:11 +0000 Subject: [PATCH 14/14] If you use the autocomplete and cancel other registers are not refreshed When the autocomplete is used the blank transaction gets the copy of the originating transaction and if you decide to cancel this any other open register that had a split in the new transaction is left with blank rows where the transaction was. Add a test for the pending and blank transaction being equal and refresh all registers if so. --- gnucash/register/ledger-core/split-register.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c index c874365c51..575c621c1a 100644 --- a/gnucash/register/ledger-core/split-register.c +++ b/gnucash/register/ledger-core/split-register.c @@ -1365,11 +1365,17 @@ void gnc_split_register_cancel_cursor_trans_changes (SplitRegister *reg) { SRInfo *info = gnc_split_register_get_info (reg); - Transaction *pending_trans; + Transaction *pending_trans, *blank_trans; + gboolean refresh_all = FALSE; pending_trans = xaccTransLookup (&info->pending_trans_guid, gnc_get_current_book ()); + blank_trans = xaccSplitGetParent (gnc_split_register_get_blank_split (reg)); + + if (pending_trans == blank_trans) + refresh_all = TRUE; + /* Get the currently open transaction, rollback the edits on it, and * then repaint everything. To repaint everything, make a note of * all of the accounts that will be affected by this rollback. */ @@ -1389,7 +1395,11 @@ gnc_split_register_cancel_cursor_trans_changes (SplitRegister *reg) info->pending_trans_guid = *guid_null (); gnc_resume_gui_refresh (); - gnc_split_register_redraw(reg); + + if (refresh_all) + gnc_gui_refresh_all (); // force a refresh of all registers + else + gnc_split_register_redraw (reg); } void