gtkmm 4.10.0

Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gtk::ListItem Class Reference

Object used to represent items of a list model. More...

`#include <gtkmm/listitem.h>`

Inheritance diagram for Gtk::ListItem:
[legend]

## Public Member Functions
| ListItem (ListItem && src) noexcept
ListItem & | operator= (ListItem && src) noexcept
| ~ListItem () noexcept override
GtkListItem * | gobj ()
| Provides access to the underlying C GObject. More...
const GtkListItem * | gobj () const
| Provides access to the underlying C GObject. More...
GtkListItem * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< Glib::ObjectBase > | get_item ()
| Gets the model item that associated with self. More...
Glib::RefPtr< const Glib::ObjectBase > | get_item () const
| Gets the model item that associated with self. More...
guint | get_position () const
| Gets the position in the model that self currently displays. More...
bool | get_selected () const
| Checks if the item is displayed as selected. More...
bool | get_selectable () const
| Checks if a list item has been set to be selectable via set_selectable(). More...
void | set_selectable (bool selectable=true)
| Sets self to be selectable. More...
bool | get_activatable () const
| Checks if a list item has been set to be activatable via set_activatable(). More...
void | set_activatable (bool activatable=true)
| Sets self to be activatable. More...
void | set_child (Widget & child)
| Sets the child to be used for this listitem. More...
void | unset_child ()
Widget * | get_child ()
| Gets the child previously set via set_child() or `nullptr` if none was set. More...
const Widget * | get_child () const
| Gets the child previously set via set_child() or `nullptr` if none was set. More...
Glib::PropertyProxy< bool > | property_activatable ()
| If the item can be activated by the user. More...
Glib::PropertyProxy_ReadOnly< bool > | property_activatable () const
| If the item can be activated by the user. More...
Glib::PropertyProxy< Widget * > | property_child ()
| Widget used for display. More...
Glib::PropertyProxy_ReadOnly< Widget * > | property_child () const
| Widget used for display. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Glib::ObjectBase > > | property_item () const
| Displayed item. More...
Glib::PropertyProxy_ReadOnly< guint > | property_position () const
| Position of the item. More...
Glib::PropertyProxy< bool > | property_selectable ()
| If the item can be selected by the user. More...
Glib::PropertyProxy_ReadOnly< bool > | property_selectable () const
| If the item can be selected by the user. More...
Glib::PropertyProxy_ReadOnly< bool > | property_selected () const
| If the item is currently selected. More...
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
PropertyType | get_property (const Glib::ustring &property_name) const
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src) noexcept
void | remove_destroy_notify_callback (notifiable *data) const

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

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gtk::ListItem > | wrap (GtkListItem * object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify | func_destroy_notify
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Detailed Description

Object used to represent items of a list model.

Gtk::ListItem is the object that list-handling containers such as Gtk::ListView use to represent items in a Gio::ListModel. They are managed by the container and cannot be created by application code.

Gtk::ListItems need to be populated by application code. This is done by calling set_child().

Gtk::ListItems exist in 2 stages:

1. The unbound stage where the listitem is not currently connected to an item in the list. In that case, the property_item() property is not set.
2. The bound stage where the listitem references an item from the list. The property_item() property is set.

See also
  Gtk::ListView, Gio::ListModel

Since gtkmm 3.98:

## Constructor & Destructor Documentation

## ◆ ListItem()

Gtk::ListItem::ListItem | ( | ListItem && | src | ) |
| noexcept

## ◆ ~ListItem()

Gtk::ListItem::~ListItem | ( |  | ) |
| override noexcept

## Member Function Documentation

## ◆ get_activatable()

bool Gtk::ListItem::get_activatable | ( |  | ) | const

Checks if a list item has been set to be activatable via set_activatable().

Returns
  `true` if the item is activatable.

## ◆ get_child() [1/2]

Widget* Gtk::ListItem::get_child | ( |  | ) |

Gets the child previously set via set_child() or `nullptr` if none was set.

Returns
  The child.

## ◆ get_child() [2/2]

const Widget* Gtk::ListItem::get_child | ( |  | ) | const

Gets the child previously set via set_child() or `nullptr` if none was set.

Returns
  The child.

## ◆ get_item() [1/2]

Glib::RefPtr<Glib::ObjectBase> Gtk::ListItem::get_item | ( |  | ) |

Gets the model item that associated with self.

If self is unbound, this function returns `nullptr`.

Returns
  The item displayed.

## ◆ get_item() [2/2]

Glib::RefPtr<const Glib::ObjectBase> Gtk::ListItem::get_item | ( |  | ) | const

Gets the model item that associated with self.

If self is unbound, this function returns `nullptr`.

Returns
  The item displayed.

## ◆ get_position()

guint Gtk::ListItem::get_position | ( |  | ) | const

Gets the position in the model that self currently displays.

If self is unbound, GTK_INVALID_LIST_POSITION is returned.

Returns
  The position of this item.

## ◆ get_selectable()

bool Gtk::ListItem::get_selectable | ( |  | ) | const

Checks if a list item has been set to be selectable via set_selectable().

Do not confuse this function with get_selected().

Returns
  `true` if the item is selectable.

## ◆ get_selected()

bool Gtk::ListItem::get_selected | ( |  | ) | const

Checks if the item is displayed as selected.

The selected state is maintained by the liste widget and its model and cannot be set otherwise.

Returns
  `true` if the item is selected.

## ◆ get_type()

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

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

## ◆ gobj() [1/2]

GtkListItem* Gtk::ListItem::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkListItem* Gtk::ListItem::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkListItem* Gtk::ListItem::gobj_copy | ( |  | ) |

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

## ◆ operator=()

ListItem& Gtk::ListItem::operator= | ( | ListItem && | src | ) |
| noexcept

## ◆ property_activatable() [1/2]

Glib::PropertyProxy< bool > Gtk::ListItem::property_activatable | ( |  | ) |

If the item can be activated by the user.

Default value: `true`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_activatable() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::ListItem::property_activatable | ( |  | ) | const

If the item can be activated by the user.

Default value: `true`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_child() [1/2]

Glib::PropertyProxy< Widget* > Gtk::ListItem::property_child | ( |  | ) |

Widget used for display.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_child() [2/2]

Glib::PropertyProxy_ReadOnly< Widget* > Gtk::ListItem::property_child | ( |  | ) | const

Widget used for display.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_item()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Glib::ObjectBase> > Gtk::ListItem::property_item | ( |  | ) | const

Displayed item.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_position()

Glib::PropertyProxy_ReadOnly< guint > Gtk::ListItem::property_position | ( |  | ) | const

Position of the item.

Default value: 4294967295

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_selectable() [1/2]

Glib::PropertyProxy< bool > Gtk::ListItem::property_selectable | ( |  | ) |

If the item can be selected by the user.

Default value: `true`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_selectable() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::ListItem::property_selectable | ( |  | ) | const

If the item can be selected by the user.

Default value: `true`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_selected()

Glib::PropertyProxy_ReadOnly< bool > Gtk::ListItem::property_selected | ( |  | ) | const

If the item is currently selected.

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ set_activatable()

void Gtk::ListItem::set_activatable | ( | bool | activatable = `true` | ) |

Sets self to be activatable.

If an item is activatable, double-clicking on the item, using the Return key or calling Gtk::Widget::activate() will activate the item. Activating instructs the containing view to handle activation. `Gtk::ListView` for example will be emitting the Gtk::ListView::signal_activate() signal.

By default, list items are activatable.

Parameters

  activatable | If the item should be activatable.

## ◆ set_child()

void Gtk::ListItem::set_child | ( | Widget & | child | ) |

Sets the child to be used for this listitem.

This function is typically called by applications when setting up a listitem so that the widget can be reused when binding it multiple times.

Parameters

  child | The list item's child or `nullptr` to unset.

## ◆ set_selectable()

void Gtk::ListItem::set_selectable | ( | bool | selectable = `true` | ) |

Sets self to be selectable.

If an item is selectable, clicking on the item or using the keyboard will try to select or unselect the item. If this succeeds is up to the model to determine, as it is managing the selected state.

Note that this means that making an item non-selectable has no influence on the selected state at all. A non-selectable item may still be selected.

By default, list items are selectable. When rebinding them to a new item, they will also be reset to be selectable by GTK.

Parameters

  selectable | If the item should be selectable.

## ◆ unset_child()

void Gtk::ListItem::unset_child | ( |  | ) |

## Friends And Related Function Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::ListItem > wrap | ( | GtkListItem * | 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.