MessageDialog


Object Hierarchy:

Gtk.MessageDialog Gtk.MessageDialog Gtk.MessageDialog Gtk.Dialog Gtk.Dialog Gtk.Dialog->Gtk.MessageDialog Gtk.Window Gtk.Window Gtk.Window->Gtk.Dialog Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Window GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Gtk.Accessible Gtk.Accessible Gtk.Accessible->Gtk.MessageDialog Gtk.Accessible->Gtk.Dialog Gtk.Accessible->Gtk.Window Gtk.Accessible->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.MessageDialog Gtk.Buildable->Gtk.Dialog Gtk.Buildable->Gtk.Window Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget Gtk.ConstraintTarget Gtk.ConstraintTarget->Gtk.MessageDialog Gtk.ConstraintTarget->Gtk.Dialog Gtk.ConstraintTarget->Gtk.Window Gtk.ConstraintTarget->Gtk.Widget Gtk.Native Gtk.Native Gtk.Native->Gtk.MessageDialog Gtk.Native->Gtk.Dialog Gtk.Native->Gtk.Window Gtk.Root Gtk.Root Gtk.Root->Gtk.MessageDialog Gtk.Root->Gtk.Dialog Gtk.Root->Gtk.Window Gtk.ShortcutManager Gtk.ShortcutManager Gtk.ShortcutManager->Gtk.MessageDialog Gtk.ShortcutManager->Gtk.Dialog Gtk.ShortcutManager->Gtk.Window

Description:

[ CCode ( type_id = "gtk_message_dialog_get_type ()" ) ]
[ Version ( deprecated = true , deprecated_since = "4.10" ) ]
public class MessageDialog : Dialog, Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager

Warning: MessageDialog is deprecated since 4.10.

`GtkMessageDialog` presents a dialog with some message text.

Note:

Use [class@Gtk.AlertDialog] instead

![An example GtkMessageDialog](messagedialog.png)

It’s simply a convenience widget; you could construct the equivalent of `GtkMessageDialog` from `GtkDialog` without too much effort, but `GtkMessageDialog` saves typing.

The easiest way to do a modal message dialog is to use the gtk_dialog_modal flag, which will call [ method@Gtk.Window.set_modal] internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the [signal@Gtk.Dialog:GtkMessageDialog:response] signal to know when the user dismissed the dialog.

An example for using a modal dialog: ```c GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL; 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 (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL); ```

You might do a non-modal `GtkMessageDialog` simply by omitting the gtk_dialog_modal flag:

```c 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 (dialog, "response", G_CALLBACK ( gtk_window_destroy), NULL); ```

GtkMessageDialog as GtkBuildable

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


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Gtk.Native
All known members inherited from interface Gtk.Root
All known members inherited from interface Gtk.ShortcutManager