1.31 <GtkColumnView>

Class: <GtkColumnView>

It derives from <GtkWidget>.

Presents a large dynamic list of items using multiple columns with headers.

<GtkColumnView> uses the factories of its columns to generate a cell widget for each column, for each visible item and displays them together as the row for this item.

The column-view:show-row-separators and column-view:show-column-separators properties offer a simple way to display separators between the rows or columns.

<GtkColumnView> 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 column-view:enable-rubberband.

The column view supports sorting that can be customized by the user by clicking on column headers. To set this up, the <GtkSorter> returned by column-view:get-sorter must be attached to a sort model for the data that the view is showing, and the columns must have sorters attached to them by calling column-view-column:set-sorter. The initial sort order can be set with column-view:sort-by-column.

The column view also supports interactive resizing and reordering of columns, via Drag-and-Drop of the column headers. This can be enabled or disabled with the column-view:reorderable and column-view-column:resizable properties.

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

CSS nodes

columnview[.column-separators][.rich-list][.navigation-sidebar][.data-table]
├── header
│   ├── <column header>
┊   ┊
│   ╰── <column header>
│
├── listview
│
┊
╰── [rubberband]

<GtkColumnView> uses a single CSS node named columnview. It may carry the .column-separators style class, when column-view:show-column-separators property is set. Header widgets appear below a node with name header. The rows are contained in a <GtkListView> widget, so there is a listview node with the same structure as for a standalone <GtkListView> widget. If column-view:show-row-separators is set, it will be passed on to the list view, causing its CSS node to carry the .separators style class. For rubberband selection, a node with name rubberband is used.

The main columnview node may also carry style classes to select the style of list presentation: .rich-list, .navigation-sidebar or .data-table.

Accessibility

<GtkColumnView> uses the Gtk.AccessibleRole.tree_grid role, header title widgets are using the Gtk.AccessibleRole.column_header role. The row widgets are using the Gtk.AccessibleRole.row role, and individual cells are using the Gtk.AccessibleRole.grid_cell role

Properties

Property: column-view:columns self

The list of columns.

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

It is read only.

Property: column-view:enable-rubberband self

Allow rubberband selection.

Its value is a boolean.

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

Property: column-view:header-factory self

Factory for creating header widgets.

The factory must be for configuring <GtkListHeader> objects.

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

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

Property: column-view:model self

Model for the items displayed.

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

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

Property: column-view:reorderable self

Whether columns are reorderable.

Its value is a boolean.

Set it with (set! (column-view:reorderable self) value).

Property: column-view:row-factory self

The factory used for configuring rows.

The factory must be for configuring <GtkColumnViewRow> objects.

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

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

Property: column-view:show-column-separators self

Show separators between columns.

Its value is a boolean.

Set it with (set! (column-view:show-column-separators self) value).

Property: column-view:show-row-separators self

Show separators between rows.

Its value is a boolean.

Set it with (set! (column-view:show-row-separators self) value).

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

Activate rows on single click and select them on hover.

Its value is a boolean.

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

Property: column-view:sorter self

Sorter with the sorting choices of the user.

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

It is read only.

Property: column-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! (column-view:tab-behavior self) value).

Procedures

Method: column-view:append-column self column
Method: append-column self column

Appends the column to the end of the columns in self.

self

Passed: a <GtkColumnView>.

a columnview

column

Passed: a <GtkColumnViewColumn>.

a column that hasn’t been added to a <GtkColumnView> yet

Method: column-view:get-columns self ⇒ %return
Method: get-columns self ⇒ %return

Gets the list of columns in this column view.

This list is constant over the lifetime of self and can be used to monitor changes to the columns of self by connecting to the list-model:items-changed signal.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a <GListModel>.

The list managing the columns

Method: column-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 <GtkColumnView>.

a columnview

%return

Returned: a boolean.

true if rubberband selection is enabled

Method: column-view:get-header-factory self ⇒ %return
Method: get-header-factory self ⇒ %return

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

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a <GtkListItemFactory>, or #f.

The factory in use

Method: column-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 <GtkColumnView>.

a columnview

%return

Returned: a <GtkSelectionModel>, or #f.

The model in use

Method: column-view:get-reorderable? self ⇒ %return
Method: get-reorderable? self ⇒ %return

Returns whether columns are reorderable.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a boolean.

true if columns are reorderable

Method: column-view:get-row-factory self ⇒ %return
Method: get-row-factory self ⇒ %return

Gets the factory set via column-view:set-row-factory.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a <GtkListItemFactory>, or #f.

The factory

Method: column-view:get-show-column-separators? self ⇒ %return
Method: get-show-column-separators? self ⇒ %return

Returns whether the list should show separators between columns.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a boolean.

true if the list shows column separators

Method: column-view:get-show-row-separators? self ⇒ %return
Method: get-show-row-separators? self ⇒ %return

Returns whether the list should show separators between rows.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a boolean.

true if the list shows separators

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

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

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a boolean.

true if rows are activated on single click

Method: column-view:get-sorter self ⇒ %return
Method: get-sorter self ⇒ %return

Returns a special sorter that reflects the users sorting choices in the column view.

To allow users to customizable sorting by clicking on column headers, this sorter needs to be set on the sort model underneath the model that is displayed by the view.

See column-view-column:set-sorter for setting up per-column sorting.

Here is an example:

gtk_column_view_column_set_sorter (column, sorter);
gtk_column_view_append_column (view, column);
sorter = g_object_ref (gtk_column_view_get_sorter (view)));
model = gtk_sort_list_model_new (store, sorter);
selection = gtk_no_selection_new (model);
gtk_column_view_set_model (view, selection);
self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a <GtkSorter>, or #f.

the <GtkSorter> of self

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

Gets the behavior set for the Tab key.

self

Passed: a <GtkColumnView>.

a columnview

%return

Returned: a <GtkListTabBehavior>.

The behavior of the Tab key

Method: column-view:insert-column self position column
Method: insert-column self position column

Inserts a column at the given position in the columns of self.

If column is already a column of self, it will be repositioned.

self

Passed: a <GtkColumnView>.

a columnview

position

Passed: an unsigned 32-bit integer.

the position to insert column at

column

Passed: a <GtkColumnViewColumn>.

the column to insert

Procedure: column-view:new [model] ⇒ %return

Creates a new <GtkColumnView>.

You most likely want to call column-view:append-column to add columns next.

model

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

the list model to use

%return

Returned: a <GtkWidget>.

a new <GtkColumnView>

Method: column-view:remove-column self column
Method: remove-column self column

Removes the column from the list of columns of self.

self

Passed: a <GtkColumnView>.

a columnview

column

Passed: a <GtkColumnViewColumn>.

a column that’s part of self

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

Scroll to the row at the given position - or cell if a column is given - and performs the actions specified in flags.

This function works no matter if the columnview is shown or focused. If it isn’t, then the changes will take effect once that happens.

self

Passed: a <GtkColumnView>.

The columnview

pos

Passed: an unsigned 32-bit integer.

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

column

Passed: a <GtkColumnViewColumn>, or #f.

The column to scroll to or NULL to not scroll columns

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: column-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 <GtkColumnView>.

a columnview

enable-rubberband

Passed: a boolean.

whether to enable rubberband selection

Method: column-view:set-header-factory self [factory]
Method: set-header-factory self [factory]

Sets the factory to use for populating the <GtkListHeader> objects used in section headers.

If this factory is set to NULL, the list will not show section headers.

self

Passed: a <GtkColumnView>.

a columnview

factory

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

the factory to use

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

Sets the model to use.

This must be a <GtkSelectionModel>.

self

Passed: a <GtkColumnView>.

a columnview

model

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

the model to use

Method: column-view:set-reorderable self reorderable
Method: set-reorderable self reorderable

Sets whether columns should be reorderable by dragging.

self

Passed: a <GtkColumnView>.

a columnview

reorderable

Passed: a boolean.

whether columns should be reorderable

Method: column-view:set-row-factory self [factory]
Method: set-row-factory self [factory]

Sets the factory used for configuring rows.

The factory must be for configuring <GtkColumnViewRow> objects.

If this factory is not set - which is the default - then the defaults will be used.

This factory is not used to set the widgets displayed in the individual cells. For that see GtkColumnViewColumn.set_factory and GtkColumnViewCell.

self

Passed: a <GtkColumnView>.

a columnview

factory

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

The row factory

Method: column-view:set-show-column-separators self show-column-separators
Method: set-show-column-separators self show-column-separators

Sets whether the list should show separators between columns.

self

Passed: a <GtkColumnView>.

a columnview

show-column-separators

Passed: a boolean.

whether to show column separators

Method: column-view:set-show-row-separators self show-row-separators
Method: set-show-row-separators self show-row-separators

Sets whether the list should show separators between rows.

self

Passed: a <GtkColumnView>.

a columnview

show-row-separators

Passed: a boolean.

whether to show row separators

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

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

self

Passed: a <GtkColumnView>.

a columnview

single-click-activate

Passed: a boolean.

whether to activate items on single click

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

Sets the Tab key behavior.

This influences how the Tab and Shift+Tab keys move the focus in the columnview.

self

Passed: a <GtkColumnView>.

a columnview

tab-behavior

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

The desired tab behavior

Method: column-view:sort-by-column self column direction
Method: sort-by-column self column direction

Sets the sorting of the view.

This function should be used to set up the initial sorting. At runtime, users can change the sorting of a column view by clicking on the list headers.

This call only has an effect if the sorter returned by column-view:get-sorter is set on a sort model, and column-view-column:set-sorter has been called on column to associate a sorter with the column.

If column is unset, the view will be unsorted.

self

Passed: a <GtkColumnView>.

a columnview

column

Passed: a <GtkColumnViewColumn>, or #f.

the column to sort by

direction

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

the direction to sort in

Signals

Signal: column-view:activate

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

Emitted when a row has been activated by the user, usually via activating the GtkListBase|list.activate-item action.

This allows for a convenient way to handle activation in a columnview. See list-item:set-activatable for details on how to use this signal.

self

Passed: a <GtkColumnView>.

position

Passed: an unsigned 32-bit integer.

position of item to activate