Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: [Ethereal-dev] Improvements to the 'Do you want to save?' messages.

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Daniel Thompson <ethereal@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Jul 2004 12:28:57 +0100
Hi Folks

The attached patch will make the 'Do you want to save?' alerts confirm
more strictly to the GNOME HIG without, AFAIK violating the Win32 one. I
was going to file this as a bug but since I couldn't find the ethereal
bug database I decided to fix it instead!

Basically it will convert the current:

[Yes] [No] [Cancel]

so that the buttons use imperitive verbs and are ordered in the
recommended Alternate, Cancel, Affirmative form (both recommendations
from section 4.2). For example:

[Continue without Saving] [Cancel] [Save]

Note: I opted for 'Continue without Saving' instead of 'Close without
Saving' which is recommended in section 4.6.1 since in most cases are
not about the close the ethereal window.

On Win32 and GTK1 the button labels will remain the same but ordering
will be Win32 style (Affirmative, Alternate, Cancel). Note the Win32
guidelines recommend Yes/No for simple cases but a sentance later say
verbs are good where they increase clarity ...

Finally these changes mean the ESD_BTNS_YES_NO_CANCEL are no longer used
though I have left the infrastructural code in for the time being (and
on GTK2 switched to Alternate, Cancel, Affirmative) form if it was used.

There are probably more words in this e-mail than the patch so I think
I'll shut up now ...

-- 
Daniel Thompson <ethereal@xxxxxxxxxxxxxxxxxxxxx>
Index: simple_dialog.h
===================================================================
RCS file: /cvsroot/ethereal/simple_dialog.h,v
retrieving revision 1.15
diff -u -r1.15 simple_dialog.h
--- simple_dialog.h	4 Jun 2004 21:12:01 -0000	1.15
+++ simple_dialog.h	11 Jul 2004 11:14:08 -0000
@@ -55,7 +55,11 @@
 /** 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 @@
 #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.
Index: gtk/capture_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/capture_dlg.c,v
retrieving revision 1.137
diff -u -r1.137 capture_dlg.c
--- gtk/capture_dlg.c	30 Jun 2004 18:24:56 -0000	1.137
+++ gtk/capture_dlg.c	11 Jul 2004 11:14:12 -0000
@@ -1184,11 +1184,11 @@
 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 @@
 
   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 */
Index: gtk/compat_macros.h
===================================================================
RCS file: /cvsroot/ethereal/gtk/compat_macros.h,v
retrieving revision 1.20
diff -u -r1.20 compat_macros.h
--- gtk/compat_macros.h	17 Jun 2004 16:35:23 -0000	1.20
+++ gtk/compat_macros.h	11 Jul 2004 11:14:12 -0000
@@ -198,6 +198,7 @@
 #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 @@
 #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 @@
 #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);
Index: gtk/dlg_utils.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/dlg_utils.c,v
retrieving revision 1.39
diff -u -r1.39 dlg_utils.c
--- gtk/dlg_utils.c	20 Jun 2004 19:35:04 -0000	1.39
+++ gtk/dlg_utils.c	11 Jul 2004 11:14:12 -0000
@@ -100,6 +100,7 @@
     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 @@
             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 @@
             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, 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 @@
     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);
Index: gtk/file_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/file_dlg.c,v
retrieving revision 1.127
diff -u -r1.127 file_dlg.c
--- gtk/file_dlg.c	30 Jun 2004 07:12:25 -0000	1.127
+++ gtk/file_dlg.c	11 Jul 2004 11:14:14 -0000
@@ -582,11 +582,11 @@
 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 @@
 
   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 @@
 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 @@
 
   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.");
 
Index: gtk/main.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/main.c,v
retrieving revision 1.454
diff -u -r1.454 main.c
--- gtk/main.c	7 Jul 2004 16:31:30 -0000	1.454
+++ gtk/main.c	11 Jul 2004 11:14:17 -0000
@@ -832,7 +832,7 @@
 
   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);
@@ -905,11 +905,11 @@
 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):
+    case(ESD_BTN_DONT_SAVE):
     	main_do_quit();
         break;
     case(ESD_BTN_CANCEL):
@@ -926,7 +926,7 @@
 
   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);
@@ -1438,11 +1438,11 @@
 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;
@@ -1467,7 +1467,7 @@
         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);
Index: gtk/simple_dialog.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/simple_dialog.c,v
retrieving revision 1.39
diff -u -r1.39 simple_dialog.c
--- gtk/simple_dialog.c	29 Jun 2004 22:21:04 -0000	1.39
+++ gtk/simple_dialog.c	11 Jul 2004 11:14:18 -0000
@@ -63,7 +63,7 @@
 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 @@
   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 @@
       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));
Index: gtk/toolbar.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/toolbar.c,v
retrieving revision 1.28
diff -u -r1.28 toolbar.c
--- gtk/toolbar.c	9 Feb 2004 18:32:41 -0000	1.28
+++ gtk/toolbar.c	11 Jul 2004 11:14:18 -0000
@@ -154,6 +154,7 @@
         { 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[] = {