1.95 <GtkGridView>

Class: <GtkGridView>

It derives from <GtkListBase>.

Presents a large dynamic grid of items.

<GtkGridView> 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.

<GtkGridView> 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 grid-view:enable-rubberband.

To learn more about the list widget framework, see the overview.

Actions

<GtkGridView> defines a set of built-in actions:

  • list.activate-item activates the item at given position by emitting the the grid-view:activate signal.

CSS nodes

gridview
├── child[.activatable]
│
├── child[.activatable]
│
┊
╰── [rubberband]

<GtkGridView> uses a single CSS node with name gridview. Each child uses a single CSS node with name child. If the list-item:activatable property is set, the corresponding row will have the .activatable style class. For rubberband selection, a subnode with name rubberband is used.

Accessibility

<GtkGridView> uses the Gtk.AccessibleRole.grid role, and the items use the Gtk.AccessibleRole.grid_cell role.

Properties

Property: grid-view:enable-rubberband self

Allow rubberband selection.

Its value is a boolean.

Set it with (set! (grid-view:enable-rubberband self) value).

Property: grid-view:factory self

Factory for populating list items.

The factory must be for configuring <GtkListItem> objects.

Its value is a <GtkListItemFactory>, or #f.

Set it with (set! (grid-view:factory self) value).

Property: grid-view:max-columns self

Maximum number of columns per row.

If this number is smaller than grid-view:min-columns, that value is used instead.

Its value is an unsigned 32-bit integer.

Set it with (set! (grid-view:max-columns self) value).

Property: grid-view:min-columns self

Minimum number of columns per row.

Its value is an unsigned 32-bit integer.

Set it with (set! (grid-view:min-columns self) value).

Property: grid-view:model self

Model for the items displayed.

Its value is a <GtkSelectionModel>, or #f.

Set it with (set! (grid-view:model self) value).

Property: grid-view:single-click-activate self

Activate rows on single click and select them on hover.

Its value is a boolean.

Set it with (set! (grid-view:single-click-activate self) value).

Property: grid-view:tab-behavior self

Behavior of the Tab key

Its value is a <GtkListTabBehavior> (or, to set it, one of its symbols).

Set it with (set! (grid-view:tab-behavior self) value).

Procedures

Method: grid-view:get-enable-rubberband? self ⇒ %return
Method: get-enable-rubberband? self ⇒ %return

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: a boolean.

#t if rubberband selection is enabled

Method: grid-view:get-factory self ⇒ %return
Method: get-factory self ⇒ %return

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: a <GtkListItemFactory>, or #f.

The factory in use

Method: grid-view:get-max-columns self ⇒ %return
Method: get-max-columns self ⇒ %return

Gets the maximum number of columns that the grid will use.

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: an unsigned 32-bit integer.

The maximum number of columns

Method: grid-view:get-min-columns self ⇒ %return
Method: get-min-columns self ⇒ %return

Gets the minimum number of columns that the grid will use.

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: an unsigned 32-bit integer.

The minimum number of columns

Method: grid-view:get-model self ⇒ %return
Method: get-model self ⇒ %return

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: a <GtkSelectionModel>, or #f.

The model in use

Method: grid-view:get-single-click-activate? self ⇒ %return
Method: get-single-click-activate? self ⇒ %return

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: a boolean.

#t if items are activated on single click

Method: grid-view:get-tab-behavior self ⇒ %return
Method: get-tab-behavior self ⇒ %return

Gets the behavior set for the Tab key.

self

Passed: a <GtkGridView>.

a <GtkGridView>

%return

Returned: a <GtkListTabBehavior>.

The behavior of the Tab key

Procedure: grid-view:new [model] [factory] ⇒ %return

Creates a new <GtkGridView> that uses the given factory for mapping items to widgets.

The function takes ownership of the arguments, so you can write code like

grid_view = gtk_grid_view_new (create_model (),
  gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
model

Passed, or left out: a <GtkSelectionModel>, or #f.

the model to use

factory

Passed, or left out: a <GtkListItemFactory>, or #f.

The factory to populate items with

%return

Returned: a <GtkWidget>.

a new <GtkGridView> using the given model and factory

Method: grid-view:scroll-to self pos flags [scroll]
Method: scroll-to self pos flags [scroll]

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.

self

Passed: a <GtkGridView>.

The gridview to scroll in

pos

Passed: an unsigned 32-bit integer.

position of the item. Must be less than the number of items in the view.

flags

Passed: a <GtkListScrollFlags>, or a list of its symbols, or one of them.

actions to perform

scroll

Passed, or left out: a <GtkScrollInfo>, or #f.

details of how to perform the scroll operation or #f to scroll into view

Method: grid-view:set-enable-rubberband self enable-rubberband
Method: set-enable-rubberband self enable-rubberband

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

enable-rubberband

Passed: a boolean.

#t to enable rubberband selection

Method: grid-view:set-factory self [factory]
Method: set-factory self [factory]

Sets the <GtkListItemFactory> to use for populating list items.

self

Passed: a <GtkGridView>.

a <GtkGridView>

factory

Passed, or left out: a <GtkListItemFactory>, or #f.

the factory to use

Method: grid-view:set-max-columns self max-columns
Method: set-max-columns self 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 grid-view:set-min-columns, that value is used instead.

self

Passed: a <GtkGridView>.

a <GtkGridView>

max-columns

Passed: an unsigned 32-bit integer.

The maximum number of columns

Method: grid-view:set-min-columns self min-columns
Method: set-min-columns self 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 grid-view:set-max-columns, that value is ignored.

self

Passed: a <GtkGridView>.

a <GtkGridView>

min-columns

Passed: an unsigned 32-bit integer.

The minimum number of columns

Method: grid-view:set-model self [model]
Method: set-model self [model]

Sets the model to use.

This must be a <GtkSelectionModel>.

self

Passed: a <GtkGridView>.

a <GtkGridView>

model

Passed, or left out: a <GtkSelectionModel>, or #f.

the model to use

Method: grid-view:set-single-click-activate self single-click-activate
Method: set-single-click-activate self single-click-activate

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

self

Passed: a <GtkGridView>.

a <GtkGridView>

single-click-activate

Passed: a boolean.

#t to activate items on single click

Method: grid-view:set-tab-behavior self tab-behavior
Method: set-tab-behavior self tab-behavior

Sets the behavior of the Tab and Shift+Tab keys.

self

Passed: a <GtkGridView>.

a <GtkGridView>

tab-behavior

Passed: a <GtkListTabBehavior>, or one of its symbols.

The desired tab behavior

Signals

Signal: grid-view:activate

Connect a handler with (connect object grid-view:activate handler). It is called as (handler self position).

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 list-item:activatable for details on how to use this signal.

self

Passed: a <GtkGridView>.

position

Passed: an unsigned 32-bit integer.

position of item to activate