From Daniel Thompson: add additional message/alert box options to

display "Save", "Continue without Saving", and "Cancel", for the "do you
want to save?" messages.

svn path=/trunk/; revision=11372
This commit is contained in:
Guy Harris 2004-07-13 07:15:45 +00:00
parent aaac0102cb
commit fd262f1b97
8 changed files with 66 additions and 32 deletions

View File

@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
* $Id: capture_dlg.c,v 1.137 2004/06/30 18:24:56 ulfl Exp $
* $Id: capture_dlg.c,v 1.138 2004/07/13 07:15:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1184,11 +1184,11 @@ static void
capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
{
switch(btn) {
case(ESD_BTN_YES):
case(ESD_BTN_SAVE):
/* save file first */
file_save_as_cmd(after_save_capture_dialog, data);
break;
case(ESD_BTN_NO):
case(ESD_BTN_DONT_SAVE):
capture_prep();
break;
case(ESD_BTN_CANCEL):
@ -1205,9 +1205,9 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
"If you start a new capture without saving, your current capture data will be discarded.");
"If you start a new capture without saving, your current capture data will\nbe discarded.");
simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
} else {
/* unchanged file, just capture a new one */

View File

@ -1,7 +1,7 @@
/* compat_macros.h
* GTK-related Global defines, etc.
*
* $Id: compat_macros.h,v 1.20 2004/06/17 16:35:23 ulfl Exp $
* $Id: compat_macros.h,v 1.21 2004/07/13 07:15:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -198,6 +198,7 @@ gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), name)
#define ETHEREAL_STOCK_IMPORT "Import..."
#define ETHEREAL_STOCK_EDIT "Edit..."
#define ETHEREAL_STOCK_ADD_EXPRESSION "Add Expression..."
#define ETHEREAL_STOCK_DONT_SAVE "Continue without Saving"
/** Create a stock button. Will create a "normal" button for GTK1.
*
@ -297,6 +298,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#define ETHEREAL_STOCK_LABEL_IMPORT "_Import..."
#define ETHEREAL_STOCK_LABEL_EDIT "_Edit..."
#define ETHEREAL_STOCK_LABEL_ADD_EXPRESSION "_Expression..." /* plus sign coming from icon */
#define ETHEREAL_STOCK_LABEL_DONT_SAVE "Continue _without Saving"
#ifdef HAVE_LIBPCAP
#define ETHEREAL_STOCK_CAPTURE_START "Ethereal_Stock_CaptureStart"
@ -312,6 +314,7 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
#define ETHEREAL_STOCK_IMPORT "Ethereal_Stock_Import"
#define ETHEREAL_STOCK_EDIT "Ethereal_Stock_Edit"
#define ETHEREAL_STOCK_ADD_EXPRESSION "Ethereal_Stock_Edit_Add_Expression"
#define ETHEREAL_STOCK_DONT_SAVE "Ethereal_Stock_Continue_without_Saving"
#define BUTTON_NEW_FROM_STOCK(stock_id) \
gtk_button_new_from_stock(stock_id);

View File

@ -1,7 +1,7 @@
/* dlg_utils.c
* Utilities to use when constructing dialogs
*
* $Id: dlg_utils.c,v 1.41 2004/07/12 20:01:41 ulfl Exp $
* $Id: dlg_utils.c,v 1.42 2004/07/13 07:15:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -100,6 +100,7 @@ dlg_button_row_new(gchar *stock_id_first, ...)
gchar *ok = NULL;
gchar *apply = NULL;
gchar *save = NULL;
gchar *dont_save = NULL;
gchar *cancel = NULL;
gchar *close = NULL;
gchar *clear = NULL;
@ -125,6 +126,8 @@ dlg_button_row_new(gchar *stock_id_first, ...)
apply = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_SAVE) == 0) {
save = stock_id;
} else if (strcmp(stock_id, ETHEREAL_STOCK_DONT_SAVE) == 0) {
dont_save = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CANCEL) == 0) {
cancel = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CLOSE) == 0) {
@ -256,11 +259,17 @@ dlg_button_row_new(gchar *stock_id_first, ...)
return hbox;
}
if (yes && no && cancel) {
dlg_button_new(hbox, button_hbox, yes);
dlg_button_new(hbox, button_hbox, no);
dlg_button_new(hbox, button_hbox, cancel);
dlg_button_new(hbox, button_hbox, yes);
return hbox;
}
if (save && dont_save && cancel) {
dlg_button_new(hbox, button_hbox, dont_save);
dlg_button_new(hbox, button_hbox, cancel);
dlg_button_new(hbox, button_hbox, save);
return hbox;
}
}
if (buttons == 4) {
if (ok && apply && save && cancel) {
@ -290,6 +299,7 @@ dlg_button_row_new(gchar *stock_id_first, ...)
if (yes != NULL) dlg_button_new(hbox, button_hbox, yes);
if (no != NULL) dlg_button_new(hbox, button_hbox, no);
if (save != NULL) dlg_button_new(hbox, button_hbox, save);
if (dont_save != NULL) dlg_button_new(hbox, button_hbox, dont_save);
if (stop != NULL) dlg_button_new(hbox, button_hbox, stop);
if (close != NULL) dlg_button_new(hbox, button_hbox, close);
if (clear != NULL) dlg_button_new(hbox, button_hbox, clear);

View File

@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
* $Id: file_dlg.c,v 1.127 2004/06/30 07:12:25 guy Exp $
* $Id: file_dlg.c,v 1.128 2004/07/13 07:15:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -582,11 +582,11 @@ file_open_cmd(GtkWidget *w)
static void file_open_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
{
switch(btn) {
case(ESD_BTN_YES):
case(ESD_BTN_SAVE):
/* save file first */
file_save_as_cmd(after_save_open_dialog, data);
break;
case(ESD_BTN_NO):
case(ESD_BTN_DONT_SAVE):
cf_close(&cfile);
file_open_cmd(data);
break;
@ -603,7 +603,7 @@ file_open_cmd_cb(GtkWidget *widget, gpointer data _U_) {
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
"If you open a new capture file without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_open_answered_cb, widget);
@ -1059,11 +1059,11 @@ file_merge_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
void file_close_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
{
switch(btn) {
case(ESD_BTN_YES):
case(ESD_BTN_SAVE):
/* save file first */
file_save_as_cmd(after_save_close_file, NULL);
break;
case(ESD_BTN_NO):
case(ESD_BTN_DONT_SAVE):
cf_close(&cfile);
break;
case(ESD_BTN_CANCEL):
@ -1080,7 +1080,7 @@ file_close_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) {
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before closing it?" PRIMARY_TEXT_END "\n\n"
"If you close without saving, your capture data will be discarded.");

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.457 2004/07/12 19:10:58 ulfl Exp $
* $Id: main.c,v 1.458 2004/07/13 07:15:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -835,15 +835,15 @@ main_window_delete_event_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer
gtk_window_present(GTK_WINDOW(top_level));
#endif
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before program quit?" PRIMARY_TEXT_END "\n\n"
"If you quit the program without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
return TRUE;
} else {
/* unchanged file, just exit */
/* "main_do_quit()" indicates whether the main window should be deleted. */
return main_do_quit();
/* "main_do_quit()" indicates whether the main window should be deleted. */
return main_do_quit();
}
}
@ -918,12 +918,12 @@ main_save_window_geometry(GtkWidget *widget)
static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
{
switch(btn) {
case(ESD_BTN_YES):
case(ESD_BTN_SAVE):
/* save file first */
file_save_as_cmd(after_save_exit, NULL);
break;
case(ESD_BTN_NO):
main_do_quit();
case(ESD_BTN_DONT_SAVE):
main_do_quit();
break;
case(ESD_BTN_CANCEL):
break;
@ -939,13 +939,13 @@ file_quit_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before program quit?" PRIMARY_TEXT_END "\n\n"
"If you quit the program without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
} else {
/* unchanged file, just exit */
main_do_quit();
main_do_quit();
}
}
@ -1451,11 +1451,11 @@ static void
dnd_save_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
{
switch(btn) {
case(ESD_BTN_YES):
case(ESD_BTN_SAVE):
/* save file first */
file_save_as_cmd(after_save_open_dnd_file, data);
break;
case(ESD_BTN_NO):
case(ESD_BTN_DONT_SAVE):
cf_close(&cfile);
dnd_open_file_cmd(data);
break;
@ -1480,7 +1480,7 @@ GtkSelectionData *selection_data, guint info, guint t _U_, gpointer data _U_)
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION,
ESD_BTNS_YES_NO_CANCEL,
ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
"If you open a new capture file without saving, your current capture data will be discarded.");
simple_dialog_set_cb(dialog, dnd_save_file_answered_cb, selection_data);

View File

@ -1,7 +1,7 @@
/* simple_dialog.c
* Simple message dialog box routines.
*
* $Id: simple_dialog.c,v 1.39 2004/06/29 22:21:04 ulfl Exp $
* $Id: simple_dialog.c,v 1.40 2004/07/13 07:15:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -63,7 +63,7 @@ static GtkWidget *
display_simple_dialog(gint type, gint btn_mask, char *message)
{
GtkWidget *win, *main_vb, *top_hb, *type_pm, *msg_label,
*bbox, *ok_bt, *yes_bt, *bt;
*bbox, *ok_bt, *yes_bt, *bt, *save_bt, *dont_save_bt;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
@ -176,6 +176,9 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
case(ESD_BTNS_YES_NO_CANCEL):
bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL);
break;
case(ESD_BTNS_SAVE_DONTSAVE_CANCEL):
bbox = dlg_button_row_new(GTK_STOCK_SAVE, ETHEREAL_STOCK_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
break;
case(ESD_BTNS_YES_NO):
bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, NULL);
break;
@ -193,6 +196,17 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
SIGNAL_CONNECT(ok_bt, "clicked", simple_dialog_cancel_cb, win);
}
save_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_SAVE);
if (save_bt) {
OBJECT_SET_DATA(save_bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE));
SIGNAL_CONNECT(save_bt, "clicked", simple_dialog_cancel_cb, win);
}
dont_save_bt = OBJECT_GET_DATA(bbox, ETHEREAL_STOCK_DONT_SAVE);
if (dont_save_bt) {
OBJECT_SET_DATA(dont_save_bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE));
SIGNAL_CONNECT(dont_save_bt, "clicked", simple_dialog_cancel_cb, win);
}
bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLEAR);
if(bt) {
OBJECT_SET_DATA(bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR));

View File

@ -2,7 +2,7 @@
* The main toolbar
* Copyright 2003, Ulf Lamping <ulf.lamping@web.de>
*
* $Id: toolbar.c,v 1.28 2004/02/09 18:32:41 ulfl Exp $
* $Id: toolbar.c,v 1.29 2004/07/13 07:15:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -154,6 +154,7 @@ void ethereal_stock_icons(void) {
{ ETHEREAL_STOCK_IMPORT, ETHEREAL_STOCK_LABEL_IMPORT, 0, 0, NULL },
{ ETHEREAL_STOCK_EDIT, ETHEREAL_STOCK_LABEL_EDIT, 0, 0, NULL },
{ ETHEREAL_STOCK_ADD_EXPRESSION, ETHEREAL_STOCK_LABEL_ADD_EXPRESSION, 0, 0, NULL },
{ ETHEREAL_STOCK_DONT_SAVE, ETHEREAL_STOCK_LABEL_DONT_SAVE, 0, 0, NULL }
};
static const stock_pixmap_t pixmaps[] = {

View File

@ -2,7 +2,7 @@
* Definitions for alert box routines with toolkit-independent APIs but
* toolkit-dependent implementations.
*
* $Id: simple_dialog.h,v 1.15 2004/06/04 21:12:01 guy Exp $
* $Id: simple_dialog.h,v 1.16 2004/07/13 07:15:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -55,7 +55,11 @@ typedef enum {
/** display a "No" button */
#define ESD_BTN_NO 0x08
/** display a "Clear" button */
#define ESD_BTN_CLEAR 0x10
#define ESD_BTN_CLEAR 0x10
/** display a "Save" button */
#define ESD_BTN_SAVE 0x20
/** display a "Continue without Saving" button */
#define ESD_BTN_DONT_SAVE 0x40
/** Standard button combination "Ok" + "Cancel". */
#define ESD_BTNS_OK_CANCEL (ESD_BTN_OK|ESD_BTN_CANCEL)
@ -63,6 +67,8 @@ typedef enum {
#define ESD_BTNS_YES_NO (ESD_BTN_YES|ESD_BTN_NO)
/** Standard button combination "Yes" + "No" + "Cancel". */
#define ESD_BTNS_YES_NO_CANCEL (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
/** Standard button combination "No" + "Cancel" + "Save". */
#define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
#if __GNUC__ >= 2
/** Create and show a simple dialog.