A GnomeMessageBox is a GnomeDialog subclass that conveys
a short message or asks a simple question. Gnome provides
several "types" of message box; they have different icons
next to the text, and corresponding titles. The icons
look nice, and allow users to quickly classify the
message being presented.
The API is very simple; there are no functions specific
to GnomeMessageBox other than
the constructor, in Figure 10. The
first argument is the message to display; the second is a
string encoding the message box type. Then you can list
any buttons, just as you would with
gnome_dialog_new(). Unlike the unadorned GnomeDialog,
GnomeMessageBox closes on any button click by
default. Of course you can change this behavior using gnome_dialog_set_close().
Macros are provided for the available message box types.
-
GNOME_MESSAGE_BOX_INFO
should be used for "FYI" messages.
-
GNOME_MESSAGE_BOX_WARNING
should be used for nonfatal errors.
-
GNOME_MESSAGE_BOX_ERROR
should be used if an operation fails entirely.
-
GNOME_MESSAGE_BOX_QUESTION
should be used if your dialog asks a question.
-
GNOME_MESSAGE_BOX_GENERIC
should be used if none of the other types apply.
Here's how you might use
GnomeMessageBox:
GtkWidget * mbox;
mbox = gnome_message_box_new (message,
GNOME_MESSAGE_BOX_INFO,
GNOME_STOCK_BUTTON_OK,
NULL);
gtk_widget_show (mbox);
|
Notice that GnomeMessageBox,
like most GnomeDialog
subclasses but not GnomeDialog
itself, automatically closes when clicked. So there is no
need to destroy it by hand.