Gnome::Gtk4::GridView
Description
Gnome::Gtk4::GridView presents a large dynamic grid of items.
Gnome::Gtk4::GridView uses its factory to generate one child widget for each visible item and shows them in a grid. The orientation of the grid view determines if the grid reflows vertically or horizontally.
Gnome::Gtk4::GridView 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 enable-rubberband.
To learn more about the list widget framework, see the [overview](section-list-widget.html).
CSS nodes
Gnome::Gtk4::GridView uses a single CSS node with name gridview. Each child uses a single CSS node with name child. If the activatable defined in Gnome::Gtk4::ListItem property is set, the corresponding row will have the `.activatable` style class. For rubberband selection, a subnode with name rubberband is used.
Accessibility
Gnome::Gtk4::GridView uses the GTK_ACCESSIBLE_ROLE_GRID
role, and the items use the GTK_ACCESSIBLE_ROLE_GRID_CELL
role.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-gridview
Creates a new Gnome::Gtk4::GridView that uses the given $factory
for mapping items to widgets.
The function takes ownership of the arguments, so you can write code like
method new-gridview ( N-Object() $model, N-Object() $factory --> Gnome::Gtk4::GridView \)
$model; (transfer ownership: full) the model to use.
$factory; (transfer ownership: full) The factory to populate items with.
Methods
get-enable-rubberband
Returns whether rows can be selected by dragging with the mouse.
method get-enable-rubberband (--> Bool )
Return value; True
if rubberband selection is enabled.
get-factory
Gets the factory that's currently used to populate list items.
method get-factory (--> N-Object )
Return value; The factory in use.
get-max-columns
Gets the maximum number of columns that the grid will use.
method get-max-columns (--> UInt )
Return value; The maximum number of columns.
get-min-columns
Gets the minimum number of columns that the grid will use.
method get-min-columns (--> UInt )
Return value; The minimum number of columns.
get-model
Gets the model that's currently used to read the items displayed.
method get-model (--> N-Object )
Return value; The model in use.
get-single-click-activate
Returns whether items will be activated on single click and selected on hover.
method get-single-click-activate (--> Bool )
Return value; True
if items are activated on single click.
get-tab-behavior
Gets the behavior set for the <kbd>Tab</kbd> key.
method get-tab-behavior (--> GtkListTabBehavior )
Return value; The behavior of the <kbd>Tab</kbd> key.
scroll-to
Scrolls to the item at the given position and performs the actions specified in $flags
.
This function works no matter if the gridview is shown or focused. If it isn't, then the changes will take effect once that happens.
method scroll-to ( UInt() $pos, UInt $flags, N-Object $scroll )
$pos; position of the item.
$flags; actions to perform.
$scroll; (transfer ownership: full) details of how to perform the scroll operation or undefined to scroll into view
set-enable-rubberband
Sets whether selections can be changed by dragging with the mouse.
method set-enable-rubberband ( Bool() $enable-rubberband )
$enable-rubberband;
True
to enable rubberband selection.
set-factory
Sets the Gnome::Gtk4::ListItemFactory to use for populating list items.
method set-factory ( N-Object() $factory )
$factory; the factory to use.
set-max-columns
Sets the maximum number of columns to use.
This number must be at least 1.
If $max-columns
is smaller than the minimum set via .set-min-columns()
, that value is used instead.
method set-max-columns ( UInt() $max-columns )
$max-columns; The maximum number of columns.
set-min-columns
Sets the minimum number of columns to use.
This number must be at least 1.
If $min-columns
is smaller than the minimum set via .set-max-columns()
, that value is ignored.
method set-min-columns ( UInt() $min-columns )
$min-columns; The minimum number of columns.
set-model
Sets the model to use.
This must be a Gnome::Gtk4::R-SelectionModel.
method set-model ( N-Object() $model )
$model; the model to use.
set-single-click-activate
Sets whether items should be activated on single click and selected on hover.
method set-single-click-activate ( Bool() $single-click-activate )
$single-click-activate;
True
to activate items on single click.
set-tab-behavior
Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
method set-tab-behavior ( GtkListTabBehavior $tab-behavior )
$tab-behavior; The desired tab behavior.
Signals
activate
Emitted when a cell has been activated by the user, usually via activating the GtkGridView|list.activate-item action.
This allows for a convenient way to handle activation in a gridview. See activatable defined in Gnome::Gtk4::ListItem for details on how to use this signal.
method handler ( guint $position, Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::GridView :$_widget, *C<user>-options )
$position; position of item to activate.
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::GridView object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.