Add support for modal message boxes ("simple dialog").
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 9 Oct 2000 06:38:36 +0000 (06:38 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 9 Oct 2000 06:38:36 +0000 (06:38 +0000)
Make the message boxes popped up for errors when selecting a font modal,
so that the user has to say "yes, I know, I'll do better next time"
before hitting "OK" again, so that you don't get a pile of message
boxes.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2485 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/gui_prefs.c
gtk/simple_dialog.c
simple_dialog.h

index c6af8bd904f58509c531d7a40f0c1e91107dcd4c..a8db02a28a08ac4527e2b9924267e8a0f9269bfc 100644 (file)
@@ -1,7 +1,7 @@
 /* gui_prefs.c
  * Dialog box for GUI preferences
  *
- * $Id: gui_prefs.c,v 1.20 2000/10/09 06:28:49 guy Exp $
+ * $Id: gui_prefs.c,v 1.21 2000/10/09 06:38:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -320,9 +320,10 @@ font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs)
        font_name = g_strdup(gtk_font_selection_dialog_get_font_name(
              GTK_FONT_SELECTION_DIALOG(fs)));
        if (font_name == NULL) {
-               /* No font was selected; let the user know, and don't let
-                  them accept that non-font. */
-               simple_dialog(ESD_TYPE_CRIT, NULL,
+               /* No font was selected; let the user know, but don't
+                  tear down the font selection dialog, so they can
+                  try again. */
+               simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
                   "You have not selected a font.");
                return;
        }
@@ -336,7 +337,7 @@ font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs)
                /* Oops, that font didn't work.
                   Tell the user, but don't tear down the font selection
                   dialog, so that they can try again. */
-               simple_dialog(ESD_TYPE_CRIT, NULL,
+               simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
                   "The font you selected cannot be loaded.");
 
                g_free(font_name);
@@ -349,7 +350,7 @@ font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs)
                /* Oops, that font didn't work.
                   Tell the user, but don't tear down the font selection
                   dialog, so that they can try again. */
-               simple_dialog(ESD_TYPE_CRIT, NULL,
+               simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
                   "The font you selected doesn't have a boldface version.");
 
                g_free(font_name);
index 61269534a2a512439132f29bc3b7ce9c696724bd..d0377422d05988d1c7f6767f1a8221b013108858 100644 (file)
@@ -1,7 +1,7 @@
 /* simple_dialog.c
  * Simple message dialog box routines.
  *
- * $Id: simple_dialog.c,v 1.6 2000/08/23 06:56:31 guy Exp $
+ * $Id: simple_dialog.c,v 1.7 2000/10/09 06:38:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -76,7 +76,7 @@ simple_dialog(gint type, gint *btn_mask, gchar *msg_format, ...) {
   gchar      **icon;
 
   /* Main window */
-  switch (type) {
+  switch (type & ~ESD_TYPE_MODAL) {
   case ESD_TYPE_WARN :
     icon = icon_excl_xpm;
     win = dlg_window_new("Ethereal: Warning");
@@ -92,6 +92,9 @@ simple_dialog(gint type, gint *btn_mask, gchar *msg_format, ...) {
     break;
   }
 
+  if (type & ESD_TYPE_MODAL)
+    gtk_window_set_modal(GTK_WINDOW(win), TRUE);
+
   gtk_container_border_width(GTK_CONTAINER(win), 7);
 
   gtk_object_set_data(GTK_OBJECT(win), bm_key, btn_mask);
index 9afdf1f1e5f85aac0c27f240390d1d20cec88d37..f952c19940f68df3e0068207e455faca790ef75a 100644 (file)
@@ -2,7 +2,7 @@
  * Definitions for dialog box routines with toolkit-independent APIs but
  * toolkit-dependent implementations.
  *
- * $Id: simple_dialog.h,v 1.1 2000/01/03 06:59:09 guy Exp $
+ * $Id: simple_dialog.h,v 1.2 2000/10/09 06:38:34 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -32,9 +32,13 @@ extern "C" {
 #endif /* __cplusplus */
 
 /* Dialog type. */
-#define ESD_TYPE_INFO 0
-#define ESD_TYPE_WARN 1
-#define ESD_TYPE_CRIT 2
+#define ESD_TYPE_INFO  0x00
+#define ESD_TYPE_WARN  0x01
+#define ESD_TYPE_CRIT  0x02
+
+/* Flag to be ORed with the dialog type, to specify that the dialog is
+   to be modal. */
+#define ESD_TYPE_MODAL 0x04
 
 /* Which buttons to display. */
 #define ESD_BTN_OK     0