* src/gnome/window-register.c: add additional warnings when

deleting reconciled splits/transactions


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4038 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-04-24 20:49:32 +00:00
parent 657a9fdbe1
commit dd22ea89c1
3 changed files with 79 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2001-04-24 Dave Peticolas <dave@krondo.com>
* src/gnome/window-register.c: add additional warnings when
deleting reconciled splits/transactions
2001-04-24 Christian Stimming <stimming@tuhh.de> 2001-04-24 Christian Stimming <stimming@tuhh.de>
* src/guile/gnc.gwp: g-wrap all the euro-related functions. * src/guile/gnc.gwp: g-wrap all the euro-related functions.

View File

@ -2572,9 +2572,6 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
gnc_suspend_gui_refresh (); gnc_suspend_gui_refresh ();
/* make a copy of all of the accounts that will be
* affected by this deletion, so that we can update
* their register windows after the deletion. */
trans = xaccSplitGetParent (split); trans = xaccSplitGetParent (split);
splits = g_list_copy (xaccTransGetSplitList (trans)); splits = g_list_copy (xaccTransGetSplitList (trans));

View File

@ -2753,6 +2753,30 @@ gnc_transaction_delete_toggle_cb(GtkToggleButton *button, gpointer data)
} }
static gboolean
trans_has_reconciled_splits (Transaction *trans)
{
GList *node;
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
Split *split = node->data;
switch (xaccSplitGetReconcile (split))
{
case YREC:
case FREC:
return TRUE;
default:
break;
}
}
return FALSE;
}
/********************************************************************\ /********************************************************************\
* gnc_transaction_delete_query * * gnc_transaction_delete_query *
* creates and displays a dialog which asks the user wheter they * * creates and displays a dialog which asks the user wheter they *
@ -2763,7 +2787,7 @@ gnc_transaction_delete_toggle_cb(GtkToggleButton *button, gpointer data)
* Returns: DeleteType choice indicator * * Returns: DeleteType choice indicator *
\*******************************************************************/ \*******************************************************************/
static DeleteType static DeleteType
gnc_transaction_delete_query(GtkWindow *parent) gnc_transaction_delete_query (GtkWindow *parent, Transaction *trans)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *dvbox; GtkWidget *dvbox;
@ -2775,17 +2799,27 @@ gnc_transaction_delete_query(GtkWindow *parent)
GSList *group; GSList *group;
gint pos = 0; gint pos = 0;
gint result; gint result;
gboolean reconciled;
const char *usual = _("This selection will delete the whole " const char *usual = _("This selection will delete the whole "
"transaction. This is what you usually want."); "transaction. This is what you usually want.");
const char *warn = _("Warning: Just deleting all the splits will " const char *usual_recn = _("This selection will delete the whole "
"transaction.\n\n"
"You would be deleting a transaction "
"with reconciled splits!");
const char *warn = _("Warning: Just deleting all the other splits will "
"make your account unbalanced. You probably " "make your account unbalanced. You probably "
"shouldn't do this unless you're going to " "shouldn't do this unless you're going to "
"immediately add another split to bring the " "immediately add another split to bring the "
"transaction back into balance."); "transaction back into balance.");
const char *warn_recn = _("You would be deleting reconciled splits!");
const char *cbuf;
char *buf;
DeleteType return_value; DeleteType return_value;
reconciled = trans_has_reconciled_splits (trans);
dialog = gnome_dialog_new(_("Delete Transaction"), dialog = gnome_dialog_new(_("Delete Transaction"),
GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, GNOME_STOCK_BUTTON_CANCEL,
@ -2814,21 +2848,27 @@ gnc_transaction_delete_query(GtkWindow *parent)
gtk_signal_connect(GTK_OBJECT(trans_button), "toggled", gtk_signal_connect(GTK_OBJECT(trans_button), "toggled",
GTK_SIGNAL_FUNC(gnc_transaction_delete_toggle_cb), GTK_SIGNAL_FUNC(gnc_transaction_delete_toggle_cb),
(gpointer) usual); (gpointer) reconciled ? usual_recn : usual);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(trans_button)); group = gtk_radio_button_group(GTK_RADIO_BUTTON(trans_button));
splits_button = gtk_radio_button_new_with_label(group, splits_button =
_("Delete all the splits")); gtk_radio_button_new_with_label(group, _("Delete all the other splits"));
gtk_object_set_user_data(GTK_OBJECT(splits_button), text); gtk_object_set_user_data(GTK_OBJECT(splits_button), text);
gtk_box_pack_start(GTK_BOX(vbox), splits_button, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), splits_button, TRUE, TRUE, 0);
if (reconciled)
buf = g_strconcat (warn, "\n\n", warn_recn, NULL);
else
buf = g_strdup (warn);
gtk_signal_connect(GTK_OBJECT(splits_button), "toggled", gtk_signal_connect(GTK_OBJECT(splits_button), "toggled",
GTK_SIGNAL_FUNC(gnc_transaction_delete_toggle_cb), GTK_SIGNAL_FUNC(gnc_transaction_delete_toggle_cb),
(gpointer) warn); (gpointer) buf);
gtk_box_pack_start(GTK_BOX(dvbox), frame, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(dvbox), frame, TRUE, TRUE, 0);
gtk_editable_insert_text(GTK_EDITABLE(text), usual, strlen(warn), &pos); cbuf = reconciled ? usual_recn : usual;
gtk_editable_insert_text(GTK_EDITABLE(text), cbuf, strlen(cbuf), &pos);
gtk_text_set_line_wrap(GTK_TEXT(text), TRUE); gtk_text_set_line_wrap(GTK_TEXT(text), TRUE);
gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); gtk_text_set_word_wrap(GTK_TEXT(text), TRUE);
gtk_text_set_editable(GTK_TEXT(text), FALSE); gtk_text_set_editable(GTK_TEXT(text), FALSE);
@ -2838,6 +2878,8 @@ gnc_transaction_delete_query(GtkWindow *parent)
result = gnome_dialog_run_and_close(GNOME_DIALOG(dialog)); result = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
g_free (buf);
if (result != 0) if (result != 0)
return_value = DELETE_CANCEL; return_value = DELETE_CANCEL;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trans_button))) else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trans_button)))
@ -2905,8 +2947,10 @@ deleteCB(GtkWidget *widget, gpointer data)
{ {
const char *format = _("Are you sure you want to delete\n %s\n" const char *format = _("Are you sure you want to delete\n %s\n"
"from the transaction\n %s ?"); "from the transaction\n %s ?");
const char *recn_warn = _("You would be deleting a reconciled split!");
const char *memo; const char *memo;
const char *desc; const char *desc;
char recn;
memo = xaccSplitGetMemo (split); memo = xaccSplitGetMemo (split);
memo = (memo && *memo) ? memo : _("(no memo)"); memo = (memo && *memo) ? memo : _("(no memo)");
@ -2917,6 +2961,16 @@ deleteCB(GtkWidget *widget, gpointer data)
/* ask for user confirmation before performing permanent damage */ /* ask for user confirmation before performing permanent damage */
buf = g_strdup_printf (format, memo, desc); buf = g_strdup_printf (format, memo, desc);
recn = xaccSplitGetReconcile (split);
if (recn == YREC || recn == FREC)
{
char *new_buf;
new_buf = g_strconcat (buf, "\n\n", recn_warn, NULL);
g_free (buf);
buf = new_buf;
}
result = gnc_verify_dialog_parented (regData->window, buf, FALSE); result = gnc_verify_dialog_parented (regData->window, buf, FALSE);
g_free(buf); g_free(buf);
@ -2936,8 +2990,18 @@ deleteCB(GtkWidget *widget, gpointer data)
{ {
const char *message = _("Are you sure you want to delete the current " const char *message = _("Are you sure you want to delete the current "
"transaction?"); "transaction?");
const char *recn_warn = _("You would be deleting a transaction "
"with reconciled splits!");
char *buf;
result = gnc_verify_dialog_parented(regData->window, message, FALSE); if (trans_has_reconciled_splits (trans))
buf = g_strconcat (message, "\n\n", recn_warn, NULL);
else
buf = g_strdup (message);
result = gnc_verify_dialog_parented (regData->window, buf, FALSE);
g_free (buf);
if (!result) if (!result)
return; return;
@ -2953,7 +3017,8 @@ deleteCB(GtkWidget *widget, gpointer data)
{ {
DeleteType del_type; DeleteType del_type;
del_type = gnc_transaction_delete_query(GTK_WINDOW(regData->window)); del_type = gnc_transaction_delete_query (GTK_WINDOW(regData->window),
trans);
if (del_type == DELETE_CANCEL) if (del_type == DELETE_CANCEL)
return; return;