WidgetPathProtocol

public protocol WidgetPathProtocol

GtkWidgetPath is a boxed type that represents a widget hierarchy from the topmost widget, typically a toplevel, to any child. This widget path abstraction is used in GtkStyleContext on behalf of the real widget in order to query style information.

If you are using GTK+ widgets, you probably will not need to use this API directly, as there is gtk_widget_get_path(), and the style context returned by gtk_widget_get_style_context() will be automatically updated on widget hierarchy changes.

The widget path generation is generally simple:

Defining a button within a window

(C Language Example):

{
  GtkWidgetPath *path;

  path = gtk_widget_path_new ();
  gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
  gtk_widget_path_append_type (path, GTK_TYPE_BUTTON);
}

Although more complex information, such as widget names, or different classes (property that may be used by other widget types) and intermediate regions may be included:

Defining the first tab widget in a notebook

(C Language Example):

{
  GtkWidgetPath *path;
  guint pos;

  path = gtk_widget_path_new ();

  pos = gtk_widget_path_append_type (path, GTK_TYPE_NOTEBOOK);
  gtk_widget_path_iter_add_region (path, pos, "tab", GTK_REGION_EVEN | GTK_REGION_FIRST);

  pos = gtk_widget_path_append_type (path, GTK_TYPE_LABEL);
  gtk_widget_path_iter_set_name (path, pos, "first tab label");
}

All this information will be used to match the style information that applies to the described widget.

The WidgetPathProtocol protocol exposes the methods and properties of an underlying GtkWidgetPath 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 WidgetPath. Alternatively, use WidgetPathRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkWidgetPath instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkWidgetPath instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkWidgetPath instance.

    Declaration

    Swift

    var widget_path_ptr: UnsafeMutablePointer<GtkWidgetPath>! { get }
  • Required Initialiser for types conforming to WidgetPathProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

WidgetPath Record: WidgetPathProtocol extension (methods and fields)

  • appendFor(widget:) Extension method

    Appends the data from widget to the widget hierarchy represented by path. This function is a shortcut for adding information from widget to the given path. This includes setting the name or adding the style classes from widget.

    Declaration

    Swift

    @inlinable
    func appendFor<WidgetT>(widget: WidgetT) -> Int where WidgetT : WidgetProtocol
  • append(type:) Extension method

    Appends a widget type to the widget hierarchy represented by path.

    Declaration

    Swift

    @inlinable
    func append(type: GType) -> Int
  • Appends a widget type with all its siblings to the widget hierarchy represented by path. Using this function instead of gtk_widget_path_append_type() will allow the CSS theming to use sibling matches in selectors and apply :nth-child() pseudo classes. In turn, it requires a lot more care in widget implementations as widgets need to make sure to call gtk_widget_reset_style() on all involved widgets when the siblings path changes.

    Declaration

    Swift

    @inlinable
    func appendWith<WidgetPathT>(siblings: WidgetPathT, siblingIndex: Int) -> Int where WidgetPathT : WidgetPathProtocol
  • copy() Extension method

    Returns a copy of path

    Declaration

    Swift

    @inlinable
    func copy() -> WidgetPathRef!
  • free() Extension method

    Decrements the reference count on path, freeing the structure if the reference count reaches 0.

    Declaration

    Swift

    @inlinable
    func free()
  • getObjectType() Extension method

    Returns the topmost object type, that is, the object type this path is representing.

    Declaration

    Swift

    @inlinable
    func getObjectType() -> GType
  • hasParent(type:) Extension method

    Returns true if any of the parents of the widget represented in path is of type type, or any subtype of it.

    Declaration

    Swift

    @inlinable
    func hasParent(type: GType) -> Bool
  • is_(type:) Extension method

    Returns true if the widget type represented by this path is type, or a subtype of it.

    Declaration

    Swift

    @inlinable
    func is_(type: GType) -> Bool
  • iterAddClass(pos:name:) Extension method

    Adds the class name to the widget at position pos in the hierarchy defined in path. See gtk_style_context_add_class().

    Declaration

    Swift

    @inlinable
    func iterAddClass(pos: Int, name: UnsafePointer<gchar>!)
  • Adds the region name to the widget at position pos in the hierarchy defined in path. See gtk_style_context_add_region().

    Region names must only contain lowercase letters and “-”, starting always with a lowercase letter.

    iter_add_region is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterAddRegion(pos: Int, name: UnsafePointer<gchar>!, flags: RegionFlags)
  • iterClearClasses(pos:) Extension method

    Removes all classes from the widget at position pos in the hierarchy defined in path.

    Declaration

    Swift

    @inlinable
    func iterClearClasses(pos: Int)
  • iterClearRegions(pos:) Extension method

    Removes all regions from the widget at position pos in the hierarchy defined in path.

    iter_clear_regions is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterClearRegions(pos: Int)
  • iterGetName(pos:) Extension method

    Returns the name corresponding to the widget found at the position pos in the widget hierarchy defined by path

    Declaration

    Swift

    @inlinable
    func iterGetName(pos: Int) -> String!
  • iterGetObjectName(pos:) Extension method

    Returns the object name that is at position pos in the widget hierarchy defined in path.

    Declaration

    Swift

    @inlinable
    func iterGetObjectName(pos: Int) -> String!
  • iterGetObjectType(pos:) Extension method

    Returns the object GType that is at position pos in the widget hierarchy defined in path.

    Declaration

    Swift

    @inlinable
    func iterGetObjectType(pos: Int) -> GType
  • iterGetSiblingIndex(pos:) Extension method

    Returns the index into the list of siblings for the element at pos as returned by gtk_widget_path_iter_get_siblings(). If that function would return nil because the element at pos has no siblings, this function will return 0.

    Declaration

    Swift

    @inlinable
    func iterGetSiblingIndex(pos: Int) -> Int
  • iterGetSiblings(pos:) Extension method

    Returns the list of siblings for the element at pos. If the element was not added with siblings, nil is returned.

    Declaration

    Swift

    @inlinable
    func iterGetSiblings(pos: Int) -> WidgetPathRef!
  • iterGetState(pos:) Extension method

    Returns the state flags corresponding to the widget found at the position pos in the widget hierarchy defined by path

    Declaration

    Swift

    @inlinable
    func iterGetState(pos: Int) -> StateFlags
  • iterHasClass(pos:name:) Extension method

    Returns true if the widget at position pos has the class name defined, false otherwise.

    Declaration

    Swift

    @inlinable
    func iterHasClass(pos: Int, name: UnsafePointer<gchar>!) -> Bool
  • iterHasName(pos:name:) Extension method

    Returns true if the widget at position pos has the name name, false otherwise.

    Declaration

    Swift

    @inlinable
    func iterHasName(pos: Int, name: UnsafePointer<gchar>!) -> Bool
  • iterHasQclass(pos:qname:) Extension method

    See gtk_widget_path_iter_has_class(). This is a version that operates with GQuarks.

    Declaration

    Swift

    @inlinable
    func iterHasQclass(pos: Int, qname: GQuark) -> Bool
  • iterHasQname(pos:qname:) Extension method

    See gtk_widget_path_iter_has_name(). This is a version that operates on GQuarks.

    Declaration

    Swift

    @inlinable
    func iterHasQname(pos: Int, qname: GQuark) -> Bool
  • See gtk_widget_path_iter_has_region(). This is a version that operates with GQuarks.

    iter_has_qregion is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterHasQregion(pos: Int, qname: GQuark, flags: UnsafeMutablePointer<GtkRegionFlags>!) -> Bool
  • Returns true if the widget at position pos has the class name defined, false otherwise.

    iter_has_region is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterHasRegion(pos: Int, name: UnsafePointer<gchar>!, flags: UnsafeMutablePointer<GtkRegionFlags>!) -> Bool
  • iterListClasses(pos:) Extension method

    Returns a list with all the class names defined for the widget at position pos in the hierarchy defined in path.

    Declaration

    Swift

    @inlinable
    func iterListClasses(pos: Int) -> GLib.SListRef!
  • iterListRegions(pos:) Extension method

    Returns a list with all the region names defined for the widget at position pos in the hierarchy defined in path.

    iter_list_regions is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterListRegions(pos: Int) -> GLib.SListRef!
  • iterRemoveClass(pos:name:) Extension method

    Removes the class name from the widget at position pos in the hierarchy defined in path.

    Declaration

    Swift

    @inlinable
    func iterRemoveClass(pos: Int, name: UnsafePointer<gchar>!)
  • iterRemoveRegion(pos:name:) Extension method

    Removes the region name from the widget at position pos in the hierarchy defined in path.

    iter_remove_region is deprecated: The use of regions is deprecated.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func iterRemoveRegion(pos: Int, name: UnsafePointer<gchar>!)
  • iterSetName(pos:name:) Extension method

    Sets the widget name for the widget found at position pos in the widget hierarchy defined by path.

    Declaration

    Swift

    @inlinable
    func iterSetName(pos: Int, name: UnsafePointer<gchar>!)
  • iterSetObjectName(pos:name:) Extension method

    Sets the object name for a given position in the widget hierarchy defined by path.

    When set, the object name overrides the object type when matching CSS.

    Declaration

    Swift

    @inlinable
    func iterSetObjectName(pos: Int, name: UnsafePointer<CChar>? = nil)
  • iterSetObjectType(pos:type:) Extension method

    Sets the object type for a given position in the widget hierarchy defined by path.

    Declaration

    Swift

    @inlinable
    func iterSetObjectType(pos: Int, type: GType)
  • iterSetState(pos:state:) Extension method

    Sets the widget name for the widget found at position pos in the widget hierarchy defined by path.

    If you want to update just a single state flag, you need to do this manually, as this function updates all state flags.

    Setting a flag

    (C Language Example):

    gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) | flag);
    

    Unsetting a flag

    (C Language Example):

    gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) & ~flag);
    

    Declaration

    Swift

    @inlinable
    func iterSetState(pos: Int, state: StateFlags)
  • length() Extension method

    Returns the number of GtkWidget GTypes between the represented widget and its topmost container.

    Declaration

    Swift

    @inlinable
    func length() -> Int
  • prepend(type:) Extension method

    Prepends a widget type to the widget hierachy represented by path.

    Declaration

    Swift

    @inlinable
    func prepend(type: GType)
  • ref() Extension method

    Increments the reference count on path.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> WidgetPathRef!
  • toString() Extension method

    Dumps the widget path into a string representation. It tries to match the CSS style as closely as possible (Note that there might be paths that cannot be represented in CSS).

    The main use of this code is for debugging purposes, so that you can g_print() the path or dump it in a gdb session.

    Declaration

    Swift

    @inlinable
    func toString() -> String!
  • unref() Extension method

    Decrements the reference count on path, freeing the structure if the reference count reaches 0.

    Declaration

    Swift

    @inlinable
    func unref()
  • objectType Extension method

    Returns the topmost object type, that is, the object type this path is representing.

    Declaration

    Swift

    @inlinable
    var objectType: GType { get }