NativeDialogProtocol
public protocol NativeDialogProtocol : ObjectProtocol
Native dialogs are platform dialogs that don’t use GtkDialog
or
GtkWindow
. They are used in order to integrate better with a
platform, by looking the same as other native applications and
supporting platform specific features.
The GtkDialog
functions cannot be used on such objects, but we
need a similar API in order to drive them. The GtkNativeDialog
object is an API that allows you to do this. It allows you to set
various common properties on the dialog, as well as show and hide
it and get a GtkNativeDialog::response
signal when the user finished
with the dialog.
There is also a gtk_native_dialog_run()
helper that makes it easy
to run any native dialog in a modal way with a recursive mainloop,
similar to gtk_dialog_run()
.
The NativeDialogProtocol
protocol exposes the methods and properties of an underlying GtkNativeDialog
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 NativeDialog
.
Alternatively, use NativeDialogRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkNativeDialog
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
native_dialog_ptr
Default implementationTyped pointer to the underlying
GtkNativeDialog
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkNativeDialog
instance.Declaration
Swift
var native_dialog_ptr: UnsafeMutablePointer<GtkNativeDialog>! { get }
-
Required Initialiser for types conforming to
NativeDialogProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
NativeDialogPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: NativeDialogPropertyName, 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 NativeDialog property
Declaration
Swift
@inlinable func get(property: NativeDialogPropertyName) -> 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 NativeDialog property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: NativeDialogPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
NativeDialogSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: NativeDialogSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
NativeDialogSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: NativeDialogSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onResponse(flags:
Extension methodhandler: ) Emitted when the user responds to the dialog.
When this is called the dialog has been hidden.
If you call
gtk_native_dialog_hide()
before the user responds to the dialog this signal will not be emitted.Note
This represents the underlyingresponse
signalDeclaration
Swift
@discardableResult @inlinable func onResponse(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ responseID: Int) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
responseID
the response ID
handler
The signal handler to call Run the given callback whenever the
response
signal is emitted -
responseSignal
Extension methodTyped
response
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var responseSignal: NativeDialogSignalName { get }
-
onNotifyModal(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::modal
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyModal(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyModal
signal is emitted -
notifyModalSignal
Extension methodTyped
notify::modal
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyModalSignal: NativeDialogSignalName { get }
-
onNotifyTitle(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::title
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyTitle(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyTitle
signal is emitted -
notifyTitleSignal
Extension methodTyped
notify::title
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyTitleSignal: NativeDialogSignalName { get }
-
onNotifyTransientFor(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::transient-for
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyTransientFor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyTransientFor
signal is emitted -
notifyTransientForSignal
Extension methodTyped
notify::transient-for
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyTransientForSignal: NativeDialogSignalName { get }
-
onNotifyVisible(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::visible
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyVisible(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyVisible
signal is emitted -
notifyVisibleSignal
Extension methodTyped
notify::visible
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyVisibleSignal: NativeDialogSignalName { get }
-
destroy()
Extension methodDestroys a dialog.
When a dialog is destroyed, it will break any references it holds to other objects. If it is visible it will be hidden and any underlying window system resources will be destroyed.
Note that this does not release any reference to the object (as opposed to destroying a GtkWindow) because there is no reference from the windowing system to the
GtkNativeDialog
.Declaration
Swift
@inlinable func destroy()
-
getModal()
Extension methodReturns whether the dialog is modal. See
gtk_native_dialog_set_modal()
.Declaration
Swift
@inlinable func getModal() -> Bool
-
getTitle()
Extension methodGets the title of the
GtkNativeDialog
.Declaration
Swift
@inlinable func getTitle() -> String!
-
getTransientFor()
Extension methodFetches the transient parent for this window. See
gtk_native_dialog_set_transient_for()
.Declaration
Swift
@inlinable func getTransientFor() -> WindowRef!
-
getVisible()
Extension methodDetermines whether the dialog is visible.
Declaration
Swift
@inlinable func getVisible() -> Bool
-
hide()
Extension methodHides the dialog if it is visilbe, aborting any interaction. Once this is called the
GtkNativeDialog::response
signal will not be emitted until after the next call togtk_native_dialog_show()
.If the dialog is not visible this does nothing.
Declaration
Swift
@inlinable func hide()
-
run()
Extension methodBlocks in a recursive main loop until
self
emits theGtkNativeDialog::response
signal. It then returns the response ID from theresponse
signal emission.Before entering the recursive main loop,
gtk_native_dialog_run()
callsgtk_native_dialog_show()
on the dialog for you.After
gtk_native_dialog_run()
returns, then dialog will be hidden.Typical usage of this function might be: (C Language Example):
gint result = gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: do_application_specific_something (); break; default: do_nothing_since_dialog_was_cancelled (); break; } g_object_unref (dialog);
Note that even though the recursive main loop gives the effect of a modal dialog (it prevents the user from interacting with other windows in the same window group while the dialog is run), callbacks such as timeouts, IO channel watches, DND drops, etc, will be triggered during a
gtk_native_dialog_run()
call.Declaration
Swift
@inlinable func run() -> Int
-
set(modal:
Extension method) Sets a dialog modal or non-modal. Modal dialogs prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use
gtk_native_dialog_set_transient_for()
to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.Declaration
Swift
@inlinable func set(modal: Bool)
-
set(title:
Extension method) Sets the title of the
GtkNativeDialog
.Declaration
Swift
@inlinable func set(title: UnsafePointer<CChar>!)
-
setTransientFor(parent:
Extension method) Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Passing
nil
forparent
unsets the current transient window.Declaration
Swift
@inlinable func setTransientFor(parent: WindowRef? = nil)
-
setTransientFor(parent:
Extension method) Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Passing
nil
forparent
unsets the current transient window.Declaration
Swift
@inlinable func setTransientFor<WindowT>(parent: WindowT?) where WindowT : WindowProtocol
-
show()
Extension methodShows the dialog on the display, allowing the user to interact with it. When the user accepts the state of the dialog the dialog will be automatically hidden and the
GtkNativeDialog::response
signal will be emitted.Multiple calls while the dialog is visible will be ignored.
Declaration
Swift
@inlinable func show()
-
modal
Extension methodWhether the window should be modal with respect to its transient parent.
Declaration
Swift
@inlinable var modal: Bool { get nonmutating set }
-
title
Extension methodThe title of the dialog window
Declaration
Swift
@inlinable var title: String! { get nonmutating set }
-
transientFor
Extension methodFetches the transient parent for this window. See
gtk_native_dialog_set_transient_for()
.Declaration
Swift
@inlinable var transientFor: WindowRef! { get nonmutating set }
-
visible
Extension methodWhether the window is currenlty visible.
Declaration
Swift
@inlinable var visible: Bool { get }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }