Class ColumnView

All Implemented Interfaces:
PointerInterface

public class ColumnView extends Widget
`GtkColumnView` 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 [property@Gtk.ColumnView:show-row-separators] and
[property@Gtk.ColumnView: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
[property@Gtk.ColumnView: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
[method@Gtk.ColumnView.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 [method@Gtk.ColumnViewColumn.set_sorter]. The initial sort
order can be set with [method@Gtk.ColumnView.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 [property@Gtk.ColumnView:reorderable] and
[property@Gtk.ColumnViewColumn:resizable] properties.

To learn more about the list widget framework, see the
[overview](section-list-widget.html).

# 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 [property@Gtk.ColumnView: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 [property@Gtk.ColumnView: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](section-list-widget.html#list-styles):
.rich-list, .navigation-sidebar or .data-table.

# Accessibility

`GtkColumnView` uses the %GTK_ACCESSIBLE_ROLE_TREE_GRID role, header title
widgets are using the %GTK_ACCESSIBLE_ROLE_COLUMN_HEADER role. The row widgets
are using the %GTK_ACCESSIBLE_ROLE_ROW role, and individual cells are using
the %GTK_ACCESSIBLE_ROLE_GRID_CELL role

https://docs.gtk.org/gtk4/class.ColumnView.html

  • Field Details

  • Constructor Details

    • ColumnView

      public ColumnView(PointerContainer pointer)
    • ColumnView

      public ColumnView(@Nullable SelectionModel model)
      Creates a new `GtkColumnView`.

      You most likely want to call [method@Gtk.ColumnView.append_column]
      to add columns next.
      Parameters:
      model - the list model to use
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • appendColumn

      public void appendColumn(@Nonnull ColumnViewColumn column)
      Appends the @column to the end of the columns in @self.
      Parameters:
      column - a `GtkColumnViewColumn` that hasn't been added to a `GtkColumnView` yet
    • getColumns

      public ListModel getColumns()
      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
      ::items-changed signal.
      Returns:
      The list managing the columns
    • getEnableRubberband

      public boolean getEnableRubberband()
      Returns whether rows can be selected by dragging with the mouse.
      Returns:
      %TRUE if rubberband selection is enabled
    • getModel

      public SelectionModel getModel()
      Gets the model that's currently used to read the items displayed.
      Returns:
      The model in use
    • getReorderable

      public boolean getReorderable()
      Returns whether columns are reorderable.
      Returns:
      %TRUE if columns are reorderable
    • getShowColumnSeparators

      public boolean getShowColumnSeparators()
      Returns whether the list should show separators
      between columns.
      Returns:
      %TRUE if the list shows column separators
    • getShowRowSeparators

      public boolean getShowRowSeparators()
      Returns whether the list should show separators
      between rows.
      Returns:
      %TRUE if the list shows separators
    • getSingleClickActivate

      public boolean getSingleClickActivate()
      Returns whether rows will be activated on single click and
      selected on hover.
      Returns:
      %TRUE if rows are activated on single click
    • getSorter

      public Sorter getSorter()
      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 [method@Gtk.ColumnViewColumn.set_sorter] for setting up
      per-column sorting.

      Here is an example:
      ```c
      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);
      ```
      Returns:
      the `GtkSorter` of @self
    • insertColumn

      public void insertColumn(int position, @Nonnull ColumnViewColumn 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.
      Parameters:
      position - the position to insert @column at
      column - the `GtkColumnViewColumn` to insert
    • removeColumn

      public void removeColumn(@Nonnull ColumnViewColumn column)
      Removes the @column from the list of columns of @self.
      Parameters:
      column - a `GtkColumnViewColumn` that's part of @self
    • setEnableRubberband

      public void setEnableRubberband(boolean enable_rubberband)
      Sets whether selections can be changed by dragging with the mouse.
      Parameters:
      enable_rubberband - %TRUE to enable rubberband selection
    • setModel

      public void setModel(@Nullable SelectionModel model)
      Sets the model to use.

      This must be a [iface@Gtk.SelectionModel].
      Parameters:
      model - the model to use
    • setReorderable

      public void setReorderable(boolean reorderable)
      Sets whether columns should be reorderable by dragging.
      Parameters:
      reorderable - whether columns should be reorderable
    • setShowColumnSeparators

      public void setShowColumnSeparators(boolean show_column_separators)
      Sets whether the list should show separators
      between columns.
      Parameters:
      show_column_separators - %TRUE to show column separators
    • setShowRowSeparators

      public void setShowRowSeparators(boolean show_row_separators)
      Sets whether the list should show separators
      between rows.
      Parameters:
      show_row_separators - %TRUE to show row separators
    • setSingleClickActivate

      public void setSingleClickActivate(boolean single_click_activate)
      Sets whether rows should be activated on single click and
      selected on hover.
      Parameters:
      single_click_activate - %TRUE to activate items on single click
    • sortByColumn

      public void sortByColumn(@Nullable ColumnViewColumn column, int 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
      [method@Gtk.ColumnView.get_sorter] is set on a sort model,
      and [method@Gtk.ColumnViewColumn.set_sorter] has been called
      on @column to associate a sorter with the column.

      If @column is %NULL, the view will be unsorted.
      Parameters:
      column - the `GtkColumnViewColumn` to sort by
      direction - the direction to sort in
    • onActivate

      public SignalHandler onActivate(ColumnView.OnActivate signal)
      Connect to signal "activate".
      See ColumnView.OnActivate.onActivate(int) for signal description.
      Field SIGNAL_ON_ACTIVATE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • asScrollable

      public Scrollable asScrollable()
      Implements interface Scrollable. Call this to get access to interface functions.
      Returns:
      Scrollable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()