/* -*-c-*-
*
- * $Id: msg.c,v 1.1 1998/12/11 09:44:21 mdw Exp $
+ * $Id: msg.c,v 1.7 1999/05/21 22:08:20 mdw Exp $
*
* Display a message and get an answer
*
* This file is part of the mgLib GTK utilities library.
*
* mgLib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
*
* mgLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with mgLib; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Library General Public
+ * License along with mgLib; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
*/
/*----- Revision history --------------------------------------------------*
*
* $Log: msg.c,v $
+ * Revision 1.7 1999/05/21 22:08:20 mdw
+ * Take advantage of new dynamic string macros.
+ *
+ * Revision 1.6 1999/05/06 19:51:48 mdw
+ * Reformatted the LGPL notice a little bit.
+ *
+ * Revision 1.5 1999/05/05 18:52:45 mdw
+ * Change licensing conditions to LGPL.
+ *
+ * Revision 1.4 1999/04/29 20:48:13 mdw
+ * Add documentation for `msg'.
+ *
+ * Revision 1.3 1999/03/25 23:36:10 mdw
+ * Compile to nothing in absence of GTK, for the benefit of parent packages
+ * which contain non-GTK-dependent parts.
+ *
+ * Revision 1.2 1998/12/15 23:48:06 mdw
+ * Use `dstr_putf' for formatting, rather than `sprintf'.
+ *
* Revision 1.1 1998/12/11 09:44:21 mdw
* Initial version.
*
*/
+#ifdef HAVE_GTK
+
/*----- Header files ------------------------------------------------------*/
#include <stdarg.h>
#include <gtk/gtk.h>
#include <mLib/alloc.h>
+#include <mLib/dstr.h>
#include "cancel.h"
#include "mdwfocus.h"
*
* Use: Displays a message to the user in a nice dialogue box and
* returns the index of the button selected.
+ *
+ * The @msg@ argument is a @printf@-style format string, which
+ * contains the message to actually be shown. The @buttons@
+ * argument is a comma-separated list of buttons to be drawn,
+ * from right to left. A button name can be preceded with `:'
+ * to indicate that it's the default, or `~' if it's the
+ * `cancel' button. The return value is the zero-based index
+ * of the button selected.
*/
static int close(GtkWidget *w, gpointer p)
/* --- Set up the message string --- */
{
- char buf[1024];
+ dstr d = DSTR_INIT;
va_list ap;
va_start(ap, msg);
-#ifdef HAVE_VSNPRINTF
- vsnprintf(buf, sizeof(buf), msg, ap);
-#else
- vsprintf(buf, sizeof(buf), msg, ap);
-#endif
+ dstr_vputf(&d, msg, ap);
va_end(ap);
- w = gtk_label_new(buf);
+ w = gtk_label_new(d.buf);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dbox)->vbox), w, 1, 1, 0);
gtk_window_position(GTK_WINDOW(dbox), GTK_WIN_POS_MOUSE);
gtk_widget_show(w);
gtk_misc_set_padding(GTK_MISC(w), 16, 16);
+ dstr_destroy(&d);
}
/* --- Set up the buttons --- */
cancel(GTK_WINDOW(dbox), w);
gtk_widget_show(w);
}
+ free(p);
+
+ /* --- Preflight checklist --- */
gtk_widget_realize(dbox);
if (f & f_mdwfocus)
mdwfocus(dbox);
+
}
/* --- Ready --- */
}
/*----- That's all, folks -------------------------------------------------*/
+
+#else
+ int mgLib_msg = 0;
+#endif