From 1b7e87ed594bb792447c91428be8bd5426bdf319 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Mon, 5 Jun 2023 20:09:57 +0100 Subject: [PATCH] Add warnings to the "Jump" operation instead of doing nothing --- gnucash/gnome/gnc-plugin-page-register.cpp | 36 +++++++++++++++++++ ...rg.gnucash.GnuCash.warnings.gschema.xml.in | 20 +++++++++++ 2 files changed, 56 insertions(+) diff --git a/gnucash/gnome/gnc-plugin-page-register.cpp b/gnucash/gnome/gnc-plugin-page-register.cpp index d84ac2b069e..b5ee1eb62c8 100644 --- a/gnucash/gnome/gnc-plugin-page-register.cpp +++ b/gnucash/gnome/gnc-plugin-page-register.cpp @@ -4853,6 +4853,10 @@ jump_multiple_splits_by_single_account (Account *account, Split *split) other_split = s; } + // Jump to the same account so that the right warning is triggered + if (!other_split) + other_split = split; + return other_split; } @@ -4894,6 +4898,10 @@ jump_multiple_splits_by_value (Account *account, Split *split, gboolean largest) other_split = s; } + // Jump to the same account so that the right warning is triggered + if (!other_split) + other_split = split; + return other_split; } @@ -4995,6 +5003,20 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, } if (other_split == NULL) { + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window), + (GtkDialogFlags)(GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_ERROR, + GTK_BUTTONS_NONE, + "%s", + _("Unable to jump to other account")); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), + "%s", _("This transaction involves more than one other account. Select a specific split to jump to that account.")); + gtk_dialog_add_button (GTK_DIALOG(dialog), _("_OK"), GTK_RESPONSE_OK); + gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_MULTIPLE_SPLITS); + gtk_widget_destroy (dialog); + LEAVE ("no split (2)"); return; } @@ -5010,6 +5032,20 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, if (account == leader) { + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window), + (GtkDialogFlags)(GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_ERROR, + GTK_BUTTONS_NONE, + "%s", + _("Unable to jump to other account")); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), + "%s", _("This transaction only involves the current account so there is no other account to jump to.")); + gtk_dialog_add_button (GTK_DIALOG(dialog), _("_OK"), GTK_RESPONSE_OK); + gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_SINGLE_ACCOUNT); + gtk_widget_destroy (dialog); + LEAVE ("register open for account"); return; } diff --git a/gnucash/gschemas/org.gnucash.GnuCash.warnings.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.warnings.gschema.xml.in index 8db0304cd7e..253553124cc 100644 --- a/gnucash/gschemas/org.gnucash.GnuCash.warnings.gschema.xml.in +++ b/gnucash/gschemas/org.gnucash.GnuCash.warnings.gschema.xml.in @@ -124,6 +124,16 @@ Commit changes to a transaction This dialog is presented when you attempt to move out of a modified transaction. The changed data must be either saved or discarded. + + 0 + Jump when there are multiple other accounts + This dialog is presented when you are unable to jump on a transaction because it has splits for multiple other accounts. A specific split must be selected to jump to the other account. + + + 0 + Jump when there are no other accounts + This dialog is presented when you are unable to jump on a transaction because it only has splits for the current account. + @@ -247,5 +257,15 @@ Commit changes to a transaction This dialog is presented when you attempt to move out of a modified transaction. The changed data must be either saved or discarded. + + 0 + Jump when there are multiple other accounts + This dialog is presented when you are unable to jump on a transaction because it has splits for multiple other accounts. A specific split must be selected to jump to the other account. + + + 0 + Jump when there are no other accounts + This dialog is presented when you are unable to jump on a transaction because it only has splits for the current account. +