Skip to content

Commit

Permalink
Add warnings to the "Jump" operation instead of doing nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
nomis committed Sep 21, 2024
1 parent 8acf33e commit 1b7e87e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions gnucash/gnome/gnc-plugin-page-register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions gnucash/gschemas/org.gnucash.GnuCash.warnings.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@
<summary>Commit changes to a transaction</summary>
<description>This dialog is presented when you attempt to move out of a modified transaction. The changed data must be either saved or discarded.</description>
</key>
<key name="reg-trans-jump-multiple-splits" type="i">
<default>0</default>
<summary>Jump when there are multiple other accounts</summary>
<description>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.</description>
</key>
<key name="reg-trans-jump-single-account" type="i">
<default>0</default>
<summary>Jump when there are no other accounts</summary>
<description>This dialog is presented when you are unable to jump on a transaction because it only has splits for the current account.</description>
</key>
</schema>

<schema id="org.gnucash.GnuCash.warnings.temporary" path="/org/gnucash/GnuCash/warnings/temporary/">
Expand Down Expand Up @@ -247,5 +257,15 @@
<summary>Commit changes to a transaction</summary>
<description>This dialog is presented when you attempt to move out of a modified transaction. The changed data must be either saved or discarded.</description>
</key>
<key name="reg-trans-jump-multiple-splits" type="i">
<default>0</default>
<summary>Jump when there are multiple other accounts</summary>
<description>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.</description>
</key>
<key name="reg-trans-jump-single-account" type="i">
<default>0</default>
<summary>Jump when there are no other accounts</summary>
<description>This dialog is presented when you are unable to jump on a transaction because it only has splits for the current account.</description>
</key>
</schema>
</schemalist>

0 comments on commit 1b7e87e

Please sign in to comment.