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 [propertyGtk.GridView: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 [signalGtk.GridView::activate] signal.
# CSS nodes
[rubberband] ```
`GtkGridView` uses a single CSS node with name `gridview`. Each child uses
a single CSS node with name `child`. If the
[propertyGtk.ListItem: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 [enumGtk.AccessibleRole.grid] role, and the items
use the [enumGtk.AccessibleRole.grid_cell] role.
function "+"
(Widget : access Gtk_Grid_View_Record'Class)
return Gtk.Accessible.Gtk_Accessible
function "+"
(Widget : access Gtk_Grid_View_Record'Class)
return Gtk.Buildable.Gtk_Buildable
function "+"
(Widget : access Gtk_Grid_View_Record'Class)
return Gtk.Constraint_Target.Gtk_Constraint_Target
function "+"
(Widget : access Gtk_Grid_View_Record'Class)
return Gtk.Orientable.Gtk_Orientable
function "+"
(Widget : access Gtk_Grid_View_Record'Class)
return Gtk.Scrollable.Gtk_Scrollable
function "-"
(Interf : Gtk.Accessible.Gtk_Accessible)
return Gtk_Grid_View
function "-"
(Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Grid_View
function "-"
(Interf : Gtk.Constraint_Target.Gtk_Constraint_Target)
return Gtk_Grid_View
function "-"
(Interf : Gtk.Orientable.Gtk_Orientable)
return Gtk_Grid_View
function "-"
(Interf : Gtk.Scrollable.Gtk_Scrollable)
return Gtk_Grid_View
procedure Announce
(Self : not null access Gtk_Grid_View_Record;
Message : UTF8_String;
Priority : Gtk.Accessible.Gtk_Accessible_Announcement_Priority)
type Cb_GObject_Guint_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class;
Position : Guint);
type Cb_Gtk_Grid_View_Guint_Void is not null access procedure
(Self : access Gtk_Grid_View_Record'Class;
Position : Guint);
Enable_Rubberband_Property : constant Glib.Properties.Property_Boolean;
Allow rubberband selection.
Factory_Property : constant Glib.Properties.Property_Object;
Type: Gtk.List_Item_Factory.Gtk_List_Item_Factory Factory for populating list items.
The factory must be for configuring [classGtk.ListItem] objects.
function Get_Accessible_Id
(Self : not null access Gtk_Grid_View_Record) return UTF8_String
function Get_Accessible_Parent
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Accessible_Role
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Accessible.Gtk_Accessible_Role
function Get_At_Context
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Atcontext.Gtk_Atcontext
function Get_Border
(Self : not null access Gtk_Grid_View_Record;
Border : out Gtk.Scrollable.Gtk_Border) return Boolean
function Get_Bounds
(Self : not null access Gtk_Grid_View_Record;
X : out Glib.Gint;
Y : out Glib.Gint;
Width : out Glib.Gint;
Height : out Glib.Gint) return Boolean
function Get_Enable_Rubberband
(Self : not null access Gtk_Grid_View_Record) return Boolean
Returns whether rows can be selected by dragging with the mouse.
True if rubberband selection is enabled
function Get_Factory
(Self : not null access Gtk_Grid_View_Record)
return Gtk.List_Item_Factory.Gtk_List_Item_Factory
Gets the factory that's currently used to populate list items.
The factory in use. Has transfer-ownership='none'.
function Get_First_Accessible_Child
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Hadjustment
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Adjustment.Gtk_Adjustment
function Get_Hscroll_Policy
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Enums.Gtk_Scrollable_Policy
function Get_Max_Columns
(Self : not null access Gtk_Grid_View_Record) return Guint
Gets the maximum number of columns that the grid will use.
The maximum number of columns
function Get_Min_Columns
(Self : not null access Gtk_Grid_View_Record) return Guint
Gets the minimum number of columns that the grid will use.
The minimum number of columns
function Get_Model
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Selection_Model.Gtk_Selection_Model
Gets the model that's currently used to read the items displayed.
The model in use
function Get_Next_Accessible_Sibling
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Accessible.Gtk_Accessible
function Get_Orientation
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Enums.Gtk_Orientation
function Get_Platform_State
(Self : not null access Gtk_Grid_View_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State) return Boolean
function Get_Single_Click_Activate
(Self : not null access Gtk_Grid_View_Record) return Boolean
Returns whether items will be activated on single click and selected on hover.
True if items are activated on single click
function Get_Tab_Behavior
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Enums.Gtk_List_Tab_Behavior
Gets the behavior set for the <kbd>Tab</kbd> key. Since: gtk+ 4.12
The behavior of the <kbd>Tab</kbd> key
function Get_Type return Glib.GType
function Get_Vadjustment
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Adjustment.Gtk_Adjustment
function Get_Vscroll_Policy
(Self : not null access Gtk_Grid_View_Record)
return Gtk.Enums.Gtk_Scrollable_Policy
type Gtk_Grid_View is access all Gtk_Grid_View_Record'Class;
function Gtk_Grid_View_New
(Model : Gtk.Selection_Model.Gtk_Selection_Model;
Factory : access Gtk.List_Item_Factory.Gtk_List_Item_Factory_Record'Class)
return Gtk_Grid_View
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 c grid_view = gtk_grid_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
the model to use
The factory to populate items with. Has transfer-ownership='full'.
type Gtk_Grid_View_Record is new Gtk_List_Base_Record with null record;
procedure Gtk_New
(Self : out Gtk_Grid_View;
Model : Gtk.Selection_Model.Gtk_Selection_Model;
Factory : access Gtk.List_Item_Factory.Gtk_List_Item_Factory_Record'Class)
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 c grid_view = gtk_grid_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui")); Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the model to use
The factory to populate items with. Has transfer-ownership='full'.
package Implements_Gtk_Accessible is new Glib.Types.Implements
(Gtk.Accessible.Gtk_Accessible, Gtk_Grid_View_Record, Gtk_Grid_View);
package Implements_Gtk_Buildable is new Glib.Types.Implements
(Gtk.Buildable.Gtk_Buildable, Gtk_Grid_View_Record, Gtk_Grid_View);
package Implements_Gtk_Constraint_Target is new Glib.Types.Implements
(Gtk.Constraint_Target.Gtk_Constraint_Target, Gtk_Grid_View_Record, Gtk_Grid_View);
package Implements_Gtk_Orientable is new Glib.Types.Implements
(Gtk.Orientable.Gtk_Orientable, Gtk_Grid_View_Record, Gtk_Grid_View);
package Implements_Gtk_Scrollable is new Glib.Types.Implements
(Gtk.Scrollable.Gtk_Scrollable, Gtk_Grid_View_Record, Gtk_Grid_View);
procedure Initialize
(Self : not null access Gtk_Grid_View_Record'Class;
Model : Gtk.Selection_Model.Gtk_Selection_Model;
Factory : access Gtk.List_Item_Factory.Gtk_List_Item_Factory_Record'Class)
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 c grid_view = gtk_grid_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui")); Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the model to use
The factory to populate items with. Has transfer-ownership='full'.
Max_Columns_Property : constant Glib.Properties.Property_Uint;
Maximum number of columns per row.
If this number is smaller than [propertyGtk.GridView:min-columns], that value is used instead.
Min_Columns_Property : constant Glib.Properties.Property_Uint;
Minimum number of columns per row.
Model_Property : constant Glib.Properties.Property_Interface;
Type: Gtk.Selection_Model.Gtk_Selection_Model Model for the items displayed.
procedure On_Activate
(Self : not null access Gtk_Grid_View_Record;
Call : Cb_GObject_Guint_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
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 [propertyGtk.ListItem:activatable] for details on how to use this signal.
procedure On_Activate
(Self : not null access Gtk_Grid_View_Record;
Call : Cb_Gtk_Grid_View_Guint_Void;
After : Boolean := False)
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 [propertyGtk.ListItem:activatable] for details on how to use this signal.
procedure Reset_Property
(Self : not null access Gtk_Grid_View_Record;
Property : Gtk.Accessible.Gtk_Accessible_Property)
procedure Reset_Relation
(Self : not null access Gtk_Grid_View_Record;
Relation : Gtk.Accessible.Gtk_Accessible_Relation)
procedure Reset_State
(Self : not null access Gtk_Grid_View_Record;
State : Gtk.Accessible.Gtk_Accessible_State)
procedure Scroll_To
(Self : not null access Gtk_Grid_View_Record;
Pos : Guint;
Flags : Gtk.Enums.Gtk_List_Scroll_Flags;
Scroll : Gtk.Scroll_Info.Gtk_Scroll_Info)
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. Since: gtk+ 4.12
position of the item. Must be less than the number of items in the view.
actions to perform
details of how to perform the scroll operation or null to scroll into view. Has transfer-ownership='full'.
procedure Set_Accessible_Parent
(Self : not null access Gtk_Grid_View_Record;
Parent : Gtk.Accessible.Gtk_Accessible;
Next_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Set_Enable_Rubberband
(Self : not null access Gtk_Grid_View_Record;
Enable_Rubberband : Boolean)
Sets whether selections can be changed by dragging with the mouse.
True to enable rubberband selection
procedure Set_Factory
(Self : not null access Gtk_Grid_View_Record;
Factory : access Gtk.List_Item_Factory.Gtk_List_Item_Factory_Record'Class)
Sets the GtkListItemFactory to use for populating list items.
the factory to use
procedure Set_Hadjustment
(Self : not null access Gtk_Grid_View_Record;
Hadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class)
procedure Set_Hscroll_Policy
(Self : not null access Gtk_Grid_View_Record;
Policy : Gtk.Enums.Gtk_Scrollable_Policy)
procedure Set_Max_Columns
(Self : not null access Gtk_Grid_View_Record;
Max_Columns : Guint)
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 [methodGtk.GridView.set_min_columns], that value is used instead.
The maximum number of columns
procedure Set_Min_Columns
(Self : not null access Gtk_Grid_View_Record;
Min_Columns : Guint)
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 [methodGtk.GridView.set_max_columns], that value is ignored.
The minimum number of columns
procedure Set_Model
(Self : not null access Gtk_Grid_View_Record;
Model : Gtk.Selection_Model.Gtk_Selection_Model)
Sets the model to use. This must be a [ifaceGtk.SelectionModel].
the model to use
procedure Set_Orientation
(Self : not null access Gtk_Grid_View_Record;
Orientation : Gtk.Enums.Gtk_Orientation)
procedure Set_Single_Click_Activate
(Self : not null access Gtk_Grid_View_Record;
Single_Click_Activate : Boolean)
Sets whether items should be activated on single click and selected on hover.
True to activate items on single click
procedure Set_Tab_Behavior
(Self : not null access Gtk_Grid_View_Record;
Tab_Behavior : Gtk.Enums.Gtk_List_Tab_Behavior)
Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys. Since: gtk+ 4.12
The desired tab behavior
procedure Set_Vadjustment
(Self : not null access Gtk_Grid_View_Record;
Vadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class)
procedure Set_Vscroll_Policy
(Self : not null access Gtk_Grid_View_Record;
Policy : Gtk.Enums.Gtk_Scrollable_Policy)
Signal_Activate : constant Glib.Signal_Name := "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 [propertyGtk.ListItem:activatable] for details on how to use this signal.
Single_Click_Activate_Property : constant Glib.Properties.Property_Boolean;
Activate rows on single click and select them on hover.
Tab_Behavior_Property : constant Gtk.Enums.Property_Gtk_List_Tab_Behavior;
Behavior of the <kbd>Tab</kbd> key
procedure Update_Next_Accessible_Sibling
(Self : not null access Gtk_Grid_View_Record;
New_Sibling : Gtk.Accessible.Gtk_Accessible)
procedure Update_Platform_State
(Self : not null access Gtk_Grid_View_Record;
State : Gtk.Accessible.Gtk_Accessible_Platform_State)