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.

  • ptr

    Untyped pointer to the underlying GtkNativeDialog instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • native_dialog_ptr Default implementation

    Typed 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)

NativeDialog Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

NativeDialog signals

  • Connect a Swift signal handler to the given, typed NativeDialogSignalName signal

    Declaration

    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 by userData

    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 a C signal handler to the given, typed NativeDialogSignalName signal

    Declaration

    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 by userData

    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:handler:) Extension method

    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 underlying response signal

    Declaration

    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 method

    Typed response signal for using the connect(signal:) methods

    Declaration

    Swift

    static var responseSignal: NativeDialogSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::modal signal

    Declaration

    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 method

    Typed notify::modal signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyModalSignal: NativeDialogSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::title signal

    Declaration

    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 method

    Typed notify::title signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyTitleSignal: NativeDialogSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::transient-for signal

    Declaration

    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 method

    Typed notify::transient-for signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyTransientForSignal: NativeDialogSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::visible signal

    Declaration

    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 method

    Typed notify::visible signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyVisibleSignal: NativeDialogSignalName { get }

NativeDialog Class: NativeDialogProtocol extension (methods and fields)

  • destroy() Extension method

    Destroys 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 method

    Returns whether the dialog is modal. See gtk_native_dialog_set_modal().

    Declaration

    Swift

    @inlinable
    func getModal() -> Bool
  • getTitle() Extension method

    Gets the title of the GtkNativeDialog.

    Declaration

    Swift

    @inlinable
    func getTitle() -> String!
  • getTransientFor() Extension method

    Fetches the transient parent for this window. See gtk_native_dialog_set_transient_for().

    Declaration

    Swift

    @inlinable
    func getTransientFor() -> WindowRef!
  • getVisible() Extension method

    Determines whether the dialog is visible.

    Declaration

    Swift

    @inlinable
    func getVisible() -> Bool
  • hide() Extension method

    Hides 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 to gtk_native_dialog_show().

    If the dialog is not visible this does nothing.

    Declaration

    Swift

    @inlinable
    func hide()
  • run() Extension method

    Blocks in a recursive main loop until self emits the GtkNativeDialog::response signal. It then returns the response ID from the response signal emission.

    Before entering the recursive main loop, gtk_native_dialog_run() calls gtk_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 for parent 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 for parent unsets the current transient window.

    Declaration

    Swift

    @inlinable
    func setTransientFor<WindowT>(parent: WindowT?) where WindowT : WindowProtocol
  • show() Extension method

    Shows 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 method

    Whether the window should be modal with respect to its transient parent.

    Declaration

    Swift

    @inlinable
    var modal: Bool { get nonmutating set }
  • title Extension method

    The title of the dialog window

    Declaration

    Swift

    @inlinable
    var title: String! { get nonmutating set }
  • transientFor Extension method

    Fetches the transient parent for this window. See gtk_native_dialog_set_transient_for().

    Declaration

    Swift

    @inlinable
    var transientFor: WindowRef! { get nonmutating set }
  • visible Extension method

    Whether the window is currenlty visible.

    Declaration

    Swift

    @inlinable
    var visible: Bool { get }
  • parentInstance Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parentInstance: GObject { get }