Class ColumnView
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
,Scrollable
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 Gtk.ColumnView:show-row-separators
and
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
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
getSorter()
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 ColumnViewColumn.setSorter(org.gnome.gtk.Sorter)
. The initial sort
order can be set with sortByColumn(org.gnome.gtk.ColumnViewColumn, org.gnome.gtk.SortType)
.
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 Gtk.ColumnView:reorderable
and
Gtk.ColumnViewColumn: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 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 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: .rich-list, .navigation-sidebar or .data-table.
Accessibility
GtkColumnView
uses the AccessibleRole.TREE_GRID
role, header title
widgets are using the AccessibleRole.COLUMN_HEADER
role. The row widgets
are using the AccessibleRole.ROW
role, and individual cells are using
the AccessibleRole.GRID_CELL
role
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Functional interface declaration of theActivateCallback
callback.static class
ColumnView.Builder<B extends ColumnView.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Scrollable
Scrollable.ScrollableImpl, Scrollable.ScrollableInterface
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionColumnView
(MemorySegment address) Create a ColumnView proxy instance for the provided memory address.ColumnView
(Object... propertyNamesAndValues) Creates a new ColumnView with the provided property names and values.ColumnView
(@Nullable SelectionModel model) Creates a newGtkColumnView
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendColumn
(ColumnViewColumn column) Appends thecolumn
to the end of the columns in this ColumnView.protected ColumnView
asParent()
Returns this instance as if it were its parent type.static ColumnView.Builder
<? extends ColumnView.Builder> builder()
AColumnView.Builder
object constructs aColumnView
with the specified properties.void
emitActivate
(int position) Emits the "activate" signal.Gets the list of columns in this column view.boolean
Returns whether rows can be selected by dragging with the mouse.Gets the factory that's currently used to populate section headers.getModel()
Gets the model that's currently used to read the items displayed.boolean
Returns whether columns are reorderable.Gets the factory set viasetRowFactory(org.gnome.gtk.ListItemFactory)
.boolean
Returns whether the list should show separators between columns.boolean
Returns whether the list should show separators between rows.boolean
Returns whether rows will be activated on single click and selected on hover.Returns a special sorter that reflects the users sorting choices in the column view.Gets the behavior set for theTab
key.static Type
getType()
Get the GType of the ColumnView classvoid
insertColumn
(int position, ColumnViewColumn column) Inserts a column at the given position in the columns of this ColumnView.onActivate
(ColumnView.ActivateCallback handler) Emitted when a row has been activated by the user, usually via activating the GtkListBase|list.activate-item action.void
removeColumn
(ColumnViewColumn column) Removes thecolumn
from the list of columns of this ColumnView.void
scrollTo
(int pos, @Nullable ColumnViewColumn column, Set<ListScrollFlags> flags, @Nullable ScrollInfo scroll) Scroll to the row at the given position - or cell if a column is given - and performs the actions specified inflags
.void
scrollTo
(int pos, @Nullable ColumnViewColumn column, ListScrollFlags flags, @Nullable ScrollInfo scroll) Scroll to the row at the given position - or cell if a column is given - and performs the actions specified inflags
.void
setEnableRubberband
(boolean enableRubberband) Sets whether selections can be changed by dragging with the mouse.void
setHeaderFactory
(@Nullable ListItemFactory factory) Sets theGtkListItemFactory
to use for populating theListHeader
objects used in section headers.void
setModel
(@Nullable SelectionModel model) Sets the model to use.void
setReorderable
(boolean reorderable) Sets whether columns should be reorderable by dragging.void
setRowFactory
(@Nullable ListItemFactory factory) Sets the factory used for configuring rows.void
setShowColumnSeparators
(boolean showColumnSeparators) Sets whether the list should show separators between columns.void
setShowRowSeparators
(boolean showRowSeparators) Sets whether the list should show separators between rows.void
setSingleClickActivate
(boolean singleClickActivate) Sets whether rows should be activated on single click and selected on hover.void
setTabBehavior
(ListTabBehavior tabBehavior) Sets the behavior of theTab
andShift
+Tab
keys.void
sortByColumn
(@Nullable ColumnViewColumn column, SortType direction) Sets the sorting of the view.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.Scrollable
getBorder, getHadjustment, getHscrollPolicy, getVadjustment, getVscrollPolicy, setHadjustment, setHscrollPolicy, setVadjustment, setVscrollPolicy
-
Constructor Details
-
ColumnView
Create a ColumnView proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ColumnView
Creates a newGtkColumnView
.You most likely want to call
appendColumn(org.gnome.gtk.ColumnViewColumn)
to add columns next.- Parameters:
model
- the list model to use
-
ColumnView
Creates a new ColumnView with the provided property names and values.- Parameters:
propertyNamesAndValues
- pairs of property names and values (Strings and Objects). Does not need to be null-terminated.- Throws:
IllegalArgumentException
- invalid property names or values
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
appendColumn
Appends thecolumn
to the end of the columns in this ColumnView.- Parameters:
column
- aGtkColumnViewColumn
that hasn't been added to aGtkColumnView
yet
-
getColumns
Gets the list of columns in this column view.This list is constant over the lifetime of this ColumnView and can be used to monitor changes to the columns of this ColumnView 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
-
getHeaderFactory
Gets the factory that's currently used to populate section headers.- Returns:
- The factory in use
-
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
-
getRowFactory
Gets the factory set viasetRowFactory(org.gnome.gtk.ListItemFactory)
.- Returns:
- The factory
-
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
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
ColumnViewColumn.setSorter(org.gnome.gtk.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);
- Returns:
- the
GtkSorter
of this ColumnView
-
getTabBehavior
Gets the behavior set for theTab
key.- Returns:
- The behavior of the
Tab
key
-
insertColumn
Inserts a column at the given position in the columns of this ColumnView.If
column
is already a column of this ColumnView, it will be repositioned.- Parameters:
position
- the position to insertcolumn
atcolumn
- theGtkColumnViewColumn
to insert
-
removeColumn
Removes thecolumn
from the list of columns of this ColumnView.- Parameters:
column
- aGtkColumnViewColumn
that's part of this ColumnView
-
scrollTo
public void scrollTo(int pos, @Nullable @Nullable ColumnViewColumn column, Set<ListScrollFlags> flags, @Nullable @Nullable ScrollInfo scroll) Scroll to the row at the given position - or cell if a column is given - and performs the actions specified inflags
.This function works no matter if the listview is shown or focused. If it isn't, then the changes will take effect once that happens.
- Parameters:
pos
- position of the item. Must be less than the number of items in the view.column
- The column to scroll to ornull
to not scroll columns.flags
- actions to performscroll
- details of how to perform the scroll operation ornull
to scroll into view
-
scrollTo
public void scrollTo(int pos, @Nullable @Nullable ColumnViewColumn column, ListScrollFlags flags, @Nullable @Nullable ScrollInfo scroll) Scroll to the row at the given position - or cell if a column is given - and performs the actions specified inflags
.This function works no matter if the listview is shown or focused. If it isn't, then the changes will take effect once that happens.
- Parameters:
pos
- position of the item. Must be less than the number of items in the view.column
- The column to scroll to ornull
to not scroll columns.flags
- actions to performscroll
- details of how to perform the scroll operation ornull
to scroll into view
-
setEnableRubberband
public void setEnableRubberband(boolean enableRubberband) Sets whether selections can be changed by dragging with the mouse.- Parameters:
enableRubberband
-true
to enable rubberband selection
-
setHeaderFactory
Sets theGtkListItemFactory
to use for populating theListHeader
objects used in section headers.If this factory is set to
null
, the list will not show section headers.- Parameters:
factory
- the factory to use
-
setModel
Sets the model to use.This must be a
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
-
setRowFactory
Sets the factory used for configuring rows. The factory must be for configuringColumnViewRow
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#setFactory
andGtkColumnViewCell
.- Parameters:
factory
- The row factory
-
setShowColumnSeparators
public void setShowColumnSeparators(boolean showColumnSeparators) Sets whether the list should show separators between columns.- Parameters:
showColumnSeparators
-true
to show column separators
-
setShowRowSeparators
public void setShowRowSeparators(boolean showRowSeparators) Sets whether the list should show separators between rows.- Parameters:
showRowSeparators
-true
to show row separators
-
setSingleClickActivate
public void setSingleClickActivate(boolean singleClickActivate) Sets whether rows should be activated on single click and selected on hover.- Parameters:
singleClickActivate
-true
to activate items on single click
-
setTabBehavior
Sets the behavior of theTab
andShift
+Tab
keys.- Parameters:
tabBehavior
- The desired tab behavior
-
sortByColumn
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
getSorter()
is set on a sort model, andColumnViewColumn.setSorter(org.gnome.gtk.Sorter)
has been called oncolumn
to associate a sorter with the column.If
column
isnull
, the view will be unsorted.- Parameters:
column
- theGtkColumnViewColumn
to sort bydirection
- the direction to sort in
-
onActivate
public SignalConnection<ColumnView.ActivateCallback> onActivate(ColumnView.ActivateCallback handler) 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
ListItem.setActivatable(boolean)
for details on how to use this signal.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitActivate
public void emitActivate(int position) Emits the "activate" signal. SeeonActivate(org.gnome.gtk.ColumnView.ActivateCallback)
. -
builder
AColumnView.Builder
object constructs aColumnView
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withColumnView.Builder.build()
.
-