HIG rework. Remove newlines from dialog message strings. Give some

dialogs more descriptive button labels.  Clean up the code around the
file save query dialog.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13019 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2006-01-29 14:53:19 +00:00
parent 3cbcbd6e86
commit 1bd014def0
28 changed files with 898 additions and 666 deletions

View File

@ -1,3 +1,33 @@
2006-01-28 David Hampton <hampton@employees.org>
* src/gnome-utils/gncmod-gnome-utils.c:
* src/app-utils/gnc-err-popup.[ch]:
* src/app-utils/Makefile.am: Remove deprecated files
* src/register/ledger-core/split-register-model.c:
* src/register/ledger-core/split-register.c:
* src/register/ledger-core/split-register-control.c:
* src/import-export/hbci/dialog-pass.c:
* src/business/business-ledger/gncEntryLedger.c:
* src/business/business-ledger/gncEntryLedgerControl.c:
* src/business/business-gnome/gnc-plugin-business.c:
* src/gnome-utils/gnc-gnome-utils.c:
* src/gnome-utils/gw-gnome-utils-spec.scm:
* src/gnome-utils/gnc-file.[ch]:
* src/gnome-utils/gnc-main-window.c:
* src/gnome-utils/dialog-utils.[ch]:
* src/gnome-utils/gnc-gui-query.[ch]:
* src/gnome/gnc-split-reg.c:
* src/gnome/dialog-chart-export.c:
* src/gnome/schemas/apps_gnucash_warnings.schemas.in:
* src/gnome/dialog-commodities.c:
* src/gnome/dialog-price-edit-db.c:
* src/gnc-ui.h:
* src/app-utils/option-util.c: HIG rework. Remove newlines from
dialog message strings. Give some dialogs more descriptive button
labels. Clean up the code around the file save query dialog.
2006-01-28 Joshua Sled <jsled@asynchronous.org> 2006-01-28 Joshua Sled <jsled@asynchronous.org>
* src/report/report-system/html-style-sheet.scm * src/report/report-system/html-style-sheet.scm

View File

@ -30,7 +30,6 @@ libgncmod_app_utils_la_SOURCES = \
gnc-druid-provider-desc-file.c \ gnc-druid-provider-desc-file.c \
gnc-druid-provider-desc-multifile.c \ gnc-druid-provider-desc-multifile.c \
gnc-druid-provider-file-cb.c \ gnc-druid-provider-file-cb.c \
gnc-err-popup.c \
gnc-euro.c \ gnc-euro.c \
gnc-exp-parser.c \ gnc-exp-parser.c \
gnc-gettext-util.c \ gnc-gettext-util.c \
@ -56,7 +55,6 @@ gncinclude_HEADERS = \
gnc-druid-provider-desc-file.h \ gnc-druid-provider-desc-file.h \
gnc-druid-provider-desc-multifile.h \ gnc-druid-provider-desc-multifile.h \
gnc-druid-provider-file-cb.h \ gnc-druid-provider-file-cb.h \
gnc-err-popup.h \
gnc-euro.h \ gnc-euro.h \
gnc-exp-parser.h \ gnc-exp-parser.h \
gnc-gettext-util.h \ gnc-gettext-util.h \

View File

@ -1,79 +0,0 @@
/********************************************************************\
* gnc-err-popup.c -- GnuCash error GUI popups *
* Copyright (c) 2001 Linux Developers Group, Inc. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
#include "config.h"
#include <glib.h>
#include <stdarg.h>
#include <string.h>
#include "gnc-err-popup.h"
/********************************************************************\
Callbacks so that app can display gui messages.
\********************************************************************/
static GNCGuiMessage gnc_gui_warning_func = NULL;
static GNCGuiMessage gnc_gui_error_func = NULL;
void
gnc_set_warning_message (GNCGuiMessage func)
{
gnc_gui_warning_func = func;
}
void
gnc_set_error_message (GNCGuiMessage func)
{
gnc_gui_error_func = func;
}
gboolean
gnc_send_gui_warning(const gchar *format, ...)
{
va_list args;
if (!gnc_gui_warning_func) return FALSE;
va_start (args, format);
gnc_gui_warning_func(format, args);
va_end(args);
return(TRUE);
}
gboolean
gnc_send_gui_error(const gchar *format, ...)
{
va_list args;
if (!gnc_gui_error_func) return(FALSE);
va_start (args, format);
gnc_gui_error_func(format, args);
va_end(args);
return(TRUE);
}
/************************* END OF FILE ******************************\
\********************************************************************/

View File

@ -1,50 +0,0 @@
/********************************************************************\
* gnc-err-popup.h -- GnuCash GUI Error Popup *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
/** @file gnc-err-popup.h @brief GnuCash GUI error loging facility
* Copyright (c) 2001 Linux Developers Group, Inc.
*/
#ifndef GNC_ERR_POPUP_H
#define GNC_ERR_POPUP_H
#include <glib.h>
#include <stdarg.h>
#include <stdio.h>
/* -------------------------------------------------------- */
/* Infrastructure to send messages go to GUI popups, not to stderr!
* Incompletely implemented, needs work.
* XXX This probably duplicates some popup code elswwhere in the
* code and should be trashed at earliest convenience.
*/
typedef void (*GNCGuiMessage) (const char *format, va_list args);
void gnc_set_warning_message (GNCGuiMessage func);
void gnc_set_error_message (GNCGuiMessage func);
gboolean gnc_send_gui_warning (const char *format, ...) G_GNUC_PRINTF(1,2);
gboolean gnc_send_gui_error (const char *format, ...) G_GNUC_PRINTF(1,2);
#define PWARN_GUI(format, args...) { \
gnc_send_gui_error(format, ## args); \
}
#endif /* GNC_ERR_POPUP_H */

View File

@ -22,7 +22,7 @@
#include "config.h" #include "config.h"
#include <glib.h> #include <gtk/gtk.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
@ -32,7 +32,6 @@
#include "glib-helpers.h" #include "glib-helpers.h"
#include "guile-util.h" #include "guile-util.h"
#include "qof.h" #include "qof.h"
#include "gnc-err-popup.h"
#include "guile-mappings.h" #include "guile-mappings.h"
#include <g-wrap-wct.h> #include <g-wrap-wct.h>
@ -1730,7 +1729,9 @@ gnc_commit_option(GNCOption *option)
{ {
SCM oops; SCM oops;
char *section, *name; char *section, *name;
GtkWidget *dialog;
const gchar *message; const gchar *message;
const gchar *format = _("There is a problem with option %s:%s.\n%s");
/* Second element is error message */ /* Second element is error message */
oops = SCM_CADR(result); oops = SCM_CADR(result);
@ -1744,10 +1745,16 @@ gnc_commit_option(GNCOption *option)
name = gnc_option_name(option); name = gnc_option_name(option);
section = gnc_option_section(option); section = gnc_option_section(option);
gnc_send_gui_error(_("There is a problem with option %s:%s.\n%s"), dialog = gtk_message_dialog_new(NULL,
section ? section : "(null)", 0,
name ? name : "(null)", GTK_MESSAGE_ERROR,
message ? message : "(null)"); GTK_BUTTONS_OK,
format,
section ? section : "(null)",
name ? name : "(null)",
message ? message : "(null)");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (name != NULL) if (name != NULL)
free(name); free(name);

View File

@ -735,7 +735,8 @@ gnc_plugin_business_cmd_export_invoice (GtkAction *action, GncMainWindowActionDa
qof_session_save(chart_session, NULL); qof_session_save(chart_session, NULL);
} }
} }
show_session_error(qof_session_get_error(chart_session), filename); show_session_error(qof_session_get_error(chart_session), filename,
GNC_FILE_DIALOG_EXPORT);
g_free(filename); g_free(filename);
qof_session_end(chart_session); qof_session_end(chart_session);
qof_session_set_current_session(current_session); qof_session_set_current_session(current_session);
@ -766,7 +767,8 @@ gnc_plugin_business_cmd_export_customer (GtkAction *action, GncMainWindowActionD
qof_session_save(chart_session, NULL); qof_session_save(chart_session, NULL);
} }
} }
show_session_error(qof_session_get_error(chart_session), filename); show_session_error(qof_session_get_error(chart_session), filename,
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session); qof_session_end(chart_session);
g_free(filename); g_free(filename);
qof_session_set_current_session(current_session); qof_session_set_current_session(current_session);
@ -797,7 +799,8 @@ gnc_plugin_business_cmd_export_vendor (GtkAction *action, GncMainWindowActionDat
qof_session_save(chart_session, NULL); qof_session_save(chart_session, NULL);
} }
} }
show_session_error(qof_session_get_error(chart_session), filename); show_session_error(qof_session_get_error(chart_session), filename,
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session); qof_session_end(chart_session);
g_free(filename); g_free(filename);
qof_session_set_current_session(current_session); qof_session_set_current_session(current_session);
@ -828,7 +831,8 @@ gnc_plugin_business_cmd_export_employee (GtkAction *action, GncMainWindowActionD
qof_session_save(chart_session, NULL); qof_session_save(chart_session, NULL);
} }
} }
show_session_error(qof_session_get_error(chart_session), filename); show_session_error(qof_session_get_error(chart_session), filename,
GNC_FILE_DIALOG_EXPORT);
qof_session_end(chart_session); qof_session_end(chart_session);
g_free(filename); g_free(filename);
qof_session_set_current_session(current_session); qof_session_set_current_session(current_session);

View File

@ -25,11 +25,12 @@
#include "config.h" #include "config.h"
#include <glib.h> #include <gtk/gtk.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include "Account.h" #include "Account.h"
#include "dialog-account.h" #include "dialog-account.h"
#include "dialog-utils.h"
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
#include "combocell.h" #include "combocell.h"
#include "pricecell.h" #include "pricecell.h"
@ -801,13 +802,29 @@ gnc_entry_ledger_duplicate_current_entry (GncEntryLedger *ledger)
/* If the cursor has been edited, we are going to have to commit /* If the cursor has been edited, we are going to have to commit
* it before we can duplicate. Make sure the user wants to do that. */ * it before we can duplicate. Make sure the user wants to do that. */
if (changed) { if (changed) {
const char *message = _("The current entry has been changed.\n" const char *title = _("Save the current entry?");
"Would you like to save it?"); const char *message =
gint result; _("The current transaction has been changed. Would you like to "
"record the changes before duplicating this entry, or "
"cancel the duplication?");
GtkWidget *dialog;
gint response;
result = gnc_ok_cancel_dialog (ledger->parent, GTK_RESPONSE_OK, message); dialog = gtk_message_dialog_new(GTK_WINDOW(ledger->parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Record"), GTK_RESPONSE_ACCEPT,
NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), "invoice_entry_duplicated");
gtk_widget_destroy(dialog);
if (result != GTK_RESPONSE_OK) { if (response != GTK_RESPONSE_ACCEPT) {
gnc_resume_gui_refresh (); gnc_resume_gui_refresh ();
return; return;
} }

View File

@ -31,6 +31,7 @@
#include "Account.h" #include "Account.h"
#include "combocell.h" #include "combocell.h"
#include "dialog-account.h" #include "dialog-account.h"
#include "dialog-utils.h"
#include "gnc-component-manager.h" #include "gnc-component-manager.h"
#include "gnc-ui.h" #include "gnc-ui.h"
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
@ -272,7 +273,7 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
{ {
GncEntryLedger *ledger = user_data; GncEntryLedger *ledger = user_data;
GncEntry *entry, *new_entry; GncEntry *entry, *new_entry;
gint result; gint response;
VirtualLocation virt_loc; VirtualLocation virt_loc;
int changed; int changed;
char const *cell_name; char const *cell_name;
@ -482,35 +483,46 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
* limited cases -- usually just let the change go through. * limited cases -- usually just let the change go through.
*/ */
{ {
const char *message; GtkWidget *dialog;
const char *title = _("Save the current entry?");
const char *message =
_("The current entry has been changed. However, this entry is "
"part of an existing order. Would you like to record the change "
"and effectively change your order?");
switch (ledger->type) { switch (ledger->type) {
case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_INVOICE_ENTRY:
if (gncEntryGetOrder (entry) != NULL) { if (gncEntryGetOrder (entry) != NULL) {
message = _("The current entry has been changed.\n" dialog = gtk_message_dialog_new(GTK_WINDOW(ledger->parent),
"However, this entry is part of an existing order.\n" GTK_DIALOG_DESTROY_WITH_PARENT,
"Would you like to record the change and\n" GTK_MESSAGE_QUESTION,
"effectively change your order?"); GTK_BUTTONS_NONE,
"%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
_("_Don't Record"), GTK_RESPONSE_REJECT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Record"), GTK_RESPONSE_ACCEPT,
NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), "invoice_entry_changed");
gtk_widget_destroy(dialog);
break; break;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
result = GTK_RESPONSE_YES; response = GTK_RESPONSE_ACCEPT;
goto dontask; break;
} }
result = gnc_verify_cancel_dialog(ledger->parent, GTK_RESPONSE_YES, message);
} }
dontask: switch (response)
switch (result)
{ {
case GTK_RESPONSE_YES: case GTK_RESPONSE_ACCEPT:
break; break;
case GTK_RESPONSE_NO: case GTK_RESPONSE_REJECT:
{ {
VirtualCellLocation vcell_loc; VirtualCellLocation vcell_loc;
GncEntry *new_entry; GncEntry *new_entry;
@ -531,10 +543,8 @@ dontask:
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
return TRUE;
default: default:
break; return TRUE;
} }
return FALSE; return FALSE;

View File

@ -63,24 +63,11 @@
/* Dialog windows ***************************************************/ /* Dialog windows ***************************************************/
extern gint
gnc_verify_cancel_dialog(gncUIWidget parent,
gint default_result,
const char *format, ...) G_GNUC_PRINTF (3,4);
extern gboolean extern gboolean
gnc_verify_dialog(gncUIWidget parent, gnc_verify_dialog(gncUIWidget parent,
gboolean yes_is_default, gboolean yes_is_default,
const char *format, ...) G_GNUC_PRINTF (3, 4); const char *format, ...) G_GNUC_PRINTF (3, 4);
gint
gnc_verify_remember_dialog(gncUIWidget parent, const gchar *gconf_key,
const gchar *yes_label, const gchar *no_label,
const gchar *format, ...) G_GNUC_PRINTF (5,6);
extern gint extern gint
gnc_ok_cancel_dialog(gncUIWidget parent, gnc_ok_cancel_dialog(gncUIWidget parent,
gint default_result, gint default_result,
@ -94,12 +81,6 @@ gnc_warning_dialog(gncUIWidget parent,
gint
gnc_warning_remember_dialog(gncUIWidget parent, const gchar *gconf_key,
const gchar *yes_label, const gchar *no_label,
const gchar *format, ...) G_GNUC_PRINTF (5,6);
extern void extern void
gnc_error_dialog(GtkWidget *parent, gnc_error_dialog(GtkWidget *parent,
const char *forrmat, ...) G_GNUC_PRINTF (2, 3); const char *forrmat, ...) G_GNUC_PRINTF (2, 3);

View File

@ -944,3 +944,126 @@ gnc_gtk_dialog_add_button (GtkWidget *dialog, const gchar *label, const gchar *s
gtk_widget_show_all(button); gtk_widget_show_all(button);
gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, response); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, response);
} }
static void
gnc_perm_button_cb (GtkButton *perm, gpointer user_data)
{
gboolean perm_active;
perm_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm));
gtk_widget_set_sensitive(user_data, !perm_active);
}
gint
gnc_dialog_run (GtkDialog *dialog, const gchar *gconf_key)
{
GtkWidget *perm, *temp;
gboolean ask = TRUE;
gint response;
/* Does the user want to see this question? If not, return the
* previous answer. */
response = gnc_gconf_get_int(GCONF_WARNINGS_PERM, gconf_key, NULL);
if (response != 0)
return response;
response = gnc_gconf_get_int(GCONF_WARNINGS_TEMP, gconf_key, NULL);
if (response != 0)
return response;
/* Add in the checkboxes to find out if the answer should be remembered. */
#if 0
if (GTK_IS_MESSAGE_DIALOG(dialog)) {
GtkMessageType type;
g_object_get(dialog, "message-type", &type, (gchar*)NULL);
ask = (type == GTK_MESSAGE_QUESTION);
} else {
ask = FALSE;
}
#endif
perm = gtk_check_button_new_with_mnemonic
(ask
? _("Remember and don't _ask me again.")
: _("Don't _tell me again."));
temp = gtk_check_button_new_with_mnemonic
(ask
? _("Remember and don't ask me again this _session.")
: _("Don't tell me again this _session."));
gtk_widget_show(perm);
gtk_widget_show(temp);
gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), perm);
gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), temp);
g_signal_connect(perm, "clicked", G_CALLBACK(gnc_perm_button_cb), temp);
/* OK. Present the dialog. */
response = gtk_dialog_run(dialog);
if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT)) {
return GTK_RESPONSE_NO;
}
/* Save the answer? */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm))) {
gnc_gconf_set_int(GCONF_WARNINGS_PERM, gconf_key, response, NULL);
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp))) {
gnc_gconf_set_int(GCONF_WARNINGS_TEMP, gconf_key, response, NULL);
}
return response;
}
#ifndef HAVE_GLIB26
/** Find the first GtkLabel in a container. When called on a gtk2.4
* message dialog, there is only one label in the dialog so theis
* should return it. */
static void
find_label (GtkWidget *widget, gpointer data)
{
GtkWidget **label = data;
if (*label)
return;
if (GTK_IS_LABEL(widget)) {
*label = widget;
return;
}
if (GTK_IS_CONTAINER(widget)) {
gtk_container_foreach(GTK_CONTAINER(widget), find_label, data);
}
}
/** Mimic the gtk2.6 function to add secondary information to a
* message dialog. */
void
gtk_message_dialog_format_secondary_text(GtkMessageDialog *dialog,
const gchar *format,
...)
{
GtkWidget *label = NULL;
const gchar *current;
gchar *primary, *secondary;
va_list args;
gtk_container_foreach(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
find_label, &label);
if (!label)
return;
/* Get the current markup. */
current = gtk_label_get_label(GTK_LABEL(label));
/* Format the text to be added. */
va_start(args, format);
secondary = g_strdup_vprintf(format, args);
va_end(args);
/* Append the two strings, making the first one bold. */
primary = g_strdup_printf("<b>%s</b>\n\n%s", current, secondary);
gtk_label_set_markup(GTK_LABEL(label), primary);
g_free(primary);
g_free(secondary);
}
#endif

View File

@ -150,4 +150,17 @@ void gnc_gtk_dialog_add_button (GtkWidget *dialog,
const gchar *stock_id, const gchar *stock_id,
guint response); guint response);
/** Note: This dialog is modal! (It calls gtk_dialog_run() which is modal.)
*/
gint
gnc_dialog_run(GtkDialog *dialog, const gchar *gconf_key);
#ifndef HAVE_GLIB26
void
gtk_message_dialog_format_secondary_text(GtkMessageDialog *dialog,
const gchar *message_format,
...) G_GNUC_PRINTF (2, 3);
#endif
#endif #endif

View File

@ -52,7 +52,6 @@
/* This static indicates the debugging module that this .o belongs to. */ /* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI; static QofLogModule log_module = GNC_MOD_GUI;
static GNCCanCancelSaveCB can_cancel_cb = NULL;
static GNCShutdownCB shutdown_cb = NULL; static GNCShutdownCB shutdown_cb = NULL;
@ -181,11 +180,15 @@ gnc_file_dialog (const char * title,
gboolean gboolean
show_session_error (QofBackendError io_error, const char *newfile) show_session_error (QofBackendError io_error,
const char *newfile,
GNCFileDialogType type)
{ {
GtkWidget *parent = gnc_ui_get_toplevel(); GtkWidget *parent = gnc_ui_get_toplevel();
GtkWidget *dialog;
gboolean uh_oh = TRUE; gboolean uh_oh = TRUE;
const char *fmt; const char *fmt, *label;
gint response;
gnc_destroy_splash_screen(); /* Just in case */ gnc_destroy_splash_screen(); /* Just in case */
if (NULL == newfile) { newfile = _("(null)"); } if (NULL == newfile) { newfile = _("(null)"); }
@ -197,206 +200,244 @@ show_session_error (QofBackendError io_error, const char *newfile)
break; break;
case ERR_BACKEND_NO_HANDLER: { case ERR_BACKEND_NO_HANDLER: {
fmt = _("No suitable backend was found for\n%s."); fmt = _("No suitable backend was found for %s.");
gnc_error_dialog(parent, fmt, newfile); gnc_error_dialog(parent, fmt, newfile);
break; break;
} }
case ERR_BACKEND_NO_BACKEND: case ERR_BACKEND_NO_BACKEND:
fmt = _("The URL \n %s\n" fmt = _("The URL %s is not supported by this version of GnuCash.");
"is not supported by this version of GnuCash.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_BAD_URL: case ERR_BACKEND_BAD_URL:
fmt = _("Can't parse the URL\n %s\n"); fmt = _("Can't parse the URL %s.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_CANT_CONNECT: case ERR_BACKEND_CANT_CONNECT:
fmt = _("Can't connect to\n %s\n" fmt = _("Can't connect to %s. "
"The host, username or password were incorrect."); "The host, username or password were incorrect.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_CONN_LOST: case ERR_BACKEND_CONN_LOST:
fmt = _("Can't connect to\n %s\n" fmt = _("Can't connect to %s. "
"Connection was lost, unable to send data."); "Connection was lost, unable to send data.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_TOO_NEW: case ERR_BACKEND_TOO_NEW:
fmt = _("This file/URL appears to be from a newer version\n" fmt = _("This file/URL appears to be from a newer version "
"of GnuCash. You must upgrade your version of GnuCash\n" "of GnuCash. You must upgrade your version of GnuCash "
"to work with this data."); "to work with this data.");
gnc_error_dialog (parent, fmt); gnc_error_dialog (parent, fmt);
break; break;
case ERR_BACKEND_NO_SUCH_DB: case ERR_BACKEND_NO_SUCH_DB:
fmt = _("The database\n" fmt = _("The database %s doesn't seem to exist. "
" %s\n" "Do you want to create it?");
"doesn't seem to exist. Do you want to create it?\n");
if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; } if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; }
break; break;
case ERR_BACKEND_LOCKED: case ERR_BACKEND_LOCKED:
fmt = _("GnuCash could not obtain the lock for\n" switch (type){
" %s.\n" case GNC_FILE_DIALOG_OPEN:
"That database may be in use by another user,\n" default:
"in which case you should not open the database.\n" label = GTK_STOCK_OPEN;
"\nDo you want to proceed with opening the database?"); fmt = _("GnuCash could not obtain the lock for %s."
if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; } "That database may be in use by another user, "
"in which case you should not open the database. "
"Do you want to proceed with opening the database?");
break;
case GNC_FILE_DIALOG_IMPORT:
label = _("Import");
fmt = _("GnuCash could not obtain the lock for %s."
"That database may be in use by another user, "
"in which case you should not import the database. "
"Do you want to proceed with importing the database?");
break;
case GNC_FILE_DIALOG_SAVE:
label = GTK_STOCK_SAVE;
fmt = _("GnuCash could not obtain the lock for %s."
"That database may be in use by another user, "
"in which case you should not save the database. "
"Do you want to proceed with saving the database?");
break;
case GNC_FILE_DIALOG_EXPORT:
label = _("Export");
fmt = _("GnuCash could not obtain the lock for %s."
"That database may be in use by another user, "
"in which case you should not export the database. "
"Do you want to proceed with exporting the database?");
break;
}
dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
fmt,
newfile);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
label, GTK_RESPONSE_YES,
NULL);
response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
uh_oh = (response != GTK_RESPONSE_YES);
break; break;
case ERR_BACKEND_READONLY: case ERR_BACKEND_READONLY:
fmt = _("GnuCash could not write to\n" fmt = _("GnuCash could not write to %s. "
" %s.\n" "That database may be on a read-only file system, "
"That database may be on a read-only file system,\n" "or you may not have write permission for the directory.");
"or you may not have write permission for the directory.\n");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_DATA_CORRUPT: case ERR_BACKEND_DATA_CORRUPT:
fmt = _("The file/URL \n %s\n" fmt = _("The file/URL %s"
"does not contain GnuCash data or the data is corrupt."); "does not contain GnuCash data or the data is corrupt.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_SERVER_ERR: case ERR_BACKEND_SERVER_ERR:
fmt = _("The server at URL \n %s\n" fmt = _("The server at URL %s "
"experienced an error or encountered bad or corrupt data."); "experienced an error or encountered bad or corrupt data.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_PERM: case ERR_BACKEND_PERM:
fmt = _("You do not have permission to access\n %s\n"); fmt = _("You do not have permission to access %s.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_BACKEND_MISC: case ERR_BACKEND_MISC:
fmt = _("An error occurred while processing\n %s\n"); fmt = _("An error occurred while processing %s.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
/* QSF additions */ /* QSF additions */
case ERR_QSF_INVALID_OBJ: { case ERR_QSF_INVALID_OBJ:
fmt = _("Invalid QSF Object file!\n" fmt = _("Invalid QSF Object file! The QSF object file %s failed to"
"The QSF object file\n%s\n failed to validate" " validate against the QSF object schema. The XML structure of"
" against the QSF object schema.\nThe XML structure of the file" " the file is either not well-formed or contains illegal data.");
" is either not well-formed or contains illegal data."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_INVALID_MAP:
case ERR_QSF_INVALID_MAP: { fmt = _("Invalid QSF Map file! The QSF map file %s failed to validate"
fmt = _("Invalid QSF Map file!\n" " against the QSF map schema. The XML structure of the file"
"The QSF map file\n%s\n failed to validate " " is either not well-formed or contains illegal data.");
" against the QSF map schema.\nThe XML structure of the file" gnc_error_dialog(parent, fmt, newfile);
" is either not well-formed or contains illegal data."); break;
gnc_error_dialog(parent, fmt, newfile);
break; case ERR_QSF_BAD_QOF_VERSION:
} fmt = _("The QSF Map file %s was written for a different version of"
case ERR_QSF_BAD_QOF_VERSION: { " QOF. It may need to be modified to work with your current"
fmt = _("The QSF Map file\n%s\nwas written for a different version of QOF.\n" " QOF installation.");
"It may need to be modified to work with your current QOF installation."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_BAD_MAP:
case ERR_QSF_BAD_MAP: { fmt = _("The selected QSF map %s contains unusable data. "
fmt = _("The selected QSF map\n%s\ncontains unusable data. " "This is usually because not all the required parameters for "
"This is usually because not all the required parameters for " "the defined objects have calculations described in the map.");
"the defined objects have calculations described in the map."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_BAD_OBJ_GUID:
case ERR_QSF_BAD_OBJ_GUID: { fmt = _("The selected QSF object file %s contains one or more invalid "
fmt = _("The selected QSF object file\n%s\n contains one or more invalid GUIDs. " "GUIDs. The file cannot be processed - please check the source "
"The file cannot be processed - please check the source of the file " "of the file and try again.");
"and try again."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_NO_MAP:
case ERR_QSF_NO_MAP: { fmt = _("The selected QSF Object file %s requires a map but it was "
fmt = _("The selected QSF Object file\n%s\nrequires a map but it was not provided."); "not provided.");
gnc_error_dialog(parent, fmt, newfile); gnc_error_dialog(parent, fmt, newfile);
break; break;
}
case ERR_QSF_WRONG_MAP: { case ERR_QSF_WRONG_MAP:
fmt = _("Wrong QSF map selected.\n" fmt = _("Wrong QSF map selected. The selected map %s validates but was "
"The selected map,\n%s\n validates but was written " "written for different QOF objects. The list of objects defined "
"for different QOF objects.\n The list of objects defined in " "in this map does not include all the objects described in "
"this map does not include all the objects described in " "the current QSF object file.");
"the current QSF object file."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_MAP_NOT_OBJ:
case ERR_QSF_MAP_NOT_OBJ: { fmt = _("The selected file %s is a QSF map and cannot be "
fmt = _("The selected file \n %s\n is a QSF map and cannot be " "opened as a QSF object.");
"opened as a QSF object."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_OVERFLOW:
case ERR_QSF_OVERFLOW : { fmt = _("When converting XML strings into numbers, an overflow "
fmt = _("When converting XML strings into numbers, an overflow " "has been detected. The QSF object file %s contains invalid "
"has been detected. The QSF object file\n %s\ncontains invalid " "data in a field that is meant to hold a number.");
"data in a field that is meant to hold a number."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
} case ERR_QSF_OPEN_NOT_MERGE:
case ERR_QSF_OPEN_NOT_MERGE : { fmt = _("The QSF object file %s is valid and contains GnuCash "
fmt = _("The QSF object file\n %s\nis valid and contains GnuCash " "objects. However, GnuCash cannot open the file directly because "
"objects. However, GnuCash cannot open the file directly because " "the data needs to be merged into an existing GnuCash data book. "
"the data needs to be merged into an existing GnuCash data book. " "Please open a GnuCash file or create a new one, then import "
"Please open a GnuCash file or create a new one, then import " "this QSF object file so that the data can be merged into the "
"this QSF object file so that the data can be merged into the " "main data book.");
"main data book."); gnc_error_dialog(parent, fmt, newfile);
gnc_error_dialog(parent, fmt, newfile); break;
break;
}
case ERR_FILEIO_FILE_BAD_READ: case ERR_FILEIO_FILE_BAD_READ:
fmt = _("There was an error reading the file.\n" fmt = _("There was an error reading the file. "
"Do you want to continue?"); "Do you want to continue?");
if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; } if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
break; break;
case ERR_FILEIO_PARSE_ERROR: case ERR_FILEIO_PARSE_ERROR:
fmt = _("There was an error parsing the file\n %s"); fmt = _("There was an error parsing the file %s.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_FILEIO_FILE_EMPTY: case ERR_FILEIO_FILE_EMPTY:
fmt = _("The file \n %s\nis empty."); fmt = _("The file %s is empty.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_FILEIO_FILE_NOT_FOUND: case ERR_FILEIO_FILE_NOT_FOUND:
fmt = _("The file \n %s\ncould not be found."); fmt = _("The file %s could not be found.");
gnc_error_dialog (parent, fmt, newfile); gnc_error_dialog (parent, fmt, newfile);
break; break;
case ERR_FILEIO_FILE_TOO_OLD: case ERR_FILEIO_FILE_TOO_OLD:
fmt = _("This file is from an older version of GnuCash.\n" fmt = _("This file is from an older version of GnuCash. "
"Do you want to continue?"); "Do you want to continue?");
if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; } if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
break; break;
case ERR_FILEIO_UNKNOWN_FILE_TYPE: case ERR_FILEIO_UNKNOWN_FILE_TYPE:
fmt = _("The file type of file\n %s\nis unknown."); fmt = _("The file type of file %s is unknown.");
gnc_error_dialog(parent, fmt, newfile); gnc_error_dialog(parent, fmt, newfile);
break; break;
case ERR_FILEIO_BACKUP_ERROR: case ERR_FILEIO_BACKUP_ERROR:
fmt = _("Could not make a backup of the file\n %s"); fmt = _("Could not make a backup of the file %s");
gnc_error_dialog(parent, fmt, newfile); gnc_error_dialog(parent, fmt, newfile);
break; break;
case ERR_FILEIO_WRITE_ERROR: case ERR_FILEIO_WRITE_ERROR:
fmt = _("Could not write to file\n %s\nCheck that you have " fmt = _("Could not write to file %s Check that you have "
"permission to write to this file and that " "permission to write to this file and that "
"there is sufficient space to create it."); "there is sufficient space to create it.");
gnc_error_dialog(parent, fmt, newfile); gnc_error_dialog(parent, fmt, newfile);
break; break;
case ERR_SQL_DB_TOO_OLD: case ERR_SQL_DB_TOO_OLD:
fmt = _("This database is from an older version of GnuCash.\n" fmt = _("This database is from an older version of GnuCash. "
"Do you want to want to upgrade the database " "Do you want to want to upgrade the database "
"to the current version?"); "to the current version?");
if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; } if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
@ -404,17 +445,17 @@ show_session_error (QofBackendError io_error, const char *newfile)
case ERR_SQL_DB_BUSY: case ERR_SQL_DB_BUSY:
fmt = _("The SQL database is in use by other users, " fmt = _("The SQL database is in use by other users, "
"and the upgrade cannot be performed until they logoff.\n" "and the upgrade cannot be performed until they logoff. "
"If there are currently no other users, consult the \n" "If there are currently no other users, consult the "
"documentation to learn how to clear out dangling login\n" "documentation to learn how to clear out dangling login "
"sessions."); "sessions.");
gnc_error_dialog (parent, fmt); gnc_error_dialog (parent, fmt);
break; break;
default: default:
PERR("FIXME: Unhandled error %d", io_error); PERR("FIXME: Unhandled error %d", io_error);
fmt = _("An unknown I/O error occurred."); fmt = _("An unknown I/O error (%d) occurred.");
gnc_error_dialog (parent, fmt); gnc_error_dialog (parent, fmt, io_error);
break; break;
} }
@ -456,7 +497,7 @@ gnc_file_new (void)
/* If user attempts to start a new session before saving results of /* If user attempts to start a new session before saving results of
* the last one, prompt them to clean up their act. */ * the last one, prompt them to clean up their act. */
if (!gnc_file_query_save ()) if (!gnc_file_query_save (TRUE))
return; return;
session = qof_session_get_current_session (); session = qof_session_get_current_session ();
@ -485,7 +526,7 @@ gnc_file_new (void)
} }
gboolean gboolean
gnc_file_query_save (void) gnc_file_query_save (gboolean can_cancel)
{ {
GtkWidget *parent = gnc_ui_get_toplevel(); GtkWidget *parent = gnc_ui_get_toplevel();
@ -497,26 +538,46 @@ gnc_file_query_save (void)
*/ */
while (qof_book_not_saved(qof_session_get_book (qof_session_get_current_session ()))) while (qof_book_not_saved(qof_session_get_book (qof_session_get_current_session ())))
{ {
gint result; GtkWidget *dialog;
const char *message = _("Changes have been made since the last " gint response;
"Save. Save the data to file?"); const char *title = _("Save changes to the file?");
const char *message =
_("Changes have been made since the last time it was saved. If "
"you continue without saving these changes will be discarded.");
if (can_cancel_cb && can_cancel_cb ()) dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
result = gnc_verify_cancel_dialog (parent, GTK_RESPONSE_YES, message); GTK_DIALOG_DESTROY_WITH_PARENT,
else GTK_MESSAGE_QUESTION,
{ GTK_BUTTONS_NONE,
gboolean do_save = gnc_verify_dialog (parent, TRUE, message); "%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_button(GTK_DIALOG(dialog),
_("Continue _Without Saving"), GTK_RESPONSE_OK);
result = do_save ? GTK_RESPONSE_YES : GTK_RESPONSE_NO; if (can_cancel)
gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_SAVE, GTK_RESPONSE_YES);
response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
switch (response) {
case GTK_RESPONSE_YES:
gnc_file_save ();
/* Go check the loop condition. */
break;
case GTK_RESPONSE_CANCEL:
default:
if (can_cancel)
return FALSE;
/* No cancel function available. Fall through. */
case GTK_RESPONSE_OK:
return TRUE;
} }
if (result == GTK_RESPONSE_CANCEL)
return FALSE;
if (result == GTK_RESPONSE_NO)
return TRUE;
gnc_file_save ();
} }
return TRUE; return TRUE;
@ -541,7 +602,8 @@ gnc_post_file_open (const char * filename)
newfile = xaccResolveURL (filename); newfile = xaccResolveURL (filename);
if (!newfile) if (!newfile)
{ {
show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename); show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename,
GNC_FILE_DIALOG_OPEN);
return FALSE; return FALSE;
} }
@ -586,26 +648,12 @@ gnc_post_file_open (const char * filename)
gnc_destroy_splash_screen(); /* Just in case */ gnc_destroy_splash_screen(); /* Just in case */
#ifdef HAVE_GLIB26
dialog = gtk_message_dialog_new(NULL, dialog = gtk_message_dialog_new(NULL,
0, 0,
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
fmt1, newfile); fmt1, newfile);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), fmt2); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), fmt2);
#else
{
gchar *tmp;
tmp = g_strdup_printf("<b>%s</b>\n\n%s", fmt1, fmt2);
dialog = gtk_message_dialog_new_with_markup(NULL,
0,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
tmp, newfile);
g_free(tmp);
}
#endif
gnc_gtk_dialog_add_button(dialog, _("_Open Anyway"), gnc_gtk_dialog_add_button(dialog, _("_Open Anyway"),
GTK_STOCK_OPEN, RESPONSE_OPEN); GTK_STOCK_OPEN, RESPONSE_OPEN);
@ -649,7 +697,7 @@ gnc_post_file_open (const char * filename)
else if ((ERR_BACKEND_NO_SUCH_DB == io_err) || else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
(ERR_SQL_DB_TOO_OLD == io_err)) (ERR_SQL_DB_TOO_OLD == io_err))
{ {
if (FALSE == show_session_error (io_err, newfile)) if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN))
{ {
/* user told us to create a new database. Do it. */ /* user told us to create a new database. Do it. */
qof_session_begin (new_session, newfile, FALSE, TRUE); qof_session_begin (new_session, newfile, FALSE, TRUE);
@ -669,7 +717,7 @@ gnc_post_file_open (const char * filename)
} }
else else
{ {
uh_oh = show_session_error (io_err, newfile); uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
} }
if (!uh_oh) if (!uh_oh)
@ -688,7 +736,7 @@ gnc_post_file_open (const char * filename)
/* check for i/o error, put up appropriate error dialog */ /* check for i/o error, put up appropriate error dialog */
io_err = qof_session_get_error (new_session); io_err = qof_session_get_error (new_session);
uh_oh = show_session_error (io_err, newfile); uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
new_group = gnc_book_get_group (qof_session_get_book (new_session)); new_group = gnc_book_get_group (qof_session_get_book (new_session));
if (uh_oh) new_group = NULL; if (uh_oh) new_group = NULL;
@ -697,7 +745,8 @@ gnc_post_file_open (const char * filename)
* The backend forgot to set an error. So make one up. */ * The backend forgot to set an error. So make one up. */
if (!uh_oh && !new_group) if (!uh_oh && !new_group)
{ {
uh_oh = show_session_error (ERR_BACKEND_MISC, newfile); uh_oh = show_session_error (ERR_BACKEND_MISC, newfile,
GNC_FILE_DIALOG_OPEN);
} }
} }
@ -754,7 +803,7 @@ gnc_file_open (void)
char *lastfile; char *lastfile;
gboolean result; gboolean result;
if (!gnc_file_query_save ()) if (!gnc_file_query_save (TRUE))
return FALSE; return FALSE;
lastfile = gnc_history_get_last(); lastfile = gnc_history_get_last();
@ -777,7 +826,7 @@ gnc_file_open_file (const char * newfile)
{ {
if (!newfile) return FALSE; if (!newfile) return FALSE;
if (!gnc_file_query_save ()) if (!gnc_file_query_save (TRUE))
return FALSE; return FALSE;
return gnc_post_file_open (newfile); return gnc_post_file_open (newfile);
@ -820,7 +869,7 @@ gnc_file_export_file(const char * newfile)
/* if file appears to be locked, ask the user ... */ /* if file appears to be locked, ask the user ... */
if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err) if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
{ {
if (FALSE == show_session_error (io_err, newfile)) if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_EXPORT))
{ {
/* user told us to ignore locks. So ignore them. */ /* user told us to ignore locks. So ignore them. */
qof_session_begin (new_session, newfile, TRUE, FALSE); qof_session_begin (new_session, newfile, TRUE, FALSE);
@ -901,7 +950,7 @@ gnc_file_save (void)
io_err = qof_session_get_error (session); io_err = qof_session_get_error (session);
if (ERR_BACKEND_NO_ERR != io_err) if (ERR_BACKEND_NO_ERR != io_err)
{ {
show_session_error (io_err, newfile); show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
if (been_here_before) return; if (been_here_before) return;
been_here_before = TRUE; been_here_before = TRUE;
@ -947,7 +996,8 @@ gnc_file_save_as (void)
newfile = xaccResolveURL (filename); newfile = xaccResolveURL (filename);
if (!newfile) if (!newfile)
{ {
show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename); show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename,
GNC_FILE_DIALOG_SAVE);
return; return;
} }
@ -970,7 +1020,7 @@ gnc_file_save_as (void)
/* if file appears to be locked, ask the user ... */ /* if file appears to be locked, ask the user ... */
if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err) if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
{ {
if (FALSE == show_session_error (io_err, newfile)) if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE))
{ {
/* user told us to ignore locks. So ignore them. */ /* user told us to ignore locks. So ignore them. */
qof_session_begin (new_session, newfile, TRUE, FALSE); qof_session_begin (new_session, newfile, TRUE, FALSE);
@ -981,7 +1031,7 @@ gnc_file_save_as (void)
else if ((ERR_BACKEND_NO_SUCH_DB == io_err) || else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
(ERR_SQL_DB_TOO_OLD == io_err)) (ERR_SQL_DB_TOO_OLD == io_err))
{ {
if (FALSE == show_session_error (io_err, newfile)) if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE))
{ {
/* user told us to create a new database. Do it. */ /* user told us to create a new database. Do it. */
qof_session_begin (new_session, newfile, FALSE, TRUE); qof_session_begin (new_session, newfile, FALSE, TRUE);
@ -995,7 +1045,7 @@ gnc_file_save_as (void)
io_err = qof_session_get_error (new_session); io_err = qof_session_get_error (new_session);
if (ERR_BACKEND_NO_ERR != io_err) if (ERR_BACKEND_NO_ERR != io_err)
{ {
show_session_error (io_err, newfile); show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
xaccLogDisable(); xaccLogDisable();
qof_session_destroy (new_session); qof_session_destroy (new_session);
xaccLogEnable(); xaccLogEnable();
@ -1066,12 +1116,6 @@ gnc_file_quit (void)
gnc_unset_busy_cursor (NULL); gnc_unset_busy_cursor (NULL);
} }
void
gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb)
{
can_cancel_cb = cb;
}
void void
gnc_file_set_shutdown_callback (GNCShutdownCB cb) gnc_file_set_shutdown_callback (GNCShutdownCB cb)
{ {

View File

@ -132,7 +132,9 @@ void gnc_file_save_as (void);
/** Tell the user about errors in the backends /** Tell the user about errors in the backends
*/ */
gboolean show_session_error (QofBackendError io_error, const char *newfile); gboolean show_session_error (QofBackendError io_error,
const char *newfile,
GNCFileDialogType type);
char * gnc_file_dialog (const char * title, char * gnc_file_dialog (const char * title,
const char * filter, const char * filter,
@ -142,13 +144,10 @@ char * gnc_file_dialog (const char * title,
gboolean gnc_file_open_file (const char *filename); gboolean gnc_file_open_file (const char *filename);
void gnc_file_export_file(const char * filename); void gnc_file_export_file(const char * filename);
gboolean gnc_file_query_save (void); gboolean gnc_file_query_save (gboolean can_cancel);
void gnc_file_quit (void); void gnc_file_quit (void);
typedef gboolean (*GNCCanCancelSaveCB) (void);
void gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb);
typedef void (*GNCShutdownCB) (int); typedef void (*GNCShutdownCB) (int);
void gnc_file_set_shutdown_callback (GNCShutdownCB cb); void gnc_file_set_shutdown_callback (GNCShutdownCB cb);

View File

@ -449,7 +449,7 @@ gnc_shutdown (int exit_status)
{ {
if (gnucash_ui_is_running()) { if (gnucash_ui_is_running()) {
if (!gnome_is_terminating) { if (!gnome_is_terminating) {
if (gnc_file_query_save()) { if (gnc_file_query_save(FALSE)) {
gnc_hook_run(HOOK_UI_SHUTDOWN, NULL); gnc_hook_run(HOOK_UI_SHUTDOWN, NULL);
gnc_gui_shutdown(); gnc_gui_shutdown();
} }

View File

@ -36,96 +36,6 @@
/* This static indicates the debugging module that this .o belongs to. */ /* This static indicates the debugging module that this .o belongs to. */
/* static short module = MOD_GUI; */ /* static short module = MOD_GUI; */
void gnc_remember_all_toggled (GtkToggleButton *togglebutton, gpointer user_data);
void
gnc_remember_all_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
GtkWidget *other_button;
gboolean active;
active = gtk_toggle_button_get_active(togglebutton);
other_button = gnc_glade_lookup_widget(GTK_WIDGET(togglebutton),
"remember_one");
gtk_widget_set_sensitive(other_button, !active);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(other_button), FALSE);
}
static gint
gnc_remember_common(gncUIWidget parent, const gchar *dialog_name,
const gchar *message, const gchar *gconf_key,
const gchar *first_button_text, ...)
{
GladeXML *xml;
GtkWidget *dialog, *label, *box, *checkbox;
gint response;
const gchar *text;
va_list args;
/* Does the user want to see this question? If not, return the
* previous answer. */
response = gnc_gconf_get_int(GCONF_WARNINGS_PERM, gconf_key, NULL);
if (response != 0)
return response;
response = gnc_gconf_get_int(GCONF_WARNINGS_TEMP, gconf_key, NULL);
if (response != 0)
return response;
/* Find the glade page layout */
xml = gnc_glade_xml_new ("gnc-gui-query.glade", dialog_name);
dialog = glade_xml_get_widget (xml, dialog_name);
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
dialog);
/* Insert the message. */
label = glade_xml_get_widget (xml, "label");
gtk_label_set_markup(GTK_LABEL(label), message);
/* Hide the checkboxes if there's no key */
box = glade_xml_get_widget (xml, "remember_vbox");
if (gconf_key == NULL)
gtk_widget_hide(box);
/* Set the buttons */
va_start(args, first_button_text);
for (text = first_button_text; text != NULL; ) {
response = va_arg(args, gint);
gtk_dialog_add_button(GTK_DIALOG(dialog), text, response);
text = va_arg(args, gchar *);
}
va_end(args);
// gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
/* Tell the window manager if there's a parent window. */
if (parent)
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW (parent));
/* Get a response */
response = gtk_dialog_run(GTK_DIALOG(dialog));
if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT)) {
gtk_widget_destroy(GTK_WIDGET(dialog));
return GTK_RESPONSE_NO;
}
/* Save the answer? */
checkbox = glade_xml_get_widget (xml, "remember_all");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox))) {
gnc_gconf_set_int(GCONF_WARNINGS_PERM, gconf_key, response, NULL);
} else {
checkbox = glade_xml_get_widget (xml, "remember_one");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox))) {
gnc_gconf_set_int(GCONF_WARNINGS_TEMP, gconf_key, response, NULL);
}
}
gtk_widget_destroy(GTK_WIDGET(dialog));
return response;
}
/********************************************************************\ /********************************************************************\
* gnc_ok_cancel_dialog * * gnc_ok_cancel_dialog *
* display a message, and asks the user to press "Ok" or "Cancel" * * display a message, and asks the user to press "Ok" or "Cancel" *
@ -173,59 +83,6 @@ gnc_ok_cancel_dialog(gncUIWidget parent,
/********************************************************************\
* gnc_verify_cancel_dialog *
* display a message, and asks the user to press "Yes", "No", or *
* "Cancel" *
* *
* NOTE: This function does not return until the dialog is closed *
* *
* Args: parent - the parent window *
* default - the button that will be the default *
* format - the format string for the message to display *
* This is a standard 'printf' style string. *
* args - a pointer to the first argument for the format *
* string. *
* Return: the result the user selected *
\********************************************************************/
gint
gnc_verify_cancel_dialog(GtkWidget *parent,
gint default_result,
const gchar *format, ...)
{
GtkWidget *dialog;
gint result;
gchar *buffer;
va_list args;
if (parent == NULL)
parent = gnc_ui_get_toplevel();
va_start(args, format);
buffer = g_strdup_vprintf(format, args);
dialog = gtk_message_dialog_new (GTK_WINDOW(parent),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s",
buffer);
g_free(buffer);
va_end(args);
gtk_dialog_add_buttons (GTK_DIALOG(dialog),
GTK_STOCK_YES, GTK_RESPONSE_YES,
GTK_STOCK_NO, GTK_RESPONSE_NO,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_result);
result = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
return(result);
}
/********************************************************************\ /********************************************************************\
* gnc_verify_dialog * * gnc_verify_dialog *
* display a message, and asks the user to press "Yes" or "No" * * display a message, and asks the user to press "Yes" or "No" *
@ -271,27 +128,6 @@ gnc_verify_dialog(gncUIWidget parent, gboolean yes_is_default,
} }
gint
gnc_verify_remember_dialog(gncUIWidget parent, const gchar *gconf_key,
const gchar *yes_label, const gchar *no_label,
const gchar *format, ...)
{
gchar *buffer;
gint response;
va_list args;
va_start(args, format);
buffer = g_strdup_vprintf(format, args);
response = gnc_remember_common(parent, "Question Dialog", buffer, gconf_key,
yes_label, GTK_RESPONSE_YES,
no_label, GTK_RESPONSE_NO,
NULL);
g_free(buffer);
va_end(args);
return response;
}
/********************************************************************\ /********************************************************************\
* gnc_info_dialog * * gnc_info_dialog *
* displays an information dialog box * * displays an information dialog box *
@ -362,12 +198,6 @@ gnc_warning_dialog_common(GtkWidget *parent, const gchar *format, va_list args)
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }
void
gnc_warning_dialog_va(const gchar *format, va_list args)
{
gnc_warning_dialog_common(NULL, format, args);
}
void void
gnc_warning_dialog(GtkWidget *parent, const gchar *format, ...) gnc_warning_dialog(GtkWidget *parent, const gchar *format, ...)
{ {
@ -379,28 +209,6 @@ gnc_warning_dialog(GtkWidget *parent, const gchar *format, ...)
} }
gint
gnc_warning_remember_dialog(gncUIWidget parent, const gchar *gconf_key,
const gchar *yes_label, const gchar *no_label,
const gchar *format, ...)
{
gchar *buffer;
gint response;
va_list args;
va_start(args, format);
buffer = g_strdup_vprintf(format, args);
response = gnc_remember_common(parent, "Warning Dialog", buffer, gconf_key,
yes_label, GTK_RESPONSE_YES,
no_label, GTK_RESPONSE_NO,
NULL);
g_free(buffer);
va_end(args);
return response;
}
/********************************************************************\ /********************************************************************\
* gnc_error_dialog_common * * gnc_error_dialog_common *
* displays an error dialog box * * displays an error dialog box *
@ -434,12 +242,6 @@ gnc_error_dialog_common(GtkWidget *parent, const gchar *format, va_list args)
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }
void
gnc_error_dialog_va(const gchar *format, va_list args)
{
gnc_error_dialog_common(NULL, format, args);
}
void void
gnc_error_dialog(GtkWidget *parent, const gchar *format, ...) gnc_error_dialog(GtkWidget *parent, const gchar *format, ...)
{ {

View File

@ -28,13 +28,6 @@ gnc_info_dialog(GtkWidget *parent,
const char *format, ...) G_GNUC_PRINTF (2, 3); const char *format, ...) G_GNUC_PRINTF (2, 3);
extern void
gnc_warning_dialog_va(const char *format, va_list args);
extern void
gnc_error_dialog_va(const char *format, va_list args);
extern void extern void
gnc_error_dialog(GtkWidget *parent, gnc_error_dialog(GtkWidget *parent,
const char *format, ...) G_GNUC_PRINTF (2, 3); const char *format, ...) G_GNUC_PRINTF (2, 3);

View File

@ -839,13 +839,16 @@ gnc_main_window_prompt_for_save (GtkWidget *window)
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
_("<b>Save changes to file %s before " _("<b>Save changes to file %s before "
"closing?</b>\n\nIf you don't save, " "closing?</b>\n\nChanges have been "
"changes will be discarded."), "made since the last time it was "
"saved. If you continue without "
"saving these changes will be "
"discarded."),
filename); filename);
#endif #endif
gtk_dialog_add_buttons(GTK_DIALOG(dialog), gtk_dialog_add_buttons(GTK_DIALOG(dialog),
_("Close _without Saving"), GTK_RESPONSE_CLOSE, _("Close _Without Saving"), GTK_RESPONSE_CLOSE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_APPLY, GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,
NULL); NULL);

View File

@ -17,7 +17,6 @@
#include "dialog-options.h" #include "dialog-options.h"
#include "gnc-html.h" #include "gnc-html.h"
#include "qof.h" #include "qof.h"
#include "gnc-err-popup.h"
#include "gnc-gui-query.h" #include "gnc-gui-query.h"
#include "gnc-druid-gnome.h" #include "gnc-druid-gnome.h"
@ -96,15 +95,11 @@ libgncmod_gnome_utils_LTX_gnc_module_init(int refcount) {
gnc_druid_provider_multifile_gnome_register(); gnc_druid_provider_multifile_gnome_register();
} }
gnc_set_warning_message(gnc_warning_dialog_va);
gnc_set_error_message(gnc_error_dialog_va);
return TRUE; return TRUE;
} }
int int
libgncmod_gnome_utils_LTX_gnc_module_end(int refcount) libgncmod_gnome_utils_LTX_gnc_module_end(int refcount)
{ {
gnc_set_warning_message(NULL);
gnc_set_error_message(NULL);
return TRUE; return TRUE;
} }

View File

@ -429,15 +429,6 @@ be left empty")
((<gw:mchars> caller-owned) name)) ((<gw:mchars> caller-owned) name))
"Get a boolean value from gconf.") "Get a boolean value from gconf.")
(gw:wrap-function
ws
'gnc:file-query-save
'<gw:bool>
"gnc_file_query_save"
'()
"Query the user whether to save the current file, and save
if they say 'Yes'. The return is false if the user says 'Cancel'.")
(gw:wrap-function (gw:wrap-function
ws ws
'gnc:file-quit 'gnc:file-quit

View File

@ -256,7 +256,8 @@ on_dateok_clicked (chart_data *data)
qof_object_foreach(GNC_ID_SPLIT, book, chart_reference_cb, data); qof_object_foreach(GNC_ID_SPLIT, book, chart_reference_cb, data);
g_list_free(data->param_ref_list); g_list_free(data->param_ref_list);
qof_session_save(chart_session, NULL); qof_session_save(chart_session, NULL);
show_session_error(qof_session_get_error(chart_session), filename); show_session_error(qof_session_get_error(chart_session),
filename, GNC_FILE_DIALOG_EXPORT);
gnc_engine_resume_events(); gnc_engine_resume_events();
gnc_unset_busy_cursor(NULL); gnc_unset_busy_cursor(NULL);
} }

View File

@ -96,6 +96,9 @@ remove_clicked (CommoditiesDialog *cd)
gboolean do_delete; gboolean do_delete;
gboolean can_delete; gboolean can_delete;
gnc_commodity *commodity; gnc_commodity *commodity;
GtkWidget *dialog;
const gchar *message, *warning;
gint response;
commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree); commodity = gnc_tree_view_commodity_get_selected_commodity (cd->commodity_tree);
if (commodity == NULL) if (commodity == NULL)
@ -134,21 +137,31 @@ remove_clicked (CommoditiesDialog *cd)
prices = gnc_pricedb_get_prices(pdb, commodity, NULL); prices = gnc_pricedb_get_prices(pdb, commodity, NULL);
if (prices) if (prices)
{ {
const char *message = _("This commodity has price quotes. Are\n" message = _("This commodity has price quotes. Are "
"you sure you want to delete the selected\n" "you sure you want to delete the selected "
"commodity and its price quotes?"); "commodity and its price quotes?");
warning = "delete_commodity2";
do_delete = gnc_verify_dialog (cd->dialog, TRUE, message); } else {
} message = _("Are you sure you want to delete the "
else "selected commodity?");
{ warning = "delete_commodity";
const char *message = _("Are you sure you want to delete the\n"
"selected commodity?");
do_delete = gnc_verify_dialog (cd->dialog, TRUE, message);
} }
if (do_delete) dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(cd->dialog),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s",
_("Delete commodity?"),
message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_DELETE, GTK_RESPONSE_OK,
(gchar *)NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), warning);
gtk_widget_destroy(dialog);
if (response == GTK_RESPONSE_OK)
{ {
gnc_commodity_table *ct; gnc_commodity_table *ct;

View File

@ -37,6 +37,7 @@
#include "gnc-currency-edit.h" #include "gnc-currency-edit.h"
#include "gnc-date-edit.h" #include "gnc-date-edit.h"
#include "gnc-engine.h" #include "gnc-engine.h"
#include "gnc-gui-query.h"
#include "gnc-pricedb.h" #include "gnc-pricedb.h"
#include "gnc-tree-view-price.h" #include "gnc-tree-view-price.h"
#include "gnc-ui.h" #include "gnc-ui.h"
@ -146,7 +147,8 @@ gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data)
{ {
PricesDialog *pdb_dialog = data; PricesDialog *pdb_dialog = data;
GList *price_list; GList *price_list;
gint length; gint length, response;
GtkWidget *dialog;
ENTER(" "); ENTER(" ");
price_list = gnc_tree_view_price_get_selected_prices(pdb_dialog->price_tree); price_list = gnc_tree_view_price_get_selected_prices(pdb_dialog->price_tree);
@ -156,15 +158,37 @@ gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data)
} }
length = g_list_length(price_list); length = g_list_length(price_list);
if (gnc_verify_dialog (pdb_dialog->dialog, TRUE, if (length > 1) {
/* Translators: %d is the number of prices. This is a gchar *message;
ngettext(3) message. */
ngettext("Are you sure you want to delete the %d " message = g_strdup_printf
"selected price?", (/* Translators: %d is the number of prices. This
"Are you sure you want to delete the %d " is a ngettext(3) message. */
"selected prices?", length), ngettext("Are you sure you want to delete the selected price?",
length)) "Are you sure you want to delete the %d selected prices?",
{ length),
length);
dialog = gtk_message_dialog_new_with_markup
(GTK_WINDOW(pdb_dialog->dialog),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s",
_("Delete prices?"),
message);
g_free(message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_DELETE, GTK_RESPONSE_YES,
(gchar *)NULL);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
response = gnc_dialog_run(GTK_DIALOG(dialog), "pricedb_remove_multiple");
gtk_widget_destroy(dialog);
} else {
response = GTK_RESPONSE_YES;
}
if (response == GTK_RESPONSE_YES) {
GNCBook *book = gnc_get_current_book (); GNCBook *book = gnc_get_current_book ();
GNCPriceDB *pdb = gnc_book_get_pricedb (book); GNCPriceDB *pdb = gnc_book_get_pricedb (book);

View File

@ -44,7 +44,6 @@
#include "gnc-component-manager.h" #include "gnc-component-manager.h"
#include "gnc-date-edit.h" #include "gnc-date-edit.h"
#include "gnc-engine.h" #include "gnc-engine.h"
#include "gnc-err-popup.h"
#include "gnc-euro.h" #include "gnc-euro.h"
#include "gnc-gconf-utils.h" #include "gnc-gconf-utils.h"
#include "gnc-gui-query.h" #include "gnc-gui-query.h"
@ -702,30 +701,48 @@ gnc_split_reg_ld_destroy( GNCLedgerDisplay *ledger )
gboolean gboolean
gnc_split_reg_check_close( GNCSplitReg *gsr ) gnc_split_reg_check_close( GNCSplitReg *gsr )
{ {
gint result; GtkWidget *dialog;
gint response;
gboolean pending_changes; gboolean pending_changes;
SplitRegister *reg; SplitRegister *reg;
const char *message = _("The current transaction has been changed.\n" const char *title = _("Save transaction before closing?");
"Would you like to record it?"); const char *message =
_("The current transaction has been changed. Would you like to "
"record the changes before closing this page, close the page "
"without recording the changes, or cancel the close?");
reg = gnc_ledger_display_get_split_register( gsr->ledger ); reg = gnc_ledger_display_get_split_register( gsr->ledger );
pending_changes = gnc_split_register_changed( reg ); pending_changes = gnc_split_register_changed( reg );
if ( !pending_changes ) if ( !pending_changes )
return TRUE; return TRUE;
result = gnc_verify_cancel_dialog(gsr->window, GTK_RESPONSE_YES, message); dialog = gtk_message_dialog_new(GTK_WINDOW(gsr->window),
switch (result) GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
_("_Don't Record"), GTK_RESPONSE_REJECT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Record"), GTK_RESPONSE_ACCEPT,
NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_changed");
gtk_widget_destroy(dialog);
switch (response)
{ {
case GTK_RESPONSE_YES: case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_OK:
gnc_split_reg_record_trans_cb( gsr->window, gsr ); gnc_split_reg_record_trans_cb( gsr->window, gsr );
return TRUE; return TRUE;
case GTK_RESPONSE_NO: case GTK_RESPONSE_REJECT:
gnc_split_register_cancel_cursor_trans_changes( reg ); gnc_split_register_cancel_cursor_trans_changes( reg );
return TRUE; return TRUE;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
default:
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -931,15 +948,24 @@ gnc_split_reg_reverse_trans_cb (GtkWidget *w, gpointer data)
static gboolean static gboolean
xaccTransWarnReadOnly (const Transaction *trans) xaccTransWarnReadOnly (const Transaction *trans)
{ {
GtkWidget *dialog;
const gchar *reason; const gchar *reason;
const gchar *format =
_("Cannot modify or delete this transaction. This transaction is "
"marked read-only because:\n\n'%s'");
if (!trans) return FALSE; if (!trans) return FALSE;
reason = xaccTransGetReadOnly (trans); reason = xaccTransGetReadOnly (trans);
if (reason) { if (reason) {
gnc_send_gui_error(_("Cannot modify or delete this transaction.\n" dialog = gtk_message_dialog_new(NULL,
"This transaction is marked read-only because:\n\n'%s'"), 0,
reason); GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
format,
reason);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -954,7 +980,8 @@ gsr_default_reinit_handler( GNCSplitReg *gsr, gpointer data )
Transaction *trans; Transaction *trans;
Split *split; Split *split;
GtkWidget *dialog; GtkWidget *dialog;
gint result; gint response;
const gchar *warning;
const char *message = _("Remove the splits from this transaction?"); const char *message = _("Remove the splits from this transaction?");
const char *recn_warn = _("This transaction contains reconciled splits. " const char *recn_warn = _("This transaction contains reconciled splits. "
@ -975,6 +1002,7 @@ gsr_default_reinit_handler( GNCSplitReg *gsr, gpointer data )
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s", "<b>%s</b>\n\n%s",
message, recn_warn); message, recn_warn);
warning = "register_remove_all_splits2";
} else { } else {
dialog = dialog =
gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window), gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
@ -983,15 +1011,16 @@ gsr_default_reinit_handler( GNCSplitReg *gsr, gpointer data )
GTK_MESSAGE_QUESTION, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>", message); "<b>%s</b>", message);
warning = "register_remove_all_splits";
} }
gtk_dialog_add_button(GTK_DIALOG(dialog), gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, N_("_Remove Splits"), gnc_gtk_dialog_add_button(dialog, N_("_Remove Splits"),
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT); GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog)); response = gnc_dialog_run(GTK_DIALOG(dialog), warning);
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT) if (response != GTK_RESPONSE_ACCEPT)
return; return;
/* /*
@ -1025,7 +1054,8 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
Transaction *trans; Transaction *trans;
Split *split; Split *split;
GtkWidget *dialog; GtkWidget *dialog;
gint result; gint response;
const gchar *warning;
reg = gnc_ledger_display_get_split_register( gsr->ledger ); reg = gnc_ledger_display_get_split_register( gsr->ledger );
@ -1110,6 +1140,7 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s", buf, recn_warn); "<b>%s</b>\n\n%s", buf, recn_warn);
warning = "register_delete_split2";
} else { } else {
dialog = dialog =
gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window), gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
@ -1118,6 +1149,7 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
GTK_MESSAGE_QUESTION, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>", buf); "<b>%s</b>", buf);
warning = "register_delete_split";
} }
g_free(buf); g_free(buf);
@ -1125,9 +1157,9 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, _("_Delete Split"), gnc_gtk_dialog_add_button(dialog, _("_Delete Split"),
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT); GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog)); response = gnc_dialog_run(GTK_DIALOG(dialog), warning);
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT) if (response != GTK_RESPONSE_ACCEPT)
return; return;
gnc_split_register_delete_current_split (reg); gnc_split_register_delete_current_split (reg);
@ -1153,6 +1185,7 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
GTK_MESSAGE_WARNING, GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>\n\n%s", message, recn_warn); "<b>%s</b>\n\n%s", message, recn_warn);
warning = "register_delete_trans2";
} else { } else {
dialog = dialog =
gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window), gtk_message_dialog_new_with_markup(GTK_WINDOW(gsr->window),
@ -1161,14 +1194,15 @@ gsr_default_delete_handler( GNCSplitReg *gsr, gpointer data )
GTK_MESSAGE_QUESTION, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
"<b>%s</b>", message); "<b>%s</b>", message);
warning = "register_delete_trans";
} }
gtk_dialog_add_button(GTK_DIALOG(dialog), gtk_dialog_add_button(GTK_DIALOG(dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gnc_gtk_dialog_add_button(dialog, _("_Delete Transaction"), gnc_gtk_dialog_add_button(dialog, _("_Delete Transaction"),
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT); GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
result = gtk_dialog_run(GTK_DIALOG(dialog)); response = gnc_dialog_run(GTK_DIALOG(dialog), warning);
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
if (result != GTK_RESPONSE_ACCEPT) if (response != GTK_RESPONSE_ACCEPT)
return; return;
gnc_split_register_delete_current_trans (reg); gnc_split_register_delete_current_trans (reg);
@ -1908,7 +1942,7 @@ gtk_callback_bug_workaround (gpointer argp)
"<b>%s</b>\n\n%s", "<b>%s</b>\n\n%s",
read_only, read_only,
args->string); args->string);
gtk_dialog_run(GTK_DIALOG(dialog)); gnc_dialog_run(GTK_DIALOG(dialog), "register_read_only");
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
g_free(args); g_free(args);
return FALSE; return FALSE;

View File

@ -37,5 +37,233 @@
</locale> </locale>
</schema> </schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_read_only</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_read_only</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_read_only</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Read only register.</short>
<long>
This dialog is presented when a read-only register is opened.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_delete_trans</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_delete_trans</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_delete_trans</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Delete a transaction.</short>
<long>
This dialog is presented before allowing you to delete a transaction.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_delete_trans2</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_delete_trans2</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_delete_trans2</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Delete a transaction.</short>
<long>
This dialog is presented before allowing you to delete a
transaction that contains reconciled splits. Doing so will
throw off the reconciled value of the register and can make
it hard to perform future reconciliations.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_delete_split</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_delete_split</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_delete_split</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Remove a splits from a transaction.</short>
<long>
This dialog is presented before allowing you to remove a
splits from a transaction.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_delete_split2</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_delete_split2</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_delete_split2</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Remove a splits from a transaction.</short>
<long>
This dialog is presented before allowing you to remove a
reconciled splits from a transaction. Doing so will throw
off the reconciled value of the register and can make it
hard to perform future reconciliations.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_remove_all_splits</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_remove_all_splits</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_remove_all_splits</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Remove all the splits from a transaction.</short>
<long>
This dialog is presented before allowing you to remove all
splits from a transaction.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/register_remove_all_splits2</key>
<applyto>/apps/gnucash/general/warnings/permanent/register_remove_all_splits2</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/register_remove_all_splits2</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Remove all the splits from a transaction.</short>
<long>
This dialog is presented before allowing you to remove all
splits (including some reconciled splits) from a transaction.
Doing so will throw off the reconciled value of the register
and can make it hard to perform future reconciliations.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/transaction_changed</key>
<applyto>/apps/gnucash/general/warnings/permanent/transaction_changed</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/transaction_changed</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Commit changes to a transaction.</short>
<long>
This dialog is presented when you attempt to move out of a modified
transaction. The changed data must be either saved or discarded.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/transaction_duplicated</key>
<applyto>/apps/gnucash/general/warnings/permanent/transaction_duplicated</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/transaction_duplicated</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Duplicating a changed transaction.</short>
<long>
This dialog is presented when you attempt to duplicate a modified
transaction. The changed data must be saved or the duplication canceled.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/invoice_entry_changed</key>
<applyto>/apps/gnucash/general/warnings/permanent/invoice_entry_changed</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/invoice_entry_changed</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Commit changes to a invoice_entry.</short>
<long>
This dialog is presented when you attempt to move out of a modified
invoice entry. The changed data must be either saved or discarded.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/invoice_entry_duplicated</key>
<applyto>/apps/gnucash/general/warnings/permanent/invoice_entry_duplicated</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/invoice_entry_duplicated</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Duplicating a changed invoice_entry.</short>
<long>
This dialog is presented when you attempt to duplicate a modified
invoice entry. The changed data must be saved or the duplication canceled.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/delete_commodity</key>
<applyto>/apps/gnucash/general/warnings/permanent/delete_commodity</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/delete_commodity</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Delete a commodity.</short>
<long>
This dialog is presented before allowing you to delete a commodity.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/delete_commodity2</key>
<applyto>/apps/gnucash/general/warnings/permanent/delete_commodity2</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/delete_commodity2</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Delete a commodity and prices.</short>
<long>
This dialog is presented before allowing you to delete a commodity
that has price quotes attached. Deleting the commodity will delete
the quotes as well.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/warnings/pricedb_remove_multiple</key>
<applyto>/apps/gnucash/general/warnings/permanent/pricedb_remove_multiple</applyto>
<applyto>/apps/gnucash/general/warnings/temporary/pricedb_remove_multiple</applyto>
<owner>gnucash</owner>
<type>int</type>
<default>0</default>
<locale name="C">
<short>Delete multiple price quotes.</short>
<long>
This dialog is presented before allowing you to delete multiple price
quotes at one time.
</long>
</locale>
</schema>
</schemalist> </schemalist>
</gconfschemafile> </gconfschemafile>

View File

@ -142,7 +142,7 @@ gnc_hbci_get_initial_password (GtkWidget *parent,
/* strings didn't match */ /* strings didn't match */
if (gnc_ok_cancel_dialog (parent, GTK_RESPONSE_OK, if (gnc_ok_cancel_dialog (parent, GTK_RESPONSE_OK,
_("The two passwords didn't match. \n" _("The two passwords didn't match. "
"Please try again.")) "Please try again."))
!= GTK_RESPONSE_OK) != GTK_RESPONSE_OK)
break; break;

View File

@ -32,11 +32,12 @@
#include "gnc-ui.h" #include "gnc-ui.h"
#include "pricecell.h" #include "pricecell.h"
#include "datecell.h" #include "datecell.h"
#include "dialog-transfer.h"
#include "dialog-utils.h"
#include "split-register-control.h" #include "split-register-control.h"
#include "split-register-model-save.h" #include "split-register-model-save.h"
#include "split-register-p.h" #include "split-register-p.h"
#include "table-allgui.h" #include "table-allgui.h"
#include "dialog-transfer.h"
/* This static indicates the debugging module that this .o belongs to. */ /* This static indicates the debugging module that this .o belongs to. */
@ -1252,7 +1253,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
Transaction *pending_trans; Transaction *pending_trans;
VirtualLocation virt_loc; VirtualLocation virt_loc;
Transaction *trans, *new_trans; Transaction *trans, *new_trans;
gint result; gint response;
gboolean changed; gboolean changed;
SRInfo *info; SRInfo *info;
Split *split; Split *split;
@ -1468,22 +1469,36 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
/* Ok, we are changing transactions and the current transaction has /* Ok, we are changing transactions and the current transaction has
* changed. See what the user wants to do. */ * changed. See what the user wants to do. */
{ {
const char *message; GtkWidget *dialog, *window;
const char *title = _("Save the current transaction?");
const char *message =
_("The current transaction has been changed. Would you like to "
"record the changes before moving to a new transaction, move "
"without recording the changes, or cancel the move?");
message = _("The current transaction has been changed.\n" window = gnc_split_register_get_parent(reg);
"Would you like to record it?"); dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
result = gnc_verify_cancel_dialog GTK_MESSAGE_QUESTION,
(gnc_split_register_get_parent (reg), GTK_BUTTONS_NONE,
GTK_RESPONSE_YES, message); "%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
_("_Don't Record"), GTK_RESPONSE_REJECT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Record"), GTK_RESPONSE_ACCEPT,
NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_changed");
gtk_widget_destroy(dialog);
} }
switch (result) switch (response)
{ {
case GTK_RESPONSE_YES: case GTK_RESPONSE_ACCEPT:
break; break;
case GTK_RESPONSE_NO: case GTK_RESPONSE_REJECT:
{ {
VirtualCellLocation vcell_loc; VirtualCellLocation vcell_loc;
Split *new_split; Split *new_split;
@ -1512,10 +1527,8 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
return TRUE;
default: default:
break; return TRUE;
} }
return FALSE; return FALSE;
@ -1538,6 +1551,7 @@ gboolean
gnc_split_register_recn_cell_confirm (char old_flag, gpointer data) gnc_split_register_recn_cell_confirm (char old_flag, gpointer data)
{ {
SplitRegister *reg = data; SplitRegister *reg = data;
GtkWidget *dialog, *window;
gint response; gint response;
const gchar *title = _("Mark split as unreconciled?"); const gchar *title = _("Mark split as unreconciled?");
const gchar *message = const gchar *message =
@ -1549,11 +1563,17 @@ gnc_split_register_recn_cell_confirm (char old_flag, gpointer data)
return TRUE; return TRUE;
/* Does the user want to be warned? */ /* Does the user want to be warned? */
response = gnc_warning_remember_dialog(gnc_split_register_get_parent(reg), window = gnc_split_register_get_parent(reg);
"mark_split_unreconciled", dialog =
"_Unreconcile", GTK_STOCK_CANCEL, gtk_message_dialog_new_with_markup(GTK_WINDOW(window),
"<b>%s</b>\n\n%s\n", GTK_DIALOG_DESTROY_WITH_PARENT,
title, message); GTK_MESSAGE_WARNING,
GTK_BUTTONS_CANCEL,
"%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Unreconcile"), GTK_RESPONSE_YES);
response = gnc_dialog_run(GTK_DIALOG(dialog), "mark_split_unreconciled");
gtk_widget_destroy(dialog);
return (response == GTK_RESPONSE_YES); return (response == GTK_RESPONSE_YES);
} }

View File

@ -27,9 +27,9 @@
#include "Group.h" #include "Group.h"
#include "datecell.h" #include "datecell.h"
#include "dialog-utils.h"
#include "gnc-engine.h" #include "gnc-engine.h"
#include "gnc-gconf-utils.h" #include "gnc-gconf-utils.h"
#include "gnc-err-popup.h"
#include "gnc-ui.h" #include "gnc-ui.h"
#include "pricecell.h" #include "pricecell.h"
#include "recncell.h" #include "recncell.h"
@ -1783,15 +1783,24 @@ gnc_split_register_get_security_io_flags (VirtualLocation virt_loc,
static gboolean static gboolean
xaccTransWarnReadOnly (const Transaction *trans) xaccTransWarnReadOnly (const Transaction *trans)
{ {
GtkWidget *dialog;
const gchar *reason; const gchar *reason;
const gchar *format =
_("Cannot modify or delete this transaction. This transaction is "
"marked read-only because:\n\n'%s'");
if (!trans) return FALSE; if (!trans) return FALSE;
reason = xaccTransGetReadOnly (trans); reason = xaccTransGetReadOnly (trans);
if (reason) { if (reason) {
gnc_send_gui_error(_("Cannot modify or delete this transaction.\n" dialog = gtk_message_dialog_new(NULL,
"This transaction is marked read-only because:\n\n'%s'"), 0,
reason); GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
format,
reason);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -1827,17 +1836,25 @@ gnc_split_register_confirm (VirtualLocation virt_loc, gpointer user_data)
if (recn == YREC) if (recn == YREC)
{ {
GtkWidget *dialog, *window;
gint response; gint response;
const gchar *title = _("Change reconciled split?");
const gchar *message = _("You are about to change a reconciled split. Doing so might make "
"future reconciliation difficult! Continue with this change?");
/* Does the user want to be warned? */ /* Does the user want to be warned? */
response = gnc_warning_remember_dialog(gnc_split_register_get_parent(reg), window = gnc_split_register_get_parent(reg);
"change_reconciled_split", dialog =
_("Change _Split"), GTK_STOCK_CANCEL, gtk_message_dialog_new_with_markup(GTK_WINDOW(window),
"<b>%s</b>\n\n%s\n", GTK_DIALOG_DESTROY_WITH_PARENT,
_("Change reconciled split?"), GTK_MESSAGE_WARNING,
_("You are about to change a reconciled split. Doing so might make " GTK_BUTTONS_CANCEL,
"future reconciliation difficult! Continue with this change?")); "%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_button(GTK_DIALOG(dialog), _("Change _Split"), GTK_RESPONSE_YES);
response = gnc_dialog_run(GTK_DIALOG(dialog), "change_reconciled_split");
gtk_widget_destroy(dialog);
if (response != GTK_RESPONSE_YES) if (response != GTK_RESPONSE_YES)
return FALSE; return FALSE;

View File

@ -32,6 +32,7 @@
#include "combocell.h" #include "combocell.h"
#include "datecell.h" #include "datecell.h"
#include "dialog-utils.h"
#include "gnc-component-manager.h" #include "gnc-component-manager.h"
#include "gnc-gconf-utils.h" #include "gnc-gconf-utils.h"
#include "split-register-p.h" #include "split-register-p.h"
@ -414,15 +415,28 @@ gnc_split_register_duplicate_current (SplitRegister *reg)
* it before we can duplicate. Make sure the user wants to do that. */ * it before we can duplicate. Make sure the user wants to do that. */
if (changed) if (changed)
{ {
const char *message = _("The current transaction has been changed.\n" GtkWidget *dialog, *window;
"Would you like to record it?"); gint response;
gint result; const char *title = _("Save transaction before duplicating?");
const char *message =
_("The current transaction has been changed. Would you like to "
"record the changes before duplicating the transaction, or "
"cancel the duplication?");
result = gnc_ok_cancel_dialog window = gnc_split_register_get_parent(reg);
(gnc_split_register_get_parent (reg), dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_RESPONSE_OK, message); GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_CANCEL,
"%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s", message);
gtk_dialog_add_button(GTK_DIALOG(dialog),
_("_Record"), GTK_RESPONSE_ACCEPT);
response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_duplicated");
gtk_widget_destroy(dialog);
if (result != GTK_RESPONSE_OK) if (response != GTK_RESPONSE_ACCEPT)
{ {
gnc_resume_gui_refresh (); gnc_resume_gui_refresh ();
return NULL; return NULL;