Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GtkListView
presents a large dynamic list of items.
GtkListView
uses its factory to generate one row widget for each visible
item and shows them in a linear display, either vertically or horizontally.
The ListView:showSeparators property offers a simple way to display separators between the rows.
GtkListView
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
ListView:enableRubberband.
If you need multiple columns with headers, see ColumnView
.
To learn more about the list widget framework, see the overview.
An example of using GtkListView
:
c code
static void setup_listitem_cb (GtkListItemFactory *factory, GtkListItem *list_item) { GtkWidget *image; image = gtk_image_new (); gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE); gtk_list_item_set_child (list_item, image); } static void bind_listitem_cb (GtkListItemFactory *factory, GtkListItem *list_item) { GtkWidget *image; GAppInfo *app_info; image = gtk_list_item_get_child (list_item); app_info = gtk_list_item_get_item (list_item); gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info)); } static void activate_cb (GtkListView *list, guint position, gpointer unused) { GAppInfo *app_info; app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position); g_app_info_launch (app_info, NULL, NULL, NULL); g_object_unref (app_info); } ... model = create_application_list (); factory = gtk_signal_list_item_factory_new (); g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL); g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL); list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory); g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
CSS nodes
listview[.separators][.rich-list][.navigation-sidebar][.data-table] ├── row[.activatable] │ ├── row[.activatable] │ ┊ ╰── [rubberband]
GtkListView
uses a single CSS node named listview
. It may carry the
.separators
style class, when ListView:showSeparators
property is set. Each child widget uses a single CSS node named row
.
If the ListItem:activatable property is set, the
corresponding row will have the .activatable
style class. For
rubberband selection, a node with name rubberband
is used.
The main listview node may also carry style classes to select the style of list presentation: .rich-list, .navigation-sidebar or .data-table.
Accessibility
GtkListView
uses the AccessibleRoleList
role, and the list
items use the AccessibleRoleListItem
role.
Synopsis
- newtype ListView = ListView (ManagedPtr ListView)
- class (GObject o, IsDescendantOf ListView o) => IsListView o
- toListView :: (MonadIO m, IsListView o) => o -> m ListView
- listViewGetEnableRubberband :: (HasCallStack, MonadIO m, IsListView a) => a -> m Bool
- listViewGetFactory :: (HasCallStack, MonadIO m, IsListView a) => a -> m (Maybe ListItemFactory)
- listViewGetModel :: (HasCallStack, MonadIO m, IsListView a) => a -> m (Maybe SelectionModel)
- listViewGetShowSeparators :: (HasCallStack, MonadIO m, IsListView a) => a -> m Bool
- listViewGetSingleClickActivate :: (HasCallStack, MonadIO m, IsListView a) => a -> m Bool
- listViewNew :: (HasCallStack, MonadIO m, IsSelectionModel a, IsListItemFactory b) => Maybe a -> Maybe b -> m ListView
- listViewSetEnableRubberband :: (HasCallStack, MonadIO m, IsListView a) => a -> Bool -> m ()
- listViewSetFactory :: (HasCallStack, MonadIO m, IsListView a, IsListItemFactory b) => a -> Maybe b -> m ()
- listViewSetModel :: (HasCallStack, MonadIO m, IsListView a, IsSelectionModel b) => a -> Maybe b -> m ()
- listViewSetShowSeparators :: (HasCallStack, MonadIO m, IsListView a) => a -> Bool -> m ()
- listViewSetSingleClickActivate :: (HasCallStack, MonadIO m, IsListView a) => a -> Bool -> m ()
- constructListViewEnableRubberband :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o)
- getListViewEnableRubberband :: (MonadIO m, IsListView o) => o -> m Bool
- setListViewEnableRubberband :: (MonadIO m, IsListView o) => o -> Bool -> m ()
- clearListViewFactory :: (MonadIO m, IsListView o) => o -> m ()
- constructListViewFactory :: (IsListView o, MonadIO m, IsListItemFactory a) => a -> m (GValueConstruct o)
- getListViewFactory :: (MonadIO m, IsListView o) => o -> m (Maybe ListItemFactory)
- setListViewFactory :: (MonadIO m, IsListView o, IsListItemFactory a) => o -> a -> m ()
- clearListViewModel :: (MonadIO m, IsListView o) => o -> m ()
- constructListViewModel :: (IsListView o, MonadIO m, IsSelectionModel a) => a -> m (GValueConstruct o)
- getListViewModel :: (MonadIO m, IsListView o) => o -> m (Maybe SelectionModel)
- setListViewModel :: (MonadIO m, IsListView o, IsSelectionModel a) => o -> a -> m ()
- constructListViewShowSeparators :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o)
- getListViewShowSeparators :: (MonadIO m, IsListView o) => o -> m Bool
- setListViewShowSeparators :: (MonadIO m, IsListView o) => o -> Bool -> m ()
- constructListViewSingleClickActivate :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o)
- getListViewSingleClickActivate :: (MonadIO m, IsListView o) => o -> m Bool
- setListViewSingleClickActivate :: (MonadIO m, IsListView o) => o -> Bool -> m ()
- type ListViewActivateCallback = Word32 -> IO ()
- afterListViewActivate :: (IsListView a, MonadIO m) => a -> ((?self :: a) => ListViewActivateCallback) -> m SignalHandlerId
- onListViewActivate :: (IsListView a, MonadIO m) => a -> ((?self :: a) => ListViewActivateCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq ListView Source # | |
GObject ListView Source # | |
Defined in GI.Gtk.Objects.ListView | |
ManagedPtrNewtype ListView Source # | |
Defined in GI.Gtk.Objects.ListView toManagedPtr :: ListView -> ManagedPtr ListView | |
TypedObject ListView Source # | |
Defined in GI.Gtk.Objects.ListView | |
HasParentTypes ListView Source # | |
Defined in GI.Gtk.Objects.ListView | |
IsGValue (Maybe ListView) Source # | Convert |
Defined in GI.Gtk.Objects.ListView gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe ListView -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe ListView) | |
type ParentTypes ListView Source # | |
Defined in GI.Gtk.Objects.ListView type ParentTypes ListView = '[ListBase, Widget, Object, Accessible, Buildable, ConstraintTarget, Orientable, Scrollable] |
class (GObject o, IsDescendantOf ListView o) => IsListView o Source #
Type class for types which can be safely cast to ListView
, for instance with toListView
.
Instances
(GObject o, IsDescendantOf ListView o) => IsListView o Source # | |
Defined in GI.Gtk.Objects.ListView |
toListView :: (MonadIO m, IsListView o) => o -> m ListView Source #
Methods
Click to display all available methods, including inherited ones
Methods
actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBorder, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getEnableRubberband, getFactory, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHadjustment, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getHscrollPolicy, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getModel, getName, getNative, getNextSibling, getOpacity, getOrientation, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getShowSeparators, getSingleClickActivate, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getVadjustment, getValign, getVexpand, getVexpandSet, getVisible, getVscrollPolicy, getWidth.
Setters
setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setEnableRubberband, setFactory, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHadjustment, setHalign, setHasTooltip, setHexpand, setHexpandSet, setHscrollPolicy, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setModel, setName, setOpacity, setOrientation, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setShowSeparators, setSingleClickActivate, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setVadjustment, setValign, setVexpand, setVexpandSet, setVisible, setVscrollPolicy.
getEnableRubberband
listViewGetEnableRubberband Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether rows can be selected by dragging with the mouse.
getFactory
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> m (Maybe ListItemFactory) | Returns: The factory in use |
Gets the factory that's currently used to populate list items.
getModel
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> m (Maybe SelectionModel) | Returns: The model in use |
Gets the model that's currently used to read the items displayed.
getShowSeparators
listViewGetShowSeparators Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the list box should show separators between rows.
getSingleClickActivate
listViewGetSingleClickActivate Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether rows will be activated on single click and selected on hover.
new
:: (HasCallStack, MonadIO m, IsSelectionModel a, IsListItemFactory b) | |
=> Maybe a |
|
-> Maybe b |
|
-> m ListView | Returns: a new |
Creates a new GtkListView
that uses the given factory
for
mapping items to widgets.
The function takes ownership of the arguments, so you can write code like
c code
list_view = gtk_list_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
setEnableRubberband
listViewSetEnableRubberband Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether selections can be changed by dragging with the mouse.
setFactory
:: (HasCallStack, MonadIO m, IsListView a, IsListItemFactory b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the GtkListItemFactory
to use for populating list items.
setModel
:: (HasCallStack, MonadIO m, IsListView a, IsSelectionModel b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the model to use.
This must be a SelectionModel
to use.
setShowSeparators
listViewSetShowSeparators Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the list box should show separators between rows.
setSingleClickActivate
listViewSetSingleClickActivate Source #
:: (HasCallStack, MonadIO m, IsListView a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether rows should be activated on single click and selected on hover.
Properties
enableRubberband
Allow rubberband selection.
constructListViewEnableRubberband :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “enable-rubberband
” property. This is rarely needed directly, but it is used by new
.
getListViewEnableRubberband :: (MonadIO m, IsListView o) => o -> m Bool Source #
Get the value of the “enable-rubberband
” property.
When overloading is enabled, this is equivalent to
get
listView #enableRubberband
setListViewEnableRubberband :: (MonadIO m, IsListView o) => o -> Bool -> m () Source #
Set the value of the “enable-rubberband
” property.
When overloading is enabled, this is equivalent to
set
listView [ #enableRubberband:=
value ]
factory
Factory for populating list items.
clearListViewFactory :: (MonadIO m, IsListView o) => o -> m () Source #
Set the value of the “factory
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#factory
constructListViewFactory :: (IsListView o, MonadIO m, IsListItemFactory a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “factory
” property. This is rarely needed directly, but it is used by new
.
getListViewFactory :: (MonadIO m, IsListView o) => o -> m (Maybe ListItemFactory) Source #
Get the value of the “factory
” property.
When overloading is enabled, this is equivalent to
get
listView #factory
setListViewFactory :: (MonadIO m, IsListView o, IsListItemFactory a) => o -> a -> m () Source #
Set the value of the “factory
” property.
When overloading is enabled, this is equivalent to
set
listView [ #factory:=
value ]
model
Model for the items displayed.
clearListViewModel :: (MonadIO m, IsListView o) => o -> m () Source #
Set the value of the “model
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#model
constructListViewModel :: (IsListView o, MonadIO m, IsSelectionModel a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “model
” property. This is rarely needed directly, but it is used by new
.
getListViewModel :: (MonadIO m, IsListView o) => o -> m (Maybe SelectionModel) Source #
Get the value of the “model
” property.
When overloading is enabled, this is equivalent to
get
listView #model
setListViewModel :: (MonadIO m, IsListView o, IsSelectionModel a) => o -> a -> m () Source #
Set the value of the “model
” property.
When overloading is enabled, this is equivalent to
set
listView [ #model:=
value ]
showSeparators
Show separators between rows.
constructListViewShowSeparators :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “show-separators
” property. This is rarely needed directly, but it is used by new
.
getListViewShowSeparators :: (MonadIO m, IsListView o) => o -> m Bool Source #
Get the value of the “show-separators
” property.
When overloading is enabled, this is equivalent to
get
listView #showSeparators
setListViewShowSeparators :: (MonadIO m, IsListView o) => o -> Bool -> m () Source #
Set the value of the “show-separators
” property.
When overloading is enabled, this is equivalent to
set
listView [ #showSeparators:=
value ]
singleClickActivate
Activate rows on single click and select them on hover.
constructListViewSingleClickActivate :: (IsListView o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “single-click-activate
” property. This is rarely needed directly, but it is used by new
.
getListViewSingleClickActivate :: (MonadIO m, IsListView o) => o -> m Bool Source #
Get the value of the “single-click-activate
” property.
When overloading is enabled, this is equivalent to
get
listView #singleClickActivate
setListViewSingleClickActivate :: (MonadIO m, IsListView o) => o -> Bool -> m () Source #
Set the value of the “single-click-activate
” property.
When overloading is enabled, this is equivalent to
set
listView [ #singleClickActivate:=
value ]
Signals
activate
type ListViewActivateCallback Source #
Emitted when a row has been activated by the user, usually via activating the GtkListView|list.activate-item action.
This allows for a convenient way to handle activation in a listview.
See listItemSetActivatable
for details on how to use
this signal.
afterListViewActivate :: (IsListView a, MonadIO m) => a -> ((?self :: a) => ListViewActivateCallback) -> m SignalHandlerId Source #
Connect a signal handler for the activate signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
listView #activate callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onListViewActivate :: (IsListView a, MonadIO m) => a -> ((?self :: a) => ListViewActivateCallback) -> m SignalHandlerId Source #
Connect a signal handler for the activate signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
listView #activate callback