Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GridMeta

[493:14] static extends: object

Generated metadata helpers for Grid class surfaces.

Methods

  • properties ()

    Returns property metadata for Grid.

    • @r A list.

class: Grid

[48:7] extends: object

Arranges its child widgets in rows and columns. An
example GtkGrid It supports arbitrary positions and horizontal/vertical spans. Children are added using [method@Gtk.Grid.attach]. They can span multiple rows or columns. It is also possible to add a child next to an existing child, using [method@Gtk.Grid.attach_next_to]. To remove a child from the grid, use [method@Gtk.Grid.remove]. The behaviour of GtkGrid when several children occupy the same grid cell is undefined. # GtkGrid as GtkBuildable Every child in a GtkGrid has access to a custom [iface@Gtk.Buildable] element, called <layout>. It can by used to specify a position in the grid and optionally spans. All properties that can be used in the <layout> element are implemented by [class@Gtk.GridLayoutChild]. It is implemented by GtkWidget using [class@Gtk.LayoutManager]. To showcase it, here is a simple example:

class="GtkButton" id="button1"> <property name="label">Button 1</property>
<layout> <property name="column">0</property> <property
name="row">0</property> </layout> </object> </child> <child> <object
class="GtkButton" id="button2"> <property name="label">Button 2</property>
<layout> <property name="column">1</property> <property
name="row">0</property> </layout> </object> </child> <child> <object
class="GtkButton" id="button3"> <property name="label">Button 3</property>
<layout> <property name="column">2</property> <property
name="row">0</property> <property name="row-span">2</property> </layout>
</object> </child> <child> <object class="GtkButton" id="button4"> <property
name="label">Button 4</property> <layout> <property
name="column">0</property> <property name="row">1</property> <property
name="column-span">2</property> </layout> </object> </child> </object> ``` It
organizes the first two buttons side-by-side in one cell each. The third
button is in the last column but spans across two rows. This is defined by
the `row-span` property. The last button is located in the second row and
spans across two columns, which is defined by the `column-span` property. #
CSS nodes `GtkGrid` uses a single CSS node with name `grid`. # Accessibility
Until GTK 4.10, `GtkGrid` used the [enum@Gtk.AccessibleRole.group] role.
Starting from GTK 4.12, `GtkGrid` uses the [enum@Gtk.AccessibleRole.generic]
role.

#### Members
- **handleObj**
- **lib**
- **retainedCallbacks**
- **signalHandlerNames**
- **signalSetterHandlers**

#### Methods

- **Grid** ()

	> Creates a new grid widget.



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


- **asWidget** ()

	> Wraps this handle as `Widget`.

	- **@r** `A` `Widget` 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.


- **getProperty** (`string Name`)

	> Reads one generated property by name.



- **setProperty** (`string Name, Value`)

	> Writes one generated property by name.



- **setBaselinerow** (`int Value`)

	> The row to align to the baseline when valign is using baseline alignment.

	- **@p** `Value` is the new property value.
	- **@r** `None.` 


- **setColumnhomogeneous** (`bool Value`)

	> If %TRUE, the columns are all the same width.

	- **@p** `Value` is the new property value.
	- **@r** `None.` 


- **setColumnspacing** (`int Value`)

	> The amount of space between two consecutive columns.

	- **@p** `Value` is the new property value.
	- **@r** `None.` 


- **setRowhomogeneous** (`bool Value`)

	> If %TRUE, the rows are all the same height.

	- **@p** `Value` is the new property value.
	- **@r** `None.` 


- **setRowspacing** (`int Value`)

	> The amount of space between two consecutive rows.

	- **@p** `Value` is the new property value.
	- **@r** `None.` 


- **attach** (`object child, int column, int row, int width, int height`)

	> Adds a widget to the grid. The position of @child is determined by

	- **@column** `and` @row. The number of “cells” that @child will occupy is determined by @width and @height.
	- **@p** `child` is the widget to add.
	- **@p** `column` is the column number to attach the left side of @child to.
	- **@p** `row` is the row number to attach the top side of @child to.
	- **@p** `width` is the number of columns that @child will span.
	- **@p** `height` is the number of rows that @child will span.
	- **@r** `None.` 


- **attach\_next\_to** (`object child, object sibling, string side, int width, int height`)

	> Adds a widget to the grid. The widget is placed next to @sibling, on the side determined by @side. When @sibling is %NULL, the widget is placed in row (for left or right placement) or column 0 (for top or bottom placement), at the end indicated by @side. Attaching widgets labeled `[1]`, `[2]`, `[3]` with `@sibling == %NULL` and `@side == %GTK_POS_LEFT` yields a layout of `[3][2][1]`.

	- **@p** `child` is the widget to add.
	- **@p** `sibling` is the child of @grid that @child will be placed next to, or %NULL to place @child at the beginning or end.
	- **@p** `side` is the side of @sibling that @child is positioned next to.
	- **@p** `width` is the number of columns that @child will span.
	- **@p** `height` is the number of rows that @child will span.
	- **@r** `None.` 


- **get\_baseline\_row** ()

	> Returns which row defines the global baseline of @grid.



- **get\_child\_at** (`int column, int row`)

	> Gets the child of @grid whose area covers the grid cell at @column, @row.

	- **@p** `column` is the left edge of the cell.
	- **@p** `row` is the top edge of the cell.


- **get\_column\_homogeneous** ()

	> Returns whether all columns of @grid have the same width.



- **get\_column\_spacing** ()

	> Returns the amount of space between the columns of @grid.



- **get\_row\_baseline\_position** (`int row`)

	> Returns the baseline position of @row. See [method@Gtk.Grid.set_row_baseline_position].

	- **@p** `row` is a row index.


- **get\_row\_homogeneous** ()

	> Returns whether all rows of @grid have the same height.



- **get\_row\_spacing** ()

	> Returns the amount of space between the rows of @grid.



- **insert\_column** (`int position`)

	> Inserts a column at the specified position. Children which are attached at or to the right of this position are moved one column to the right. Children which span across this position are grown to span the new column.

	- **@p** `position` is the position to insert the column at.
	- **@r** `None.` 


- **insert\_next\_to** (`object sibling, string side`)

	> Inserts a row or column at the specified position. The new row or column is placed next to @sibling, on the side determined by @side. If @side is %GTK_POS_TOP or %GTK_POS_BOTTOM, a row is inserted. If @side is %GTK_POS_LEFT of %GTK_POS_RIGHT, a column is inserted.

	- **@p** `sibling` is the child of @grid that the new row or column will be placed next to.
	- **@p** `side` is the side of @sibling that @child is positioned next to.
	- **@r** `None.` 


- **insert\_row** (`int position`)

	> Inserts a row at the specified position. Children which are attached at or below this position are moved one row down. Children which span across this position are grown to span the new row.

	- **@p** `position` is the position to insert the row at.
	- **@r** `None.` 


- **remove** (`object child`)

	> Removes a child from @grid. The child must have been added with [method@Gtk.Grid.attach] or [method@Gtk.Grid.attach_next_to].

	- **@p** `child` is the child widget to remove.
	- **@r** `None.` 


- **remove\_column** (`int position`)

	> Removes a column from the grid. Children that are placed in this column are removed, spanning children that overlap this column have their width reduced by one, and children after the column are moved to the left.

	- **@p** `position` is the position of the column to remove.
	- **@r** `None.` 


- **remove\_row** (`int position`)

	> Removes a row from the grid. Children that are placed in this row are removed, spanning children that overlap this row have their height reduced by one, and children below the row are moved up.

	- **@p** `position` is the position of the row to remove.
	- **@r** `None.` 


- **set\_baseline\_row** (`int row`)

	> Sets which row defines the global baseline for the entire grid. Each row in the grid can have its own local baseline, but only one of those is global, meaning it will be the baseline in the parent of the @grid.

	- **@p** `row` is the row index.
	- **@r** `None.` 


- **set\_column\_homogeneous** (`bool homogeneous`)

	> Sets whether all columns of @grid will have the same width.

	- **@p** `homogeneous` is %TRUE to make columns homogeneous.
	- **@r** `None.` 


- **set\_column\_spacing** (`int spacing`)

	> Sets the amount of space between columns of @grid.

	- **@p** `spacing` is the amount of space to insert between columns.
	- **@r** `None.` 


- **set\_row\_baseline\_position** (`int row, string pos`)

	> Sets how the baseline should be positioned on @row of the grid, in case that row is assigned more space than is requested. The default baseline position is %GTK_BASELINE_POSITION_CENTER.

	- **@p** `row` is a row index.
	- **@p** `pos` is a `GtkBaselinePosition`.
	- **@r** `None.` 


- **set\_row\_homogeneous** (`bool homogeneous`)

	> Sets whether all rows of @grid will have the same height.

	- **@p** `homogeneous` is %TRUE to make rows homogeneous.
	- **@r** `None.` 


- **set\_row\_spacing** (`int spacing`)

	> Sets the amount of space between rows of @grid.

	- **@p** `spacing` is the amount of space to insert between rows.
	- **@r** `None.`