chiark / gitweb /
Allow control over the message box title.
authormdw <mdw>
Sun, 13 Jan 2002 14:32:23 +0000 (14:32 +0000)
committermdw <mdw>
Sun, 13 Jan 2002 14:32:23 +0000 (14:32 +0000)
msg.c
msg.h

diff --git a/msg.c b/msg.c
index 7ec62a10494fd2f9ce9d757af498c7de614af17a..ccd59ae0d681b9f576845c7bd4b397d9d73cd711 100644 (file)
--- a/msg.c
+++ b/msg.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: msg.c,v 1.8 1999/11/11 19:54:37 mdw Exp $
+ * $Id: msg.c,v 1.9 2002/01/13 14:32:22 mdw Exp $
  *
  * Display a message and get an answer
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: msg.c,v $
+ * Revision 1.9  2002/01/13 14:32:22  mdw
+ * Allow control over the message box title.
+ *
  * Revision 1.8  1999/11/11 19:54:37  mdw
  * Prep for standalone release.
  *
@@ -82,8 +85,9 @@ static int creply;
 
 /* --- @msg@ --- *
  *
- * Arguments:  @char *buttons@ = the button strings to display
- *             @char *msg@ = the message skeleton string
+ * Arguments:  @const char *title@ = the title for the message box
+ *             @const char *buttons@ = the button strings to display
+ *             @const char *msg@ = the message skeleton string
  *
  * Returns:    Index of the button selected.
  *
@@ -112,13 +116,14 @@ static void click(GtkWidget *w, gpointer p)
   gtk_main_quit();
 }
 
-int msg(const char *buttons, const char *msg, ...)
+int msg(const char *title, const char *buttons, const char *msg, ...)
 {
   GtkWidget *dbox, *w;
 
   /* --- Make most of the dialogue box --- */
 
   dbox = gtk_dialog_new();
+  gtk_window_set_title(GTK_WINDOW(dbox), title);
   gtk_signal_connect(GTK_OBJECT(dbox), "delete_event",
                     GTK_SIGNAL_FUNC(close), 0);
   gtk_box_set_homogeneous(GTK_BOX(GTK_DIALOG(dbox)->action_area), 0);  
@@ -147,11 +152,9 @@ int msg(const char *buttons, const char *msg, ...)
     unsigned f = 0;
     int i = 0;
 
-    enum {
-      f_ok = 1,
-      f_cancel = 2,
-      f_mdwfocus = 4
-    };
+#define f_ok 1u
+#define f_cancel 2u
+#define f_mdwfocus 4u
 
     if (*p == '!') {
       f |= f_mdwfocus;
@@ -190,6 +193,9 @@ int msg(const char *buttons, const char *msg, ...)
     if (f & f_mdwfocus)
       mdwfocus(dbox);
 
+#undef f_ok
+#undef f_cancel
+#undef f_mdwfocus
   }
 
   /* --- Ready --- */
diff --git a/msg.h b/msg.h
index dd9eddb387693ac747fd5dbd610f7b3f1bafcaf2..8c973c5a552dc201a1c92bf6ee5bc97db5bbee14 100644 (file)
--- a/msg.h
+++ b/msg.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: msg.h,v 1.5 2000/08/15 22:40:15 mdw Exp $
+ * $Id: msg.h,v 1.6 2002/01/13 14:32:23 mdw Exp $
  *
  * Display a message and get an answer
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: msg.h,v $
+ * Revision 1.6  2002/01/13 14:32:23  mdw
+ * Allow control over the message box title.
+ *
  * Revision 1.5  2000/08/15 22:40:15  mdw
  * Change guard constants.
  *
@@ -62,8 +65,9 @@
 
 /* --- @msg@ --- *
  *
- * Arguments:  @char *buttons@ = the button strings to display
- *             @char *msg@ = the message skeleton string
+ * Arguments:  @const char *title@ = the title for the message box
+ *             @const char *buttons@ = the button strings to display
+ *             @const char *msg@ = the message skeleton string
  *
  * Returns:    Index of the button selected.
  *
@@ -79,7 +83,8 @@
  *             of the button selected.
  */
 
-extern int msg(const char */*buttons*/, const char */*msg*/, ...);
+extern int msg(const char */*msg*/, const char */*buttons*/,
+              const char */*msg*/, ...);
 
 /*----- That's all, folks -------------------------------------------------*/