Class GridView
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
,Orientable
,Scrollable
GtkGridView
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-item
activates the item at given position by emitting the theGtk.GridView::activate
signal.
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 AccessibleRole.GRID
role, and the items
use the AccessibleRole.GRID_CELL
role.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theActivateCallback
callback.static class
GridView.Builder<B extends GridView.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.ListBase
ListBase.ListBaseClass, ListBase.ListBaseImpl
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.Orientable
Orientable.OrientableIface, Orientable.OrientableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.Scrollable
Scrollable.ScrollableImpl, Scrollable.ScrollableInterface
-
Constructor Summary
ConstructorDescriptionGridView
(MemorySegment address) Create a GridView proxy instance for the provided memory address.GridView
(@Nullable SelectionModel model, @Nullable ListItemFactory factory) Creates a newGtkGridView
that uses the givenfactory
for mapping items to widgets. -
Method Summary
Modifier and TypeMethodDescriptionprotected GridView
asParent()
Returns this instance as if it were its parent type.static GridView.Builder
<? extends GridView.Builder> builder()
AGridView.Builder
object constructs aGridView
with the specified properties.void
emitActivate
(int position) Emits the "activate" signal.boolean
Returns whether rows can be selected by dragging with the mouse.Gets the factory that's currently used to populate list items.int
Gets the maximum number of columns that the grid will use.int
Gets the minimum number of columns that the grid will use.getModel()
Gets the model that's currently used to read the items displayed.boolean
Returns whether items will be activated on single click and selected on hover.Gets the behavior set for theTab
key.static Type
getType()
Get the GType of the GridView classonActivate
(GridView.ActivateCallback handler) Emitted when a cell has been activated by the user, usually via activating the GtkGridView|list.activate-item action.void
scrollTo
(int pos, Set<ListScrollFlags> flags, @Nullable ScrollInfo scroll) Scrolls to the item at the given position and performs the actions specified inflags
.void
scrollTo
(int pos, ListScrollFlags flags, @Nullable ScrollInfo scroll) Scrolls to the item at the given position and performs the actions specified inflags
.void
setEnableRubberband
(boolean enableRubberband) Sets whether selections can be changed by dragging with the mouse.void
setFactory
(@Nullable ListItemFactory factory) Sets theGtkListItemFactory
to use for populating list items.void
setMaxColumns
(int maxColumns) Sets the maximum number of columns to use.void
setMinColumns
(int minColumns) Sets the minimum number of columns to use.void
setModel
(@Nullable SelectionModel model) Sets the model to use.void
setSingleClickActivate
(boolean singleClickActivate) Sets whether items should be activated on single click and selected on hover.void
setTabBehavior
(ListTabBehavior tabBehavior) Sets the behavior of theTab
andShift
+Tab
keys.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, 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.Orientable
getOrientation, setOrientation
Methods inherited from interface org.gnome.gtk.Scrollable
getBorder, getHadjustment, getHscrollPolicy, getVadjustment, getVscrollPolicy, setHadjustment, setHscrollPolicy, setVadjustment, setVscrollPolicy
-
Constructor Details
-
GridView
Create a GridView proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
GridView
public GridView(@Nullable @Nullable SelectionModel model, @Nullable @Nullable ListItemFactory factory) Creates a newGtkGridView
that uses the givenfactory
for 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
-
-
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. -
getEnableRubberband
public boolean getEnableRubberband()Returns whether rows can be selected by dragging with the mouse.- Returns:
true
if 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:
true
if items are activated on single click
-
getTabBehavior
Gets the behavior set for theTab
key.- Returns:
- The behavior of the
Tab
key
-
scrollTo
Scrolls to the item at the given position and performs the actions specified inflags
.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 ornull
to scroll into view
-
scrollTo
Scrolls to the item at the given position and performs the actions specified inflags
.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 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
-
setFactory
Sets theGtkListItemFactory
to 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
maxColumns
is 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
minColumns
is 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
-true
to activate items on single click
-
setTabBehavior
Sets the behavior of theTab
andShift
+Tab
keys.- Parameters:
tabBehavior
- The desired tab behavior
-
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:activatable
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.GridView.ActivateCallback)
. -
builder
AGridView.Builder
object constructs aGridView
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withGridView.Builder.build()
.
-