WindowRef

public struct WindowRef : WindowProtocol, GWeakCapturing

A GtkWindow is a toplevel window which can contain other widgets.

An example GtkWindow

Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,…).

GtkWindow as GtkBuildable

The GtkWindow implementation of the [ifaceGtk.Buildable] interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a <child> element.

CSS nodes

window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
├── &lt;child&gt;
╰── &lt;titlebar child&gt;.titlebar [.default-decoration]

GtkWindow has a main CSS node with name window and style class .background.

Style classes that are typically used with the main CSS node are .csd (when client-side decorations are in use), .solid-csd (for client-side decorations without invisible borders), .ssd (used by mutter when rendering server-side decorations). GtkWindow also represents window states with the following style classes on the main node: .maximized, .fullscreen, .tiled (when supported, also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).

GtkWindow subclasses often add their own discriminating style classes, such as .dialog, .popup or .tooltip.

Generally, some CSS properties don’t make sense on the toplevel window node, such as margins or padding. When client-side decorations without invisible borders are in use (i.e. the .solid-csd style class is added to the main window node), the CSS border of the toplevel window is used for resize drags. In the .csd case, the shadow area outside of the window can be used to resize it.

GtkWindow adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.

Accessibility

GtkWindow uses the GTK_ACCESSIBLE_ROLE_WINDOW role.

The WindowRef type acts as a lightweight Swift reference to an underlying GtkWindow instance. It exposes methods that can operate on this data type through WindowProtocol conformance. Use WindowRef only as an unowned reference to an existing GtkWindow instance.

  • ptr
    Untyped pointer to the underlying `GtkWindow` instance.
    

    For type-safe access, use the generated, typed pointer window_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

Window Class

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GtkWindow>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GtkWindow>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GtkWindow>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GtkWindow>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements WindowProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : WindowProtocol
  • This factory is syntactic sugar for setting weak pointers wrapped in GWeak<T>

    Declaration

    Swift

    @inlinable
    static func unowned<T>(_ other: T) -> WindowRef where T : WindowProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to WindowProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to WindowProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to WindowProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to WindowProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to WindowProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • Creates a new `GtkWindow`.
    

    To get an undecorated window (no window borders), use [methodGtk.Window.set_decorated].

    All top-level windows created by gtk_window_new() are stored in an internal top-level window list. This list can be obtained from [funcGtk.Window.list_toplevels]. Due to GTK keeping a reference to the window internally, gtk_window_new() does not return a reference to the caller.

    To delete a GtkWindow, call [methodGtk.Window.destroy].

    Declaration

    Swift

    @inlinable
    init()