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.
-
Untyped pointer to the underlying
GtkWidgetPath
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
widget_path_ptr
Default implementationTyped 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)
-
appendFor(widget:
Extension method) Appends the data from
widget
to the widget hierarchy represented bypath
. This function is a shortcut for adding information fromwidget
to the givenpath
. This includes setting the name or adding the style classes fromwidget
.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
-
appendWith(siblings:
Extension methodsiblingIndex: ) Appends a widget type with all its siblings to the widget hierarchy represented by
path
. Using this function instead ofgtk_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 callgtk_widget_reset_style()
on all involved widgets when thesiblings
path changes.Declaration
Swift
@inlinable func appendWith<WidgetPathT>(siblings: WidgetPathT, siblingIndex: Int) -> Int where WidgetPathT : WidgetPathProtocol
-
copy()
Extension methodReturns a copy of
path
Declaration
Swift
@inlinable func copy() -> WidgetPathRef!
-
free()
Extension methodDecrements the reference count on
path
, freeing the structure if the reference count reaches 0.Declaration
Swift
@inlinable func free()
-
getObjectType()
Extension methodReturns 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 inpath
is of typetype
, 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 istype
, or a subtype of it.Declaration
Swift
@inlinable func is_(type: GType) -> Bool
-
iterAddClass(pos:
Extension methodname: ) Adds the class
name
to the widget at positionpos
in the hierarchy defined inpath
. Seegtk_style_context_add_class()
.Declaration
Swift
@inlinable func iterAddClass(pos: Int, name: UnsafePointer<gchar>!)
-
iterAddRegion(pos:
Extension methodname: flags: ) Adds the region
name
to the widget at positionpos
in the hierarchy defined inpath
. Seegtk_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 inpath
.Declaration
Swift
@inlinable func iterClearClasses(pos: Int)
-
iterClearRegions(pos:
Extension method) Removes all regions from the widget at position
pos
in the hierarchy defined inpath
.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 bypath
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 inpath
.Declaration
Swift
@inlinable func iterGetObjectName(pos: Int) -> String!
-
iterGetObjectType(pos:
Extension method) Returns the object
GType
that is at positionpos
in the widget hierarchy defined inpath
.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 bygtk_widget_path_iter_get_siblings()
. If that function would returnnil
because the element atpos
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 bypath
Declaration
Swift
@inlinable func iterGetState(pos: Int) -> StateFlags
-
iterHasClass(pos:
Extension methodname: ) Returns
true
if the widget at positionpos
has the classname
defined,false
otherwise.Declaration
Swift
@inlinable func iterHasClass(pos: Int, name: UnsafePointer<gchar>!) -> Bool
-
iterHasName(pos:
Extension methodname: ) Returns
true
if the widget at positionpos
has the namename
,false
otherwise.Declaration
Swift
@inlinable func iterHasName(pos: Int, name: UnsafePointer<gchar>!) -> Bool
-
iterHasQclass(pos:
Extension methodqname: ) 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:
Extension methodqname: ) See
gtk_widget_path_iter_has_name()
. This is a version that operates onGQuarks
.Declaration
Swift
@inlinable func iterHasQname(pos: Int, qname: GQuark) -> Bool
-
iterHasQregion(pos:
Extension methodqname: flags: ) 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
-
iterHasRegion(pos:
Extension methodname: flags: ) Returns
true
if the widget at positionpos
has the classname
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 inpath
.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 inpath
.iter_list_regions is deprecated: The use of regions is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func iterListRegions(pos: Int) -> GLib.SListRef!
-
iterRemoveClass(pos:
Extension methodname: ) Removes the class
name
from the widget at positionpos
in the hierarchy defined inpath
.Declaration
Swift
@inlinable func iterRemoveClass(pos: Int, name: UnsafePointer<gchar>!)
-
iterRemoveRegion(pos:
Extension methodname: ) Removes the region
name
from the widget at positionpos
in the hierarchy defined inpath
.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:
Extension methodname: ) Sets the widget name for the widget found at position
pos
in the widget hierarchy defined bypath
.Declaration
Swift
@inlinable func iterSetName(pos: Int, name: UnsafePointer<gchar>!)
-
iterSetObjectName(pos:
Extension methodname: ) 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:
Extension methodtype: ) 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:
Extension methodstate: ) Sets the widget name for the widget found at position
pos
in the widget hierarchy defined bypath
.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 methodReturns 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 methodIncrements the reference count on
path
.Declaration
Swift
@discardableResult @inlinable func ref() -> WidgetPathRef!
-
toString()
Extension methodDumps 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 methodDecrements the reference count on
path
, freeing the structure if the reference count reaches 0.Declaration
Swift
@inlinable func unref()
-
objectType
Extension methodReturns the topmost object type, that is, the object type this path is representing.
Declaration
Swift
@inlinable var objectType: GType { get }