ListView
open class ListView : ListBase, ListViewProtocol
GtkListView presents a large dynamic list of items.
GtkListView uses its factory to generate one row widget for each visible
item and shows them in a linear display, either vertically or horizontally.
The [propertyGtk.ListView:show-separators] property offers a simple way to
display separators between the rows.
GtkListView allows the user to select items according to the selection
characteristics of the model. For models that allow multiple selected items,
it is possible to turn on rubberband selection, using
[propertyGtk.ListView:enable-rubberband].
If you need multiple columns with headers, see [classGtk.ColumnView].
To learn more about the list widget framework, see the overview.
An example of using GtkListView:
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_list_item_set_child (list_item, image);
}
static void
bind_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
GAppInfo *app_info;
image = gtk_list_item_get_child (list_item);
app_info = gtk_list_item_get_item (list_item);
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
}
static void
activate_cb (GtkListView *list,
guint position,
gpointer unused)
{
GAppInfo *app_info;
app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
g_app_info_launch (app_info, NULL, NULL, NULL);
g_object_unref (app_info);
}
...
model = create_application_list ();
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
CSS nodes
listview[.separators][.rich-list][.navigation-sidebar][.data-table]
├── row[.activatable]
│
├── row[.activatable]
│
┊
╰── [rubberband]
GtkListView uses a single CSS node named listview. It may carry the
.separators style class, when [propertyGtk.ListView:show-separators]
property is set. Each child widget uses a single CSS node named row.
If the [propertyGtk.ListItem:activatable] property is set, the
corresponding row will have the .activatable style class. For
rubberband selection, a node with name rubberband is used.
The main listview node may also carry style classes to select the style of list presentation: .rich-list, .navigation-sidebar or .data-table.
Accessibility
GtkListView uses the GTK_ACCESSIBLE_ROLE_LIST role, and the list
items use the GTK_ACCESSIBLE_ROLE_LIST_ITEM role.
The ListView type acts as a reference-counted owner of an underlying GtkListView instance.
It provides the methods that can operate on this data type through ListViewProtocol conformance.
Use ListView as a strong reference or owner of a GtkListView instance.
-
Designated initialiser from the underlying `C` data type.This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
ListViewinstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkListView>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkListView>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkListView>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkListView>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGtkListView. i.e., ownership is transferred to theListViewinstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkListView>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
ListViewProtocolWill retainGtkListView.Declaration
Swift
@inlinable public init<T>(listView other: T) where T : ListViewProtocolParameters
otheran instance of a related type that implements
ListViewProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ListViewProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Creates a new
GtkListViewthat uses the givenfactoryfor mapping items to widgets.The function takes ownership of the arguments, so you can write code like
list_view = gtk_list_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));Declaration
Swift
@inlinable public init<ListItemFactoryT, SelectionModelT>(model: SelectionModelT?, factory: ListItemFactoryT?) where ListItemFactoryT : ListItemFactoryProtocol, SelectionModelT : SelectionModelProtocol
View on GitHub
Install in Dash
ListView Class Reference