NativeDialogProtocol
public protocol NativeDialogProtocol : ObjectProtocol
Native dialogs are platform dialogs that don’t use GtkDialog.
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 [classGtk.Dialog] 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 [signalGtk.NativeDialog::response] signal when the user
finished with the dialog.
Note that unlike GtkDialog, GtkNativeDialog objects are not
toplevel widgets, and GTK does not keep them alive. It is your
responsibility to keep a reference until you are done with the
object.
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
GtkNativeDialoginstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
native_dialog_ptrDefault implementationTyped pointer to the underlying
GtkNativeDialoginstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkNativeDialoginstance.Declaration
Swift
var native_dialog_ptr: UnsafeMutablePointer<GtkNativeDialog>! { get } -
Required Initialiser for types conforming to
NativeDialogProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
NativeDialogPropertyNamesource 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a NativeDialog property
Declaration
Swift
@inlinable func get(property: NativeDialogPropertyName) -> GLibObject.ValueParameters
propertythe 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
propertythe 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
NativeDialogSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: NativeDialogSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe 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
NativeDialogSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: NativeDialogSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe 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 [method
Gtk.NativeDialog.hide] before the user responds to the dialog this signal will not be emitted.Note
This represents the underlyingresponsesignalDeclaration
Swift
@discardableResult @inlinable func onResponse(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ responseId: Int) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
responseIdthe response ID
handlerThe signal handler to call Run the given callback whenever the
responsesignal is emitted -
responseSignalExtension methodTyped
responsesignal 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 innotifybeing 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::modalsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyModal(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyModalsignal is emitted -
notifyModalSignalExtension methodTyped
notify::modalsignal 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 innotifybeing 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::titlesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyTitle(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyTitlesignal is emitted -
notifyTitleSignalExtension methodTyped
notify::titlesignal 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 innotifybeing 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-forsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyTransientFor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyTransientForsignal is emitted -
notifyTransientForSignalExtension methodTyped
notify::transient-forsignal 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 innotifybeing 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::visiblesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyVisible(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: NativeDialogRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyVisiblesignal is emitted -
notifyVisibleSignalExtension methodTyped
notify::visiblesignal 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 theGtkNativeDialog.Declaration
Swift
@inlinable func destroy() -
getModal()Extension methodReturns whether the dialog is 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.
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 visible, aborting any interaction.
Once this is called the [signal
Gtk.NativeDialog::response] signal will not be emitted until after the next call to [methodGtk.NativeDialog.show].If the dialog is not visible this does nothing.
Declaration
Swift
@inlinable func hide() -
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 [method
Gtk.NativeDialog.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
nilforparentunsets 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
nilforparentunsets the current transient window.Declaration
Swift
@inlinable func setTransientFor<WindowT>(parent: WindowT?) where WindowT : WindowProtocol -
show()Extension methodShows the dialog on the display.
When the user accepts the state of the dialog the dialog will be automatically hidden and the [signal
Gtk.NativeDialog::response] signal will be emitted.Multiple calls while the dialog is visible will be ignored.
Declaration
Swift
@inlinable func show() -
modalExtension methodWhether the window should be modal with respect to its transient parent.
Declaration
Swift
@inlinable var modal: Bool { get nonmutating set } -
titleExtension methodThe title of the dialog window
Declaration
Swift
@inlinable var title: String! { get nonmutating set } -
transientForExtension methodFetches the transient parent for this window.
Declaration
Swift
@inlinable var transientFor: WindowRef! { get nonmutating set } -
visibleExtension methodWhether the window is currently visible.
Declaration
Swift
@inlinable var visible: Bool { get } -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }
View on GitHub
Install in Dash
NativeDialogProtocol Protocol Reference