mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add a Quit option to the "File Locked" message.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7241 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3121daecdf
commit
d15de598e8
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2002-09-25 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome-utils/gnc-gui-query.c: Add routines to put up the
|
||||
various question/warning/error dialogs with a variable number of
|
||||
buttons.
|
||||
|
||||
* src/app-file/gnc-file.c (gnc_file_set_shutdown_callback): Add a
|
||||
callback so the gnome specific code can call the "top level"
|
||||
shutdown function. (gnc_post_file_open): Rework the "file locked"
|
||||
query to include a "Quit" option.
|
||||
|
||||
2002-09-25 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-actions.c: Distinguish
|
||||
|
@ -51,6 +51,7 @@ static short module = MOD_GUI;
|
||||
|
||||
static GNCSession * current_session = NULL;
|
||||
static GNCCanCancelSaveCB can_cancel_cb = NULL;
|
||||
static GNCShutdownCB shutdown_cb = NULL;
|
||||
|
||||
static GNCHistoryAddFileFunc history_add_file_func = NULL;
|
||||
static GNCHistoryGetLastFunc history_get_last_func = NULL;
|
||||
@ -389,7 +390,28 @@ gnc_post_file_open (const char * filename)
|
||||
/* if file appears to be locked, ask the user ... */
|
||||
if (ERR_BACKEND_LOCKED == io_err)
|
||||
{
|
||||
if (FALSE == show_session_error (io_err, newfile))
|
||||
const char *buttons[] = { N_("Quit Gnucash"), N_("Open Anyway"),
|
||||
N_("Don't Open"), NULL };
|
||||
char *fmt = _("GnuCash could not obtain the lock for\n"
|
||||
" %s.\n"
|
||||
"That database may be in use by another user,\n"
|
||||
"in which case you should not open the database.\n"
|
||||
"\nWhat would you like to do?");
|
||||
int rc;
|
||||
|
||||
if (shutdown_cb) {
|
||||
rc = gnc_generic_question_dialog (buttons, fmt, newfile);
|
||||
} else {
|
||||
rc = gnc_generic_question_dialog (buttons+1, fmt, newfile)+1;
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
if (shutdown_cb)
|
||||
shutdown_cb(0);
|
||||
g_assert(1);
|
||||
}
|
||||
else if (rc == 1)
|
||||
{
|
||||
/* user told us to ignore locks. So ignore them. */
|
||||
gnc_session_begin (new_session, newfile, TRUE, FALSE);
|
||||
@ -822,3 +844,9 @@ gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb)
|
||||
{
|
||||
can_cancel_cb = cb;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_file_set_shutdown_callback (GNCShutdownCB cb)
|
||||
{
|
||||
shutdown_cb = cb;
|
||||
}
|
||||
|
@ -137,4 +137,7 @@ void gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb);
|
||||
typedef void (*GNCFilePercentageFunc) (const char *message, int percent);
|
||||
void gnc_file_set_pct_handler (GNCFilePercentageFunc file_percentage_func);
|
||||
|
||||
typedef void (*GNCShutdownCB) (int);
|
||||
void gnc_file_set_shutdown_callback (GNCShutdownCB cb);
|
||||
|
||||
#endif /* GNC_FILE_H */
|
||||
|
@ -438,6 +438,92 @@ gnc_error_dialog_parented(GtkWindow *parent, const gchar *format, ...)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_generic_dialog_common *
|
||||
* display a message, and asks the user to choose from a *
|
||||
* number of selections. *
|
||||
* *
|
||||
* NOTE: This function does not return until the dialog is closed *
|
||||
* *
|
||||
* Args: parent - the parent window *
|
||||
* type - type of dialog to display (use gnome constants) *
|
||||
* buttons - Names of the buttons to display *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
#define MAX_BUTTONS 5
|
||||
static int
|
||||
gnc_generic_dialog_common(gncUIWidget parent, const char *type,
|
||||
const char **buttons_in,
|
||||
const gchar *format, va_list args)
|
||||
{
|
||||
GtkWidget *verify_box = NULL;
|
||||
const gchar *buttons[MAX_BUTTONS+1];
|
||||
gchar *buffer;
|
||||
gint i;
|
||||
|
||||
/* Translate the buttons */
|
||||
for (i = 0; (i < MAX_BUTTONS) && buttons_in[i]; i++) {
|
||||
buttons[i] = gettext(buttons_in[i]);
|
||||
}
|
||||
g_assert(i < MAX_BUTTONS);
|
||||
buttons[i] = NULL;
|
||||
|
||||
buffer = g_strdup_vprintf(format, args);
|
||||
verify_box = gnome_message_box_newv(buffer, type, buttons);
|
||||
g_free(buffer);
|
||||
|
||||
if (parent != NULL)
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box), GTK_WINDOW(parent));
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(verify_box), 0);
|
||||
|
||||
return (gnome_dialog_run_and_close(GNOME_DIALOG(verify_box)));
|
||||
}
|
||||
|
||||
int
|
||||
gnc_generic_question_dialog(const char **buttons, const gchar *format, ...)
|
||||
{
|
||||
int result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
result = gnc_generic_dialog_common(gnc_ui_get_toplevel(),
|
||||
GNOME_MESSAGE_BOX_QUESTION,
|
||||
buttons, format, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
|
||||
int
|
||||
gnc_generic_warning_dialog(const char **buttons, const gchar *format, ...)
|
||||
{
|
||||
int result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
result = gnc_generic_dialog_common(gnc_ui_get_toplevel(),
|
||||
GNOME_MESSAGE_BOX_WARNING,
|
||||
buttons, format, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
|
||||
int
|
||||
gnc_generic_error_dialog(const char **buttons, const gchar *format, ...)
|
||||
{
|
||||
int result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
result = gnc_generic_dialog_common(gnc_ui_get_toplevel(),
|
||||
GNOME_MESSAGE_BOX_ERROR,
|
||||
buttons, format, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_choose_radio_button_cb(GtkWidget *w, gpointer data)
|
||||
|
@ -40,4 +40,16 @@ extern void
|
||||
gnc_error_dialog_parented(GtkWindow *parent,
|
||||
const char *forrmat, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
extern int
|
||||
gnc_generic_question_dialog(const char **buttons,
|
||||
const char *format, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
extern int
|
||||
gnc_generic_warning_dialog(const char **buttons,
|
||||
const char *format, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
extern int
|
||||
gnc_generic_error_dialog(const char **buttons,
|
||||
const char *format, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
#endif
|
||||
|
@ -399,6 +399,7 @@ gnc_gui_init (SCM command_line)
|
||||
gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
|
||||
|
||||
gnc_file_set_can_cancel_callback (gnc_mdi_has_apps);
|
||||
gnc_file_set_shutdown_callback (gnc_shutdown);
|
||||
|
||||
gnc_options_dialog_set_global_help_cb (gnc_global_options_help_cb, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user