gtkmm 3.16.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Gtk::WidgetPath Class Reference

This represents a widget hierarchy from the topmost widget, typically a toplevel, to any child. More...

`#include <gtkmm/widgetpath.h>`

## Public Member Functions

| WidgetPath ()
| WidgetPath (GtkWidgetPath* gobject, bool make_a_copy=true)
| WidgetPath (const WidgetPath& other)
WidgetPath& | operator= (const WidgetPath& other)
| ~WidgetPath ()
void | swap (WidgetPath& other)
GtkWidgetPath* | gobj ()
| Provides access to the underlying C instance. More...
const GtkWidgetPath* | gobj () const
| Provides access to the underlying C instance. More...
GtkWidgetPath* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
Glib::ustring | to_string () const
| Dumps the widget path into a string representation. More...
int | path_length () const
| Returns the number of Gtk::Widget Types between the represented widget and its topmost container. More...
int | path_append_type (GType type)
| Appends a widget type to the widget hierarchy represented by path. More...
void | prepend_type (GType type)
| Prepends a widget type to the widget hierachy represented by path. More...
GType | iter_get_object_type (int pos) const
| Returns the object Type that is at position pos in the widget hierarchy defined in path. More...
void | iter_set_object_type (int pos, GType type)
| Sets the object type for a given position in the widget hierarchy defined by path. More...
Glib::ustring | iter_get_name (int pos) const
| Returns the name corresponding to the widget found at the position pos in the widget hierarchy defined by path. More...
void | iter_set_name (int pos, const Glib::ustring& name)
| Sets the widget name for the widget found at position pos in the widget hierarchy defined by path. More...
bool | iter_has_name (int pos, const Glib::ustring& name) const
| Returns `true` if the widget at position pos has the name name, `false` otherwise. More...
WidgetPath | iter_get_siblings (int pos=-1) const
| Returns the list of siblings for the element at pos. More...
guint | get_sibling_index (int pos=-1)
| Returns the index into the list of siblings for the element at pos as returned by iter_get_siblings(). More...
void | iter_add_class (int pos, const Glib::ustring& name)
| Adds the class name to the widget at position pos in the hierarchy defined in path. More...
void | iter_remove_class (int pos, const Glib::ustring& name)
| Removes the class name from the widget at position pos in the hierarchy defined in path. More...
void | iter_clear_classes (int pos=-1)
| Removes all classes from the widget at position pos in the hierarchy defined in path. More...
std::vector< Glib::ustring > | iter_list_classes (int pos=-1) const
| Returns a list with all the class names defined for the widget at position pos in the hierarchy defined in path. More...
bool | iter_has_class (int pos, const Glib::ustring& name) const
| Returns `true` if the widget at position pos has the class name defined, `false` otherwise. More...
void | iter_add_region (int pos, const Glib::ustring& name, RegionFlags flags)
| Adds the region name to the widget at position pos in the hierarchy defined in path. More...
void | iter_remove_region (int pos, const Glib::ustring& name)
| Removes the region name from the widget at position pos in the hierarchy defined in path. More...
void | iter_clear_regions (int pos=-1)
| Removes all regions from the widget at position pos in the hierarchy defined in path. More...
std::vector< Glib::ustring > | iter_list_regions (int pos=-1) const
| Returns a list with all the region names defined for the widget at position pos in the hierarchy defined in path. More...
bool | iter_has_region (int pos, const Glib::ustring& name, RegionFlags& flags) const
| Returns `true` if the widget at position pos has the class name defined, `false` otherwise. More...
GType | get_object_type () const
| Returns the topmost object type, that is, the object type this path is representing. More...
bool | is_type (GType type) const
| Returns `true` if the widget type represented by this path is type, or a subtype of it. More...
bool | has_parent (GType type) const
| Returns `true` if any of the parents of the widget represented in path is of type type, or any subtype of it. More...

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Attributes

GtkWidgetPath* | gobject_

## Related Functions

(Note that these are not member functions.)
void | swap (WidgetPath& lhs, WidgetPath& rhs)
Gtk::WidgetPath | wrap (GtkWidgetPath* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

This 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 gtkmm widgets, you probably will not need to use this API directly, as there is Widget::get_path(), and the style context returned by Widget::get_style_context() will be automatically updated on widget hierarchy changes.

Since gtkmm 3.0:

## Constructor & Destructor Documentation

Gtk::WidgetPath::WidgetPath | ( |  | ) |

Gtk::WidgetPath::WidgetPath | ( | GtkWidgetPath * | gobject,
|  | bool | make_a_copy = `true`
| ) |  |

explicit

Gtk::WidgetPath::WidgetPath | ( | const WidgetPath& | other | ) |

Gtk::WidgetPath::~WidgetPath | ( |  | ) |

## Member Function Documentation

GType Gtk::WidgetPath::get_object_type | ( |  | ) | const

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

Since gtkmm 3.0:

Returns
  The object type.

guint Gtk::WidgetPath::get_sibling_index | ( | int | pos = `-1` | ) |

Returns the index into the list of siblings for the element at pos as returned by iter_get_siblings().

If that function would return `0` because the element at pos has no siblings, this function will return 0.

Parameters

  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.

static GType Gtk::WidgetPath::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GtkWidgetPath* Gtk::WidgetPath::gobj | ( |  | ) |

inline

Provides access to the underlying C instance.

const GtkWidgetPath* Gtk::WidgetPath::gobj | ( |  | ) | const

inline

Provides access to the underlying C instance.

GtkWidgetPath* Gtk::WidgetPath::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

bool Gtk::WidgetPath::has_parent | ( | GType | type | ) | const

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

Since gtkmm 3.0:

Parameters

  type | Widget type to check in parents.

Returns
  `true` if any parent is of type type.

bool Gtk::WidgetPath::is_type | ( | GType | type | ) | const

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

Since gtkmm 3.0:

Parameters

  type | Widget type to match.

Returns
  `true` if the widget represented by path is of type type.

void Gtk::WidgetPath::iter_add_class | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  |

Adds the class name to the widget at position pos in the hierarchy defined in path.

See Gtk::StyleContext::add_class().

Since gtkmm 3.0:

Parameters

  pos | Position to modify, -1 for the path head.
  name | A class name.

void Gtk::WidgetPath::iter_add_region | ( | int | pos,
|  | const Glib::ustring & | name,
|  | RegionFlags | flags
| ) |  |

Adds the region name to the widget at position pos in the hierarchy defined in path.

See Gtk::StyleContext::add_region().

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
  The use of regions is deprecated.

Parameters

  pos | Position to modify, -1 for the path head.
  name | Region name.
  flags | Flags affecting the region.

void Gtk::WidgetPath::iter_clear_classes | ( | int | pos = `-1` | ) |

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

Since gtkmm 3.0:

Parameters

  pos | Position to modify, -1 for the path head.

void Gtk::WidgetPath::iter_clear_regions | ( | int | pos = `-1` | ) |

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
  The use of regions is deprecated.

Parameters

  pos | Position to modify, -1 for the path head.

Glib::ustring Gtk::WidgetPath::iter_get_name | ( | int | pos | ) | const

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

Parameters

  pos | Position to get the widget name for, -1 for the path head.

Returns
  The widget name, or `0` if none was set.

GType Gtk::WidgetPath::iter_get_object_type | ( | int | pos | ) | const

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

Since gtkmm 3.0:

Parameters

  pos | Position to get the object type for, -1 for the path head.

Returns
  A widget type.

WidgetPath Gtk::WidgetPath::iter_get_siblings | ( | int | pos = `-1` | ) | const

Returns the list of siblings for the element at pos.

If the element was not added with siblings, `0` is returned.

Parameters

  pos | Position to get the siblings for, -1 for the path head.

Returns
  `0` or the list of siblings for the element at pos.

bool Gtk::WidgetPath::iter_has_class | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  | const

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

Since gtkmm 3.0:

Parameters

  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.

bool Gtk::WidgetPath::iter_has_name | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  | const

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

Since gtkmm 3.0:

Parameters

  pos | Position to query, -1 for the path head.
  name | A widget name.

Returns
  `true` if the widget at pos has this name.

bool Gtk::WidgetPath::iter_has_region | ( | int | pos,
|  | const Glib::ustring & | name,
|  | RegionFlags& | flags
| ) |  | const

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
  The use of regions is deprecated.

Parameters

  pos | Position to query, -1 for the path head.
  name | Region name.
  flags | Return location for the region flags.

Returns
  `true` if the class name is defined for the widget at pos.

std::vector<Glib::ustring> Gtk::WidgetPath::iter_list_classes | ( | int | pos = `-1` | ) | const

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

Since gtkmm 3.0:

Parameters

  pos | Position to query, -1 for the path head.

Returns
  The list of classes, This is a list of strings, the SList contents are owned by GTK+, but you should use Glib::slist_free() to free the list itself.

std::vector<Glib::ustring> Gtk::WidgetPath::iter_list_regions | ( | int | pos = `-1` | ) | const

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
  The use of regions is deprecated.

Parameters

  pos | Position to query, -1 for the path head.

Returns
  The list of regions, This is a list of strings, the SList contents are owned by GTK+, but you should use Glib::slist_free() to free the list itself.

void Gtk::WidgetPath::iter_remove_class | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  |

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

Since gtkmm 3.0:

Parameters

  pos | Position to modify, -1 for the path head.
  name | Class name.

void Gtk::WidgetPath::iter_remove_region | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  |

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
  The use of regions is deprecated.

Parameters

  pos | Position to modify, -1 for the path head.
  name | Region name.

void Gtk::WidgetPath::iter_set_name | ( | int | pos,
|  | const Glib::ustring & | name
| ) |  |

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

Since gtkmm 3.0:

Parameters

  pos | Position to modify, -1 for the path head.
  name | Widget name.

void Gtk::WidgetPath::iter_set_object_type | ( | int | pos,
|  | GType | type
| ) |  |

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

Since gtkmm 3.0:

Parameters

  pos | Position to modify, -1 for the path head.
  type | Object type to set.

WidgetPath& Gtk::WidgetPath::operator= | ( | const WidgetPath& | other | ) |

int Gtk::WidgetPath::path_append_type | ( | GType | type | ) |

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

Since gtkmm 3.0:

Parameters

  type | Widget type to append.

Returns
  The position where the element was inserted.

int Gtk::WidgetPath::path_length | ( |  | ) | const

Returns the number of Gtk::Widget Types between the represented widget and its topmost container.

Since gtkmm 3.0:

Returns
  The number of elements in the path.

void Gtk::WidgetPath::prepend_type | ( | GType | type | ) |

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

Since gtkmm 3.0:

Parameters

  type | Widget type to prepend.

void Gtk::WidgetPath::swap | ( | WidgetPath& | other | ) |

Glib::ustring Gtk::WidgetPath::to_string | ( |  | ) | const

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 Glib::print() the path or dump it in a gdb session.

Since gtkmm 3.2:

Returns
  A new string describing path.

## Friends And Related Function Documentation

void swap | ( | WidgetPath& | lhs,
|  | WidgetPath& | rhs
| ) |  |

related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

Gtk::WidgetPath wrap | ( | GtkWidgetPath * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

## Member Data Documentation

GtkWidgetPath* Gtk::WidgetPath::gobject_

protected