Gnome User Interface Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# GnomeMessageBox

## Name

GnomeMessageBox -- Message box display routines

## Synopsis

    #include <gnome.h>

    struct      GnomeMessageBox;
    #define     GNOME_MESSAGE_BOX_INFO
    #define     GNOME_MESSAGE_BOX_WARNING
    #define     GNOME_MESSAGE_BOX_ERROR
    #define     GNOME_MESSAGE_BOX_QUESTION
    #define     GNOME_MESSAGE_BOX_GENERIC
    struct      GnomeMessageBoxButton;
    GtkWidget*  gnome_message_box_new           (const gchar *message,
                                                 const gchar *messagebox_type,
                                                 ...);
    GtkWidget*  gnome_message_box_newv          (const gchar *message,
                                                 const gchar *messagebox_type,
                                                 const gchar **buttons);
    void        gnome_message_box_set_modal     (GnomeMessageBox *messagebox);
    void        gnome_message_box_set_default   (GnomeMessageBox *messagebox,
                                                 gint button);

## Object Hierarchy

      GtkObject
       +----GtkWidget
             +----GtkContainer
                   +----GtkBin
                         +----GtkWindow
                               +----GnomeDialog
                                     +----GnomeMessageBox

## Description

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.

### struct GnomeMessageBoxButton

    struct GnomeMessageBoxButton;

### gnome_message_box_new ()

    GtkWidget*  gnome_message_box_new           (const gchar *message,
                                                 const gchar *messagebox_type,
                                                 ...);

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.
Returns : | a widget that has the dialog box.

### gnome_message_box_newv ()

    GtkWidget*  gnome_message_box_newv          (const gchar *message,
                                                 const gchar *messagebox_type,
                                                 const gchar **buttons);

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.
Returns : | a widget that has the dialog box.

### gnome_message_box_set_modal ()

    void        gnome_message_box_set_modal     (GnomeMessageBox *messagebox);

Deprecated. Use `gtk_window_set_modal()`.

`messagebox` : |

### gnome_message_box_set_default ()

    void        gnome_message_box_set_default   (GnomeMessageBox *messagebox,
                                                 gint button);

Deprecated. Use `gnome_dialog_set_modal()`.

`messagebox` : |
`button` : |

## See Also

GnomeDialog

<<< Previous Page | Home | Up | Next Page >>>
GnomeMDI | GnomeNumberEntry