[]Struct gtk::WidgetPath

pub struct WidgetPath(_);

WidgetPath 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::get_path, and the style context returned by WidgetExt::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.

Implementations

impl WidgetPath[src]

pub fn new() -> WidgetPath[src]

Returns an empty widget path.

Returns

A newly created, empty, WidgetPath

pub fn append_for_widget<P: IsA<Widget>>(&self, widget: &P) -> i32[src]

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

pub fn append_type(&self, type_: Type) -> i32[src]

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

type_

widget type to append

Returns

the position where the element was inserted

pub fn append_with_siblings(
    &self,
    siblings: &WidgetPath,
    sibling_index: u32
) -> i32
[src]

Appends a widget type with all its siblings to the widget hierarchy represented by self. Using this function instead of WidgetPath::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.

pub fn copy(&self) -> Option<WidgetPath>[src]

Returns a copy of self

Returns

a copy of self

pub fn get_object_type(&self) -> Type[src]

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

Returns

The object type

pub fn has_parent(&self, type_: Type) -> bool[src]

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

type_

widget type to check in parents

Returns

true if any parent is of type type_

pub fn is_type(&self, type_: Type) -> bool[src]

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

type_

widget type to match

Returns

true if the widget represented by self is of type type_

pub fn iter_add_class(&self, pos: i32, name: &str)[src]

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

pub fn iter_clear_classes(&self, pos: i32)[src]

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

pos

position to modify, -1 for the path head

pub fn iter_get_name(&self, pos: i32) -> Option<GString>[src]

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

pos

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

Returns

The widget name, or None if none was set.

pub fn iter_get_object_name(&self, pos: i32) -> Option<GString>[src]

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

Feature: v3_20

pos

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

Returns

the name or None

pub fn iter_get_object_type(&self, pos: i32) -> Type[src]

Returns the object glib::Type that is at position pos in the widget hierarchy defined in self.

pos

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

Returns

a widget type

pub fn iter_get_sibling_index(&self, pos: i32) -> u32[src]

Returns the index into the list of siblings for the element at pos as returned by WidgetPath::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.

pub fn iter_get_siblings(&self, pos: i32) -> Option<WidgetPath>[src]

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

pos

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

Returns

None or the list of siblings for the element at pos.

pub fn iter_get_state(&self, pos: i32) -> StateFlags[src]

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

pos

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

Returns

The state flags

pub fn iter_has_class(&self, pos: i32, name: &str) -> bool[src]

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

pos

position to query, -1 for the path head

name

class name

Returns

true if the class name is defined for the widget at pos

pub fn iter_has_name(&self, pos: i32, name: &str) -> bool[src]

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

pos

position to query, -1 for the path head

name

a widget name

Returns

true if the widget at pos has this name

pub fn iter_has_qclass(&self, pos: i32, qname: Quark) -> bool[src]

See WidgetPath::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 glib::Quark

Returns

true if the widget at pos has the class defined.

pub fn iter_has_qname(&self, pos: i32, qname: Quark) -> bool[src]

See WidgetPath::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 glib::Quark

Returns

true if the widget at pos has this name

pub fn iter_list_classes(&self, pos: i32) -> Vec<GString>[src]

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 glib::SList contents are owned by GTK+, but you should use glib::SList::free to free the list itself.

pub fn iter_remove_class(&self, pos: i32, name: &str)[src]

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

pos

position to modify, -1 for the path head

name

class name

pub fn iter_set_name(&self, pos: i32, name: &str)[src]

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

pos

position to modify, -1 for the path head

name

widget name

pub fn iter_set_object_name(&self, pos: i32, name: Option<&str>)[src]

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

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

Feature: v3_20

pos

position to modify, -1 for the path head

name

object name to set or None to unset

pub fn iter_set_object_type(&self, pos: i32, type_: Type)[src]

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

pos

position to modify, -1 for the path head

type_

object type to set

pub fn iter_set_state(&self, pos: i32, state: StateFlags)[src]

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

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);

pos

position to modify, -1 for the path head

state

state flags

pub fn length(&self) -> i32[src]

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

Returns

the number of elements in the path

pub fn prepend_type(&self, type_: Type)[src]

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

type_

widget type to prepend

Trait Implementations

impl Clone for WidgetPath

impl Debug for WidgetPath[src]

impl Default for WidgetPath[src]

impl Display for WidgetPath[src]

impl Eq for WidgetPath[src]

impl Hash for WidgetPath[src]

impl Ord for WidgetPath[src]

impl PartialEq<WidgetPath> for WidgetPath[src]

impl PartialOrd<WidgetPath> for WidgetPath[src]

impl StaticType for WidgetPath

impl StructuralEq for WidgetPath[src]

impl StructuralPartialEq for WidgetPath[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.