The GnomeMessageBox widget creates dialog boxes (of type
GnomeDialog) that contain a severity level (indicated by an icon
and a title), a message to be displayed and a list of buttons that
will be in the dialog.
The programmer will use strings desired for each button. If the
strings are any of the GNOME_STOCK macros, then instead of
creating a button with the text, the button will be a GNOME stock
button with a stock icon.
The list of known types for message boxes are:
GNOME_MESSAGE_BOX_INFO, GNOME_MESSAGE_BOX_WARNING,
GNOME_MESSAGE_BOX_ERROR, GNOME_MESSAGE_BOX_QUESTION and
GNOME_MESSAGE_BOX_GENERIC.
Here is an example that informs the user of an error:
GtkWidget *error_dialog;
int ret;
error_dialog = gnome_message_box_new (
"Wrong password",
GNOME_MESSAGE_BOX_ERROR,
"Retry", "Ignore",
NULL);
ret = gnome_dialog_run (GNOME_DIALOG (error_dialog));
switch (ret){
case 0:
do_retry();
break;
case 1:
do_ignore()
break;
default:
/* User closed dialog with window manager,
* assume "ignore"
*/
do_ignore();
break;
}
This other example uses stock buttons:
GtkWidget *yes_no_dialog;
int ret;
yes_no_dialog = gnome_message_box_new (
"Do you want to make a chocolate cake?",
GNOME_MESSAGE_BOX_QUESTION,
GNOME_STOCK_BUTTON_YES,
GNOME_STOCK_BUTTON_NO,
NULL);
ret = gnome_dialog_run (GNOME_DIALOG (yes_no_dialog));
switch (ret){
case 0:
make_chocolate_cake();
break;
case 1:
/* User does not desire chocolate cake *./
break;
default:
/*
* User closed dialog with window manager,
* assume he is not into chocolate cake.
*/
do_ignore();
break;
}
Details
struct GnomeMessageBox
struct GnomeMessageBox;
GNOME_MESSAGE_BOX_INFO
#define GNOME_MESSAGE_BOX_INFO "info"
Use this macro for displaying an informational message.
GNOME_MESSAGE_BOX_WARNING
#define GNOME_MESSAGE_BOX_WARNING "warning"
Use this macro for displaying a warning message.
GNOME_MESSAGE_BOX_ERROR
#define GNOME_MESSAGE_BOX_ERROR "error"
Use this macro for displaying an error message.
GNOME_MESSAGE_BOX_QUESTION
#define GNOME_MESSAGE_BOX_QUESTION "question"
Use this macro when you want to query the user for information.
GNOME_MESSAGE_BOX_GENERIC
#define GNOME_MESSAGE_BOX_GENERIC "generic"
Use this macro if none of the other message box types apply.
Creates a dialog box of type message_box_type with message. A number
of buttons are inserted on it. You can use the GNOME stock identifiers
to create gnome-stock-buttons.
message :
The message to be displayed.
messagebox_type :
... :
A NULL terminated list of strings to use in each button.
Creates a dialog box of type message_box_type with message. A number
of buttons are inserted on it, the messages come from the buttons array.
You can use the GNOME stock identifiers to create gnome-stock-buttons.
message :
The message to be displayed.
messagebox_type :
buttons :
a NULL terminated array with the buttons to insert.