MessageDialogProtocol
public protocol MessageDialogProtocol : DialogProtocol
GtkMessageDialog
presents a dialog with some message text. It’s simply a
convenience widget; you could construct the equivalent of GtkMessageDialog
from GtkDialog
without too much effort, but GtkMessageDialog
saves typing.
One difference from GtkDialog
is that GtkMessageDialog
sets the
GtkWindow: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: (C Language Example):
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 GtkMessageDialog
as follows:
An example for a non-modal dialog: (C Language Example):
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”.
The MessageDialogProtocol
protocol exposes the methods and properties of an underlying GtkMessageDialog
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see MessageDialog
.
Alternatively, use MessageDialogRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkMessageDialog
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
message_dialog_ptr
Default implementationTyped pointer to the underlying
GtkMessageDialog
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMessageDialog
instance.Declaration
Swift
var message_dialog_ptr: UnsafeMutablePointer<GtkMessageDialog>! { get }
-
Required Initialiser for types conforming to
MessageDialogProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MessageDialogPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: MessageDialogPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a MessageDialog property
Declaration
Swift
@inlinable func get(property: MessageDialogPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a MessageDialog property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: MessageDialogPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
getImage()
Extension methodGets the dialog’s image.
get_image is deprecated: Use #GtkDialog for dialogs with images
Declaration
Swift
@available(*, deprecated) @inlinable func getImage() -> WidgetRef!
-
getMessageArea()
Extension methodReturns 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 parentGtkDialog
.Declaration
Swift
@inlinable func getMessageArea() -> WidgetRef!
-
set(image:
Extension method) Sets the dialog’s image to
image
.set_image is deprecated: Use #GtkDialog to create dialogs with images
Declaration
Swift
@available(*, deprecated) @inlinable func set<WidgetT>(image: WidgetT) where WidgetT : WidgetProtocol
-
set(markup:
Extension method) Sets the text of the message dialog to be
str
, which is marked up with the Pango text markup language.Declaration
Swift
@inlinable func set(markup str: UnsafePointer<gchar>!)
-
image
Extension methodThe image for this dialog.
image is deprecated: Use #GtkDialog to create dialogs with images
Declaration
Swift
@inlinable var image: WidgetRef! { get nonmutating set }
-
messageArea
Extension methodReturns 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 parentGtkDialog
.Declaration
Swift
@inlinable var messageArea: WidgetRef! { get }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GtkDialog { get }
-
set(secondaryText:
Extension method) Convenience method to set the secondary text of a message dialog
Declaration
Swift
@inlinable func set(secondaryText: String)
Parameters
secondaryText
string to set the secondary text to
-
set(secondaryMarkup:
Extension method) Convenience method to set markup for the secondary text of of a message dialog
Declaration
Swift
@inlinable func set(secondaryMarkup: String)
Parameters
secondaryText
string to set the secondary text to