From fd262f1b97114cc258ace5fee044505ca39c6582 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 13 Jul 2004 07:15:45 +0000 Subject: 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 --- gtk/capture_dlg.c | 10 +++++----- gtk/compat_macros.h | 5 ++++- gtk/dlg_utils.c | 14 ++++++++++++-- gtk/file_dlg.c | 14 +++++++------- gtk/main.c | 24 ++++++++++++------------ gtk/simple_dialog.c | 18 ++++++++++++++++-- gtk/toolbar.c | 3 ++- simple_dialog.h | 10 ++++++++-- 8 files changed, 66 insertions(+), 32 deletions(-) diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index cb94c17812..333b406450 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -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 @@ -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 */ diff --git a/gtk/compat_macros.h b/gtk/compat_macros.h index e871a388c3..888a6d7369 100644 --- a/gtk/compat_macros.h +++ b/gtk/compat_macros.h @@ -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 @@ -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); diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c index 0a0166bc52..0ace9be012 100644 --- a/gtk/dlg_utils.c +++ b/gtk/dlg_utils.c @@ -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 @@ -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); diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index eec712dfb4..947ed555ba 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -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 @@ -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."); diff --git a/gtk/main.c b/gtk/main.c index 1920335863..cd5c8cd804 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -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 @@ -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); diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c index 386624b270..64f81b0caf 100644 --- a/gtk/simple_dialog.c +++ b/gtk/simple_dialog.c @@ -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 @@ -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)); diff --git a/gtk/toolbar.c b/gtk/toolbar.c index 1eb9f9287c..4716961991 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -2,7 +2,7 @@ * The main toolbar * Copyright 2003, Ulf Lamping * - * $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 @@ -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[] = { diff --git a/simple_dialog.h b/simple_dialog.h index be0cb8734e..7d5a4c8bf5 100644 --- a/simple_dialog.h +++ b/simple_dialog.h @@ -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 @@ -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. -- cgit v1.2.3