Class GridView
- All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Orientable, Scrollable, Proxy
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
Gtk.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-itemactivates the item at given position by emitting the theGtk.GridView::activatesignal.
CSS nodes
gridview
├── child[.activatable]
│
├── child[.activatable]
│
┊
╰── [rubberband]
GtkGridView uses a single CSS node with name gridview. Each child uses
a single CSS node with name child. If the Gtk.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 Gtk.AccessibleRole.grid role, and the items
use the Gtk.AccessibleRole.grid_cell role.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface declaration of theActivateCallbackcallback.static classGridView.Builder<B extends GridView.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class ListBase
ListBase.ListBase$Impl, ListBase.ListBaseClassNested classes/interfaces inherited from class 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.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterfaceNested classes/interfaces inherited from interface Orientable
Orientable.Orientable$Impl, Orientable.OrientableIfaceNested classes/interfaces inherited from interface Scrollable
Scrollable.Scrollable$Impl, Scrollable.ScrollableInterface -
Constructor Summary
ConstructorsConstructorDescriptionGridView()Create a new GridView.GridView(MemorySegment address) Create a GridView instance for the provided memory address.GridView(@Nullable SelectionModel model, @Nullable ListItemFactory factory) Creates a newGtkGridViewthat uses the givenfactoryfor mapping items to widgets. -
Method Summary
Modifier and TypeMethodDescriptionprotected GridViewasParent()Return this instance as if it were its parent type.static GridView.Builder<? extends GridView.Builder> builder()AGridView.Builderobject constructs aGridViewwith the specified properties.voidemitActivate(int position) Emits the "activate" signal.booleanReturns whether rows can be selected by dragging with the mouse.@Nullable ListItemFactoryGets the factory that's currently used to populate list items.intGets the maximum number of columns that the grid will use.static MemoryLayoutThe memory layout of the native struct.intGets the minimum number of columns that the grid will use.@Nullable SelectionModelgetModel()Gets the model that's currently used to read the items displayed.booleanReturns whether items will be activated on single click and selected on hover.Gets the behavior set for the Tab key.static @Nullable TypegetType()Get the GType of the GridView class.onActivate(GridView.ActivateCallback handler) Emitted when a cell has been activated by the user, usually via activating the GtkGridView|list.activate-item action.voidscrollTo(int pos, Set<ListScrollFlags> flags, @Nullable ScrollInfo scroll) Scrolls to the item at the given position and performs the actions specified inflags.voidscrollTo(int pos, ListScrollFlags flags, @Nullable ScrollInfo scroll) Scrolls to the item at the given position and performs the actions specified inflags.voidsetEnableRubberband(boolean enableRubberband) Sets whether selections can be changed by dragging with the mouse.voidsetFactory(@Nullable ListItemFactory factory) Sets theGtkListItemFactoryto use for populating list items.voidsetMaxColumns(int maxColumns) Sets the maximum number of columns to use.voidsetMinColumns(int minColumns) Sets the minimum number of columns to use.voidsetModel(@Nullable SelectionModel model) Sets the model to use.voidsetSingleClickActivate(boolean singleClickActivate) Sets whether items should be activated on single click and selected on hover.voidsetTabBehavior(ListTabBehavior tabBehavior) Sets the behavior of the Tab and Shift+Tab keys.Methods inherited from class 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, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, 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, setLimitEvents, 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, unsetStateFlagsMethods inherited from class 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, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Accessible
announce, getAccessibleId, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods inherited from interface Buildable
getBuildableIdMethods inherited from interface Orientable
getOrientation, setOrientationMethods inherited from interface Scrollable
getBorder, getHadjustment, getHscrollPolicy, getVadjustment, getVscrollPolicy, setHadjustment, setHscrollPolicy, setVadjustment, setVscrollPolicy
-
Constructor Details
-
GridView
Create a GridView instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
GridView
Creates a new
GtkGridViewthat uses the givenfactoryfor mapping items to widgets.The function takes ownership of the arguments, so you can write code like
grid_view = gtk_grid_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));- Parameters:
model- the model to usefactory- The factory to populate items with
-
GridView
public GridView()Create a new GridView.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
-
getEnableRubberband
public boolean getEnableRubberband()Returns whether rows can be selected by dragging with the mouse.- Returns:
trueif rubberband selection is enabled
-
getFactory
Gets the factory that's currently used to populate list items.- Returns:
- The factory in use
-
getMaxColumns
public int getMaxColumns()Gets the maximum number of columns that the grid will use.- Returns:
- The maximum number of columns
-
getMinColumns
public int getMinColumns()Gets the minimum number of columns that the grid will use.- Returns:
- The minimum number of columns
-
getModel
Gets the model that's currently used to read the items displayed.- Returns:
- The model in use
-
getSingleClickActivate
public boolean getSingleClickActivate()Returns whether items will be activated on single click and selected on hover.- Returns:
trueif items are activated on single click
-
getTabBehavior
Gets the behavior set for the Tab key.- Returns:
- The behavior of the Tab key
- Since:
- 4.12
-
scrollTo
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.
- Parameters:
pos- position of the item. Must be less than the number of items in the view.flags- actions to performscroll- details of how to perform the scroll operation ornullto scroll into view- Since:
- 4.12
-
scrollTo
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.
- Parameters:
pos- position of the item. Must be less than the number of items in the view.flags- actions to performscroll- details of how to perform the scroll operation ornullto scroll into view- Since:
- 4.12
-
setEnableRubberband
public void setEnableRubberband(boolean enableRubberband) Sets whether selections can be changed by dragging with the mouse.- Parameters:
enableRubberband-trueto enable rubberband selection
-
setFactory
Sets theGtkListItemFactoryto use for populating list items.- Parameters:
factory- the factory to use
-
setMaxColumns
public void setMaxColumns(int maxColumns) Sets the maximum number of columns to use.
This number must be at least 1.
If
maxColumnsis smaller than the minimum set viasetMinColumns(int), that value is used instead.- Parameters:
maxColumns- The maximum number of columns
-
setMinColumns
public void setMinColumns(int minColumns) Sets the minimum number of columns to use.
This number must be at least 1.
If
minColumnsis smaller than the minimum set viasetMaxColumns(int), that value is ignored.- Parameters:
minColumns- The minimum number of columns
-
setModel
Sets the model to use.
This must be a
SelectionModel.- Parameters:
model- the model to use
-
setSingleClickActivate
public void setSingleClickActivate(boolean singleClickActivate) Sets whether items should be activated on single click and selected on hover.- Parameters:
singleClickActivate-trueto activate items on single click
-
setTabBehavior
Sets the behavior of the Tab and Shift+Tab keys.- Parameters:
tabBehavior- The desired tab behavior- Since:
- 4.12
-
onActivate
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
Gtk.ListItem:activatablefor 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(GridView.ActivateCallback). -
builder
AGridView.Builderobject constructs aGridViewwith the specified properties. Use the variousset...()methods to set properties, and finish construction withGridView.Builder.build().- Returns:
- the builder object
-