Gjsify LogoGjsify Logo

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

{
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

{
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.

record

Hierarchy

  • WidgetPath

Index

Constructors

Properties

name: string

Methods

  • append_for_widget(widget: Gtk.Widget): number
  • 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.

    Parameters

    • widget: Gtk.Widget

      the widget to append to the widget path

    Returns number

  • append_type(type: GType<unknown>): number
  • Appends a widget type to the widget hierarchy represented by path.

    Parameters

    • type: GType<unknown>

      widget type to append

    Returns number

  • append_with_siblings(siblings: WidgetPath, sibling_index: number): number
  • 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.

    Parameters

    • siblings: WidgetPath

      a widget path describing a list of siblings. This path may not contain any siblings itself and it must not be modified afterwards.

    • sibling_index: number

      index into siblings for where the added element is positioned.

    Returns number

  • free(): void
  • Decrements the reference count on path, freeing the structure if the reference count reaches 0.

    Returns void

  • get_object_type(): GType<unknown>
  • has_parent(type: GType<unknown>): boolean
  • Returns %TRUE if any of the parents of the widget represented in path is of type type, or any subtype of it.

    Parameters

    • type: GType<unknown>

      widget type to check in parents

    Returns boolean

  • is_type(type: GType<unknown>): boolean
  • Returns %TRUE if the widget type represented by this path is type, or a subtype of it.

    Parameters

    • type: GType<unknown>

      widget type to match

    Returns boolean

  • iter_add_class(pos: number, name: string): void
  • Adds the class name to the widget at position pos in the hierarchy defined in path. See gtk_style_context_add_class().

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      a class name

    Returns void

  • iter_add_region(pos: number, name: string, flags: RegionFlags): void
  • 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.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      region name

    • flags: RegionFlags

      flags affecting the region

    Returns void

  • iter_clear_classes(pos: number): void
  • Removes all classes from the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    Returns void

  • iter_clear_regions(pos: number): void
  • Removes all regions from the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    Returns void

  • iter_get_name(pos: number): string
  • Returns the name corresponding to the widget found at the position pos in the widget hierarchy defined by path

    Parameters

    • pos: number

      position to get the widget name for, -1 for the path head

    Returns string

  • iter_get_object_name(pos: number): string
  • Returns the object name that is at position pos in the widget hierarchy defined in path.

    Parameters

    • pos: number

      position to get the object name for, -1 for the path head

    Returns string

  • iter_get_object_type(pos: number): GType<unknown>
  • Returns the object #GType that is at position pos in the widget hierarchy defined in path.

    Parameters

    • pos: number

      position to get the object type for, -1 for the path head

    Returns GType<unknown>

  • iter_get_sibling_index(pos: number): number
  • 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 %NULL because the element at pos has no siblings, this function will return 0.

    Parameters

    • pos: number

      position to get the sibling index for, -1 for the path head

    Returns number

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

    Parameters

    • pos: number

      position to get the siblings for, -1 for the path head

    Returns WidgetPath

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

    Parameters

    • pos: number

      position to get the state for, -1 for the path head

    Returns Gtk.StateFlags

  • iter_has_class(pos: number, name: string): boolean
  • Returns %TRUE if the widget at position pos has the class name defined, %FALSE otherwise.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • name: string

      class name

    Returns boolean

  • iter_has_name(pos: number, name: string): boolean
  • Returns %TRUE if the widget at position pos has the name name, %FALSE otherwise.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • name: string

      a widget name

    Returns boolean

  • iter_has_qclass(pos: number, qname: number): boolean
  • See gtk_widget_path_iter_has_class(). This is a version that operates with GQuarks.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • qname: number

      class name as a #GQuark

    Returns boolean

  • iter_has_qname(pos: number, qname: number): boolean
  • See gtk_widget_path_iter_has_name(). This is a version that operates on #GQuarks.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • qname: number

      widget name as a #GQuark

    Returns boolean

  • iter_has_qregion(pos: number, qname: number): [boolean, RegionFlags]
  • See gtk_widget_path_iter_has_region(). This is a version that operates with GQuarks.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • qname: number

      region name as a #GQuark

    Returns [boolean, RegionFlags]

  • iter_has_region(pos: number, name: string): [boolean, RegionFlags]
  • Returns %TRUE if the widget at position pos has the class name defined, %FALSE otherwise.

    Parameters

    • pos: number

      position to query, -1 for the path head

    • name: string

      region name

    Returns [boolean, RegionFlags]

  • iter_list_classes(pos: number): string[]
  • Returns a list with all the class names defined for the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to query, -1 for the path head

    Returns string[]

  • iter_list_regions(pos: number): string[]
  • Returns a list with all the region names defined for the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to query, -1 for the path head

    Returns string[]

  • iter_remove_class(pos: number, name: string): void
  • Removes the class name from the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      class name

    Returns void

  • iter_remove_region(pos: number, name: string): void
  • Removes the region name from the widget at position pos in the hierarchy defined in path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      region name

    Returns void

  • iter_set_name(pos: number, name: string): void
  • Sets the widget name for the widget found at position pos in the widget hierarchy defined by path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      widget name

    Returns void

  • iter_set_object_name(pos: number, name: string): void
  • 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.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • name: string

      object name to set or %NULL to unset

    Returns void

  • iter_set_object_type(pos: number, type: GType<unknown>): void
  • Sets the object type for a given position in the widget hierarchy defined by path.

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • type: GType<unknown>

      object type to set

    Returns void

  • 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

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

    Unsetting a flag

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

    Parameters

    • pos: number

      position to modify, -1 for the path head

    • state: Gtk.StateFlags

      state flags

    Returns void

  • length(): number
  • Returns the number of #GtkWidget #GTypes between the represented widget and its topmost container.

    Returns number

  • prepend_type(type: GType<unknown>): void
  • Prepends a widget type to the widget hierachy represented by path.

    Parameters

    • type: GType<unknown>

      widget type to prepend

    Returns void

  • to_string(): string
  • 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.

    Returns string

  • unref(): void
  • Decrements the reference count on path, freeing the structure if the reference count reaches 0.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method