Gtk.Message_Dialog

Entities

Simple Types

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

Gtk.Message_Dialog.Gtk_Message_Dialog presents a dialog with some message text. It's simply a convenience widget; you could construct the equivalent of Gtk.Message_Dialog.Gtk_Message_Dialog from Gtk.Dialog.Gtk_Dialog without too much effort, but Gtk.Message_Dialog.Gtk_Message_Dialog saves typing.

One difference from Gtk.Dialog.Gtk_Dialog is that Gtk.Message_Dialog.Gtk_Message_Dialog sets the Gtk.Window.Gtk_Window:skip-taskbar-hint property to True, so that the dialog is hidden from the taskbar by default.

The easiest way to do a modal message dialog is to use Gtk.Dialog.Run, though you can also pass in the GTK_DIALOG_MODAL flag, Gtk.Dialog.Run automatically makes the dialog modal and waits for the user to respond to it. Gtk.Dialog.Run returns when any dialog button is clicked.

An example for using a modal dialog:

GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_message_dialog_new (parent_window,
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_CLOSE,
                                 "Error reading "%s": %s",
                                 filename,
                                 g_strerror (errno));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);

You might do a non-modal Gtk.Message_Dialog.Gtk_Message_Dialog as follows:

An example for a non-modal dialog:

GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_message_dialog_new (parent_window,
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_CLOSE,
                                 "Error reading "%s": %s",
                                 filename,
                                 g_strerror (errno));

// Destroy the dialog when the user responds to it
// (e.g. clicks a button)

g_signal_connect_swapped (dialog, "response",
                          G_CALLBACK (gtk_widget_destroy),
                          dialog);

# GtkMessageDialog as GtkBuildable

The GtkMessageDialog implementation of the GtkBuildable interface exposes the message area as an internal child with the name "message_area".

"+"

function "+"
  (Widget : access Gtk_Message_Dialog_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Message_Dialog
Parameters
Interf
Return Value

Buttons_Property

Buttons_Property : constant Gtk.Message_Dialog.Property_Gtk_Buttons_Type;

Type: Gtk_Buttons_Type Flags: write

Format_Secondary_Markup

procedure Format_Secondary_Markup
   (Dialog  : not null access Gtk_Message_Dialog_Record;
    Message : UTF8_String := "")

Sets the secondary text of the message dialog to be Message_Format (with printf-style), which is marked up with the [Pango text markup language][PangoMarkupFormat]. Due to an oversight, this function does not escape special XML characters like Gtk.Message_Dialog.Gtk_New_With_Markup does. Thus, if the arguments may contain special XML characters, you should use g_markup_printf_escaped to escape it.

gchar *msg;

msg = g_markup_printf_escaped (message_format, ...);
gtk_message_dialog_format_secondary_markup (message_dialog,
                                            "%s", msg);
g_free (msg);

Since: gtk+ 2.6

Parameters
Dialog
Message

printf-style markup string (see [Pango markup format][PangoMarkupFormat]), or null

Get_Image

function Get_Image
   (Dialog : not null access Gtk_Message_Dialog_Record)
    return Gtk.Widget.Gtk_Widget

Gets the dialog's image. Since: gtk+ 2.14 Deprecated since 3.12, 1

Parameters
Dialog
Return Value

the dialog's image

Get_Message_Area

function Get_Message_Area
   (Dialog : not null access Gtk_Message_Dialog_Record)
    return Gtk.Widget.Gtk_Widget

Returns the message area of the dialog. This is the box where the dialog's primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those labels. See Gtk.Dialog.Get_Content_Area for the corresponding function in the parent Gtk.Dialog.Gtk_Dialog. Since: gtk+ 2.22

Parameters
Dialog
Return Value

A Gtk.Box.Gtk_Box corresponding to the "message area" in the Message_Dialog.

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Buttons_Type

type Gtk_Buttons_Type is (
   Buttons_None,
   Buttons_Ok,
   Buttons_Close,
   Buttons_Cancel,
   Buttons_Yes_No,
   Buttons_Ok_Cancel);

Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use Gtk.Message_Dialog.Buttons_None then call gtk_dialog_add_buttons.

> Please note that Gtk.Message_Dialog.Buttons_Ok, Gtk.Message_Dialog.Buttons_Yes_No > and Gtk.Message_Dialog.Buttons_Ok_Cancel are discouraged by the > GNOME Human Interface Guidelines.

Enumeration Literal
Buttons_None
Buttons_Ok
Buttons_Close
Buttons_Cancel
Buttons_Yes_No
Buttons_Ok_Cancel

Gtk_Buttons_Type_Properties

package Gtk_Buttons_Type_Properties is
   new Generic_Internal_Discrete_Property (Gtk_Buttons_Type);

Gtk_Message_Dialog

type Gtk_Message_Dialog is access all Gtk_Message_Dialog_Record'Class;

Gtk_Message_Dialog_New

function Gtk_Message_Dialog_New
   (Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "") return Gtk_Message_Dialog

Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details.

Parameters
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Return Value

Gtk_Message_Dialog_New_With_Markup

function Gtk_Message_Dialog_New_With_Markup
   (Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "") return Gtk_Message_Dialog

Creates a new message dialog, which is a simple dialog with some text that is marked up with the [Pango text markup language][PangoMarkupFormat]. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details. Special XML characters in the printf arguments passed to this function will automatically be escaped as necessary. (See g_markup_printf_escaped for how this is implemented.) Usually this is what you want, but if you have an existing Pango markup string that you want to use literally as the label, then you need to use Gtk.Message_Dialog.Set_Markup instead, since you can't pass the markup string either as the format (it might contain "%" characters) or as a string argument.

GtkWidget *dialog;
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_message_dialog_new (parent_window,
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_CLOSE,
                                 NULL);
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
                               markup);

Since: gtk+ 2.4

Parameters
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Return Value

Gtk_Message_Dialog_Record

type Gtk_Message_Dialog_Record is new Gtk_Dialog_Record with null record;

Gtk_Message_Type

type Gtk_Message_Type is (
   Message_Info,
   Message_Warning,
   Message_Question,
   Message_Error,
   Message_Other);

The type of message being displayed in the dialog.

Enumeration Literal
Message_Info
Message_Warning
Message_Question
Message_Error
Message_Other

Gtk_Message_Type_Properties

package Gtk_Message_Type_Properties is
   new Generic_Internal_Discrete_Property (Gtk_Message_Type);

Gtk_New

procedure Gtk_New
   (Dialog   : out Gtk_Message_Dialog;
    Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "")

Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Dialog
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Gtk_New_With_Markup

procedure Gtk_New_With_Markup
   (Dialog   : out Gtk_Message_Dialog;
    Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "")

Creates a new message dialog, which is a simple dialog with some text that is marked up with the [Pango text markup language][PangoMarkupFormat]. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details. Special XML characters in the printf arguments passed to this function will automatically be escaped as necessary. (See g_markup_printf_escaped for how this is implemented.) Usually this is what you want, but if you have an existing Pango markup string that you want to use literally as the label, then you need to use Gtk.Message_Dialog.Set_Markup instead, since you can't pass the markup string either as the format (it might contain "%" characters) or as a string argument.

GtkWidget *dialog;
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_message_dialog_new (parent_window,
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_CLOSE,
                                 NULL);
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
                               markup);

Since: gtk+ 2.4 Initialize_With_Markup does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Dialog
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Image_Property

Image_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Widget.Gtk_Widget The image for this dialog.

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Message_Dialog_Record, Gtk_Message_Dialog);

Initialize

procedure Initialize
   (Dialog   : not null access Gtk_Message_Dialog_Record'Class;
    Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "")

Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Dialog
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Initialize_With_Markup

procedure Initialize_With_Markup
   (Dialog   : not null access Gtk_Message_Dialog_Record'Class;
    Parent   : access Gtk.Window.Gtk_Window_Record'Class;
    Flags    : Gtk_Dialog_Flags;
    The_Type : Gtk_Message_Type;
    Buttons  : Gtk_Buttons_Type;
    Message  : UTF8_String := "")

Creates a new message dialog, which is a simple dialog with some text that is marked up with the [Pango text markup language][PangoMarkupFormat]. When the user clicks a button a "response" signal is emitted with response IDs from Gtk_Response_Type. See Gtk.Dialog.Gtk_Dialog for more details. Special XML characters in the printf arguments passed to this function will automatically be escaped as necessary. (See g_markup_printf_escaped for how this is implemented.) Usually this is what you want, but if you have an existing Pango markup string that you want to use literally as the label, then you need to use Gtk.Message_Dialog.Set_Markup instead, since you can't pass the markup string either as the format (it might contain "%" characters) or as a string argument.

GtkWidget *dialog;
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
dialog = gtk_message_dialog_new (parent_window,
                                 flags,
                                 GTK_MESSAGE_ERROR,
                                 GTK_BUTTONS_CLOSE,
                                 NULL);
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
                               markup);

Since: gtk+ 2.4 Initialize_With_Markup does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Dialog
Parent

transient parent, or null for none

Flags

flags

The_Type

type of message

Buttons

set of buttons to use

Message

printf-style format string, or null

Message_Area_Property

Message_Area_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Widget.Gtk_Widget The Gtk.Box.Gtk_Box that corresponds to the message area of this dialog. See Gtk.Message_Dialog.Get_Message_Area for a detailed description of this area.

Message_Type_Property

Message_Type_Property : constant Gtk.Message_Dialog.Property_Gtk_Message_Type;

Type: Gtk_Message_Type The type of the message.

Property_Gtk_Buttons_Type

type Property_Gtk_Buttons_Type is new Gtk_Buttons_Type_Properties.Property;

Property_Gtk_Message_Type

type Property_Gtk_Message_Type is new Gtk_Message_Type_Properties.Property;

Secondary_Text_Property

Secondary_Text_Property : constant Glib.Properties.Property_String;

The secondary text of the message dialog.

Secondary_Use_Markup_Property

Secondary_Use_Markup_Property : constant Glib.Properties.Property_Boolean;

True if the secondary text of the dialog includes Pango markup. See pango_parse_markup.

Set_Image

procedure Set_Image
   (Dialog : not null access Gtk_Message_Dialog_Record;
    Image  : not null access Gtk.Widget.Gtk_Widget_Record'Class)

Sets the dialog's image to Image. Since: gtk+ 2.10 Deprecated since 3.12, 1

Parameters
Dialog
Image

the image

Set_Markup

procedure Set_Markup
   (Dialog : not null access Gtk_Message_Dialog_Record;
    Str    : UTF8_String)

Sets the text of the message dialog to be Str, which is marked up with the [Pango text markup language][PangoMarkupFormat]. Since: gtk+ 2.4

Parameters
Dialog
Str

markup string (see [Pango markup format][PangoMarkupFormat])

Text_Property

Text_Property : constant Glib.Properties.Property_String;

The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.

Use_Markup_Property

Use_Markup_Property : constant Glib.Properties.Property_Boolean;

True if the primary text of the dialog includes Pango markup. See pango_parse_markup.