Struct gtk::WidgetPath [−][src]
pub struct WidgetPath(_);
Expand description
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 StyleContext
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 WidgetExt::path()
, and the style
context returned by WidgetExt::style_context()
will be automatically
updated on widget hierarchy changes.
The widget path generation is generally simple:
Defining a button within a window
⚠️ The following code is in C ⚠️
{
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
⚠️ The following code is in C ⚠️
{
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.
Implementations
Appends the data from widget
to the widget hierarchy represented
by self
. This function is a shortcut for adding information from
widget
to the given self
. This includes setting the name or
adding the style classes from widget
.
widget
the widget to append to the widget path
Returns
the position where the data was inserted
Appends a widget type with all its siblings to the widget hierarchy
represented by self
. Using this function instead of
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 WidgetExt::reset_style()
on all
involved widgets when the siblings
path changes.
siblings
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
index into siblings
for where the added element is
positioned.
Returns
the position where the element was inserted.
Returns the topmost object type, that is, the object type this path is representing.
Returns
The object type
Adds the class name
to the widget at position pos
in
the hierarchy defined in self
. See
StyleContextExt::add_class()
.
pos
position to modify, -1 for the path head
name
a class name
Removes all classes from the widget at position pos
in the
hierarchy defined in self
.
pos
position to modify, -1 for the path head
This is supported on crate feature v3_20
only.
v3_20
only.Returns the index into the list of siblings for the element at pos
as
returned by iter_get_siblings()
. If that function would
return None
because the element at pos
has no siblings, this function
will return 0.
pos
position to get the sibling index for, -1 for the path head
Returns
0 or the index into the list of siblings for the element at pos
.
See iter_has_class()
. This is a version that operates
with GQuarks.
pos
position to query, -1 for the path head
qname
class name as a GQuark
Returns
true
if the widget at pos
has the class defined.
See iter_has_name()
. This is a version
that operates on GQuarks
.
pos
position to query, -1 for the path head
qname
widget name as a GQuark
Returns
true
if the widget at pos
has this name
Returns a list with all the class names defined for the widget
at position pos
in the hierarchy defined in self
.
pos
position to query, -1 for the path head
Returns
The list of
classes, This is a list of strings, the GSList
contents
are owned by GTK+, but you should use g_slist_free()
to
free the list itself.
This is supported on crate feature v3_20
only.
v3_20
only.Sets the widget name for the widget found at position pos
in the widget hierarchy defined by self
.
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
⚠️ The following code is in C ⚠️
gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) | flag);
Unsetting a flag
⚠️ The following code is in C ⚠️
gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) & ~flag);
pos
position to modify, -1 for the path head
state
state flags
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for WidgetPath
impl !Send for WidgetPath
impl !Sync for WidgetPath
impl Unpin for WidgetPath
impl UnwindSafe for WidgetPath
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,