gtkmm  4.8.0
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gtk::ListItemFactory Class Reference

Mapping list items to widgets. More...

#include <gtkmm/listitemfactory.h>

Inheritance diagram for Gtk::ListItemFactory:
Inheritance graph
[legend]

Public Member Functions

 ListItemFactory (ListItemFactory && src) noexcept
 
ListItemFactoryoperator= (ListItemFactory && src) noexcept
 
 ~ListItemFactory () noexcept override
 
GtkListItemFactory * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkListItemFactory * gobj () const
 Provides access to the underlying C GObject. More...
 
GtkListItemFactory * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 

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::ListItemFactorywrap (GtkListItemFactory * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Mapping list items to widgets.

Gtk::ListItemFactory is one of the core concepts of handling list widgets. It is the object tasked with creating widgets for items taken from a Gio::ListModel when the views need them and updating them as the items displayed by the view change.

A view is usually only able to display anything after both a factory and a model have been set on the view. So it is important that you do not skip this step when setting up your first view.

Because views do not display the whole list at once but only a few items, they only need to maintain a few widgets at a time. They will instruct the Gtk::ListItemFactory to create these widgets and bind them to the items that are currently displayed. As the list model changes or the user scrolls to the list, the items will change and the view will instruct the factory to bind the widgets to those new items.

The actual widgets used for displaying those widgets is provided by you.

When the factory needs widgets created, it will create a Gtk::ListItem and hand it to your code to set up a widget for. This list item will provide various properties with information about what item to display and provide you with some opportunities to configure its behavior. See the Gtk::ListItem documentation for further details.

Various implementations of Gtk::ListItemFactory exist to allow you different ways to provide those widgets. The most common implementations are Gtk::BuilderListItemFactory which takes a Gtk::Builder .ui file and then creates widgets and manages everything automatically from the information in that file and Gtk::SignalListItemFactory which allows you to connect to signals with your own code and retain full control over how the widgets are setup and managed.

A Gtk::ListItemFactory is supposed to be final - that means its behavior should not change and the first widget created from it should behave the same way as the last widget created from it. If you intend to do changes to the behavior, it is recommended that you create a new Gtk::ListItemFactory which will allow the views to recreate its widgets.

Once you have chosen your factory and created it, you need to set it on the view widget you want to use it with, such as via Gtk::ListView::set_factory(). Reusing factories across different views is allowed, but very uncommon.

Since gtkmm 3.98:

Constructor & Destructor Documentation

◆ ListItemFactory()

Gtk::ListItemFactory::ListItemFactory ( ListItemFactory &&  src)
noexcept

◆ ~ListItemFactory()

Gtk::ListItemFactory::~ListItemFactory ( )
overridenoexcept

Member Function Documentation

◆ get_type()

static GType Gtk::ListItemFactory::get_type ( )
static

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

◆ gobj() [1/2]

GtkListItemFactory* Gtk::ListItemFactory::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkListItemFactory* Gtk::ListItemFactory::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkListItemFactory* Gtk::ListItemFactory::gobj_copy ( )

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

◆ operator=()

ListItemFactory& Gtk::ListItemFactory::operator= ( ListItemFactory &&  src)
noexcept

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::ListItemFactory > wrap ( GtkListItemFactory *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.