Re: gnome dialog run-and-close?
- From: Havoc Pennington <rhpennin midway uchicago edu>
- To: Jeff Garzik <jgarzik pobox com>
- cc: gnome-list gnome org
- Subject: Re: gnome dialog run-and-close?
- Date: Mon, 14 Dec 1998 12:51:35 -0600 (CST)
On Mon, 14 Dec 1998, Jeff Garzik wrote:
> I remember there was discussion in the recent past about whether or not
> to use gnome-dialog-run-and-close.
>
> libgnomeui gurus, what is the Right and Proper(tm) way to display a
> simple message box, modal, and then destroy it? I can do it manually of
> course, but I was hoping there was a preferred convenience function
> somewhere that I should be using instead. :)
>
If you want one of the predefined boxes in gnome-dialog-util (i.e., just
an OK button, or Yes/No, or OK/Cancel, with no input validation) you can
do this:
GtkWidget* dialog = gnome_ok_dialog(_("Your message here"));
gnome_dialog_run(GNOME_DIALOG(dialog));
/* dialog is now destroyed, don't touch it. */
/* You can optionally get the button pressed as the _run() return
value. There are GNOME_YES, GNOME_OK macros defined to save you
remembering the numbers - these work on the convenience dialogs,
and on your own dialogs if you have the buttons in the right order.
-1 means the dialog was closed without clicking a button - window
manager or escape key.
*/
If you need something more complicated, the same thing will pretty much
work for GnomeMessageBox.
If you use raw GnomeDialog, because you need something still more
complicated, the simplest way is:
GtkWidget* dialog = gnome_dialog_new(...);
/* set up your dialog's contents */
gint button_pressed = gnome_dialog_run_and_close(dialog);
The _and_close() is needed because raw GnomeDialog does not close by
default when a button is clicked. Alternatively, you can call
gnome_dialog_set_close(dialog, TRUE) and then use plain _run().
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]