Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ListViewMeta

[594:14] static extends: object

Generated metadata helpers for ListView class surfaces.

Methods

  • properties ()

    Returns property metadata for ListView.

    • @r A list.
  • signals ()

    Returns signal metadata for ListView.

    • @r A list.

class: ListViewActivateCallback

[524:7] extends: object

Generated low-level callback wrapper for GIR callback activate.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • ListViewActivateCallback (callback Fn, UserData = null)

    Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking Fn.

    • @p Fn is the Aussom callback implementation.
    • @p UserData is retained and passed through to Fn on each invocation when provided.
  • trampoline (nativeSelf, position, nativeUserData)

    Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.

  • callback ()

    Returns the wrapped NativeCallback.

  • handle ()

    Returns the callback as a NativeHandle.

  • close ()

    Closes the underlying NativeCallback.

  • isClosed ()

    Returns true when the callback has been closed.

class: ListView

[57:7] extends: object

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 [property@Gtk.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 [property@Gtk.ListView:enable-rubberband]. If you need multiple columns with headers, see [class@Gtk.ColumnView]. To learn more about the list widget framework, see the overview. An example of using GtkListView: c 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); # Actions GtkListView defines a set of built-in actions: - list.activate-item activates the item at given position by emitting the [signal@Gtk.ListView::activate] signal. # 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 [property@Gtk.ListView:show-separators] property is set. Each child widget uses a single CSS node named row. If the [property@Gtk.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 [enum@Gtk.AccessibleRole.list] role, and the list items use the [enum@Gtk.AccessibleRole.list_item] role.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • ListView (model = null, factory = null)

    Creates a new GtkListView that uses the given @factory for mapping items to widgets. The function takes ownership of the arguments, so you can write code like c list_view = gtk_list_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));

    • @p model is the model to use.
    • @p factory is The factory to populate items with.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asListBase ()

    Wraps this handle as ListBase.

    • @r A ListBase object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • asOrientable ()

    Wraps this handle as Orientable.

    • @r A Orientable object.
  • asScrollable ()

    Wraps this handle as Scrollable.

    • @r A Scrollable object.
  • connectSignal (string Name, CallbackObj)

    Connects one generated callback wrapper to a named signal.

    • @p Name is the signal name.
    • @p CallbackObj is the generated callback wrapper to connect.
    • @r The connected handler id.
  • disconnectSignalHandler (int HandlerId)

    Disconnects one retained signal handler id.

    • @p HandlerId is the signal handler id to disconnect.
    • @r None.
  • setOnActivate (callback Fn, UserData = null)

    Emitted when a row has been activated by the user. Activation usually happens via the list.activate-item action of the GtkListView. This allows for a convenient way to handle activation in a listview. See [method@Gtk.ListItem.set_activatable] for details on how to use this signal.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (ListView Self, int Position).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setEnablerubberband (bool Value)

    Allow rubberband selection.

    • @p Value is the new property value.
    • @r None.
  • setFactory (object Value)

    Factory for populating list items. The factory must be for configuring [class@Gtk.ListItem] objects.

    • @p Value is the new property value.
    • @r None.
  • setHeaderfactory (object Value)

    Factory for creating header widgets. The factory must be for configuring [class@Gtk.ListHeader] objects.

    • @p Value is the new property value.
    • @r None.
  • setModel (object Value)

    Model for the items displayed.

    • @p Value is the new property value.
    • @r None.
  • setShowseparators (bool Value)

    Show separators between rows.

    • @p Value is the new property value.
    • @r None.
  • setSingleclickactivate (bool Value)

    Activate rows on single click and select them on hover.

    • @p Value is the new property value.
    • @r None.
  • setTabbehavior (string Value)

    Behavior of the Tab key

    • @p Value is the new property value.
    • @r None.
  • get_enable_rubberband ()

    Returns whether rows can be selected by dragging with the mouse.

  • get_factory ()

    Gets the factory that's currently used to populate list items.

  • get_header_factory ()

    Gets the factory that's currently used to populate section headers.

  • get_model ()

    Gets the model that's currently used to read the items displayed.

  • get_show_separators ()

    Returns whether the listview should show separators between rows.

  • get_single_click_activate ()

    Returns whether rows will be activated on single click and selected on hover.

  • get_tab_behavior ()

    Gets the behavior set for the Tab key.

  • scroll_to (int pos, string flags, object scroll)

    Scrolls to the item at the given position and performs the actions specified in @flags. This function works no matter if the listview is shown or focused. If it isn't, then the changes will take effect once that happens.

    • @p pos is position of the item. Must be less than the number of items in the view..
    • @p flags is actions to perform.
    • @p scroll is details of how to perform the scroll operation or %NULL to scroll into view.
    • @r None.
  • set_enable_rubberband (bool enable_rubberband)

    Sets whether selections can be changed by dragging with the mouse.

    • @p enable_rubberband is whether to enable rubberband selection.
    • @r None.
  • set_factory (object factory)

    Sets the GtkListItemFactory to use for populating list items.

    • @p factory is the factory to use.
    • @r None.
  • set_header_factory (object factory)

    Sets the GtkListItemFactory to use for populating the [class@Gtk.ListHeader] objects used in section headers. If this factory is set to NULL, the list will not show section headers.

    • @p factory is the factory to use.
    • @r None.
  • set_model (object model)

    Sets the model to use. This must be a [iface@Gtk.SelectionModel] to use.

    • @p model is the model to use.
    • @r None.
  • set_show_separators (bool show_separators)

    Sets whether the listview should show separators between rows.

    • @p show_separators is whether to show separators.
    • @r None.
  • set_single_click_activate (bool single_click_activate)

    Sets whether rows should be activated on single click and selected on hover.

    • @p single_click_activate is whether to activate items on single click.
    • @r None.
  • set_tab_behavior (string tab_behavior)

    Sets the Tab key behavior. This influences how the Tab and Shift+Tab keys move the focus in the listview.

    • @p tab_behavior is The desired tab behavior.
    • @r None.