gi-gtk-3.0.11: Gtk bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.ListBox

Contents

Description

A GtkListBox is a vertical container that contains GtkListBoxRow children. These rows can by dynamically sorted and filtered, and headers can be added dynamically depending on the row content. It also allows keyboard and mouse navigation and selection like a typical list.

Using GtkListBox is often an alternative to TreeView, especially when the list contents has a more complicated layout than what is allowed by a CellRenderer, or when the contents is interactive (i.e. has a button in it).

Although a ListBox must have only ListBoxRow children you can add any kind of widget to it via containerAdd, and a ListBoxRow widget will automatically be inserted between the list and the widget.

GtkListBoxRows can be marked as activatable or selectable. If a row is activatable, ListBox::row-activated will be emitted for it when the user tries to activate it. If it is selectable, the row will be marked as selected when the user tries to select it.

The GtkListBox widget was added in GTK+ 3.10.

CSS nodes

plain code

list
╰── row[.activatable]

GtkListBox uses a single CSS node named list. Each GtkListBoxRow uses a single CSS node named row. The row nodes get the .activatable style class added when appropriate.

Synopsis

Exported types

Methods

bindModel

listBoxBindModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsListModel b) 
=> a

box: a ListBox

-> Maybe b

model: the ListModel to be bound to box

-> Maybe ListBoxCreateWidgetFunc

createWidgetFunc: a function that creates widgets for items or Nothing in case you also passed Nothing as model

-> m () 

Binds model to box.

If box was already bound to a model, that previous binding is destroyed.

The contents of box are cleared and then filled with widgets that represent items from model. box is updated whenever model changes. If model is Nothing, box is left empty.

It is undefined to add or remove widgets directly (for example, with listBoxInsert or containerAdd) while box is bound to a model.

Note that using a model is incompatible with the filtering and sorting functionality in GtkListBox. When using a model, filtering and sorting should be implemented by the model.

Since: 3.16

dragHighlightRow

listBoxDragHighlightRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsListBoxRow b) 
=> a

box: a ListBox

-> b

row: a ListBoxRow

-> m () 

This is a helper function for implementing DnD onto a ListBox. The passed in row will be highlighted via widgetDragHighlight, and any previously highlighted row will be unhighlighted.

The row will also be unhighlighted when the widget gets a drag leave event.

Since: 3.10

dragUnhighlightRow

listBoxDragUnhighlightRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

If a row has previously been highlighted via listBoxDragHighlightRow it will have the highlight removed.

Since: 3.10

getActivateOnSingleClick

listBoxGetActivateOnSingleClick Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m Bool

Returns: True if rows are activated on single click, False otherwise

Returns whether rows activate on single clicks.

Since: 3.10

getAdjustment

listBoxGetAdjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m Adjustment

Returns: the adjustment

Gets the adjustment (if any) that the widget uses to for vertical scrolling.

Since: 3.10

getRowAtIndex

listBoxGetRowAtIndex Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Int32

index_: the index of the row

-> m (Maybe ListBoxRow)

Returns: the child Widget or Nothing

Gets the n-th child in the list (not counting headers). If index_ is negative or larger than the number of items in the list, Nothing is returned.

Since: 3.10

getRowAtY

listBoxGetRowAtY Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Int32

y: position

-> m (Maybe ListBoxRow)

Returns: the row or Nothing in case no row exists for the given y coordinate.

Gets the row at the y position.

Since: 3.10

getSelectedRow

listBoxGetSelectedRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m ListBoxRow

Returns: the selected row

Gets the selected row.

Note that the box may allow multiple selection, in which case you should use listBoxSelectedForeach to find all selected rows.

Since: 3.10

getSelectedRows

listBoxGetSelectedRows Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m [ListBoxRow]

Returns: A List containing the Widget for each selected child. Free with g_list_free() when done.

Creates a list of all selected children.

Since: 3.14

getSelectionMode

listBoxGetSelectionMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m SelectionMode

Returns: a SelectionMode

Gets the selection mode of the listbox.

Since: 3.10

insert

data ListBoxInsertMethodInfo Source #

Instances

((~) * signature (b -> Int32 -> m ()), MonadIO m, IsListBox a, IsWidget b) => MethodInfo * ListBoxInsertMethodInfo a signature Source # 

listBoxInsert Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsWidget b) 
=> a

box: a ListBox

-> b

child: the Widget to add

-> Int32

position: the position to insert child in

-> m () 

Insert the child into the box at position. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of containerAdd.

If position is -1, or larger than the total number of items in the box, then the child will be appended to the end.

Since: 3.10

invalidateFilter

listBoxInvalidateFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

Update the filtering for all rows. Call this when result of the filter function on the box is changed due to an external factor. For instance, this would be used if the filter function just looked for a specific search string and the entry with the search string has changed.

Since: 3.10

invalidateHeaders

listBoxInvalidateHeaders Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

Update the separators for all rows. Call this when result of the header function on the box is changed due to an external factor.

Since: 3.10

invalidateSort

listBoxInvalidateSort Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

Update the sorting for all rows. Call this when result of the sort function on the box is changed due to an external factor.

Since: 3.10

new

listBoxNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m ListBox

Returns: a new ListBox

Creates a new ListBox container.

Since: 3.10

prepend

data ListBoxPrependMethodInfo Source #

Instances

((~) * signature (b -> m ()), MonadIO m, IsListBox a, IsWidget b) => MethodInfo * ListBoxPrependMethodInfo a signature Source # 

listBoxPrepend Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsWidget b) 
=> a

box: a ListBox

-> b

child: the Widget to add

-> m () 

Prepend a widget to the list. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of containerAdd.

Since: 3.10

selectAll

data ListBoxSelectAllMethodInfo Source #

Instances

((~) * signature (m ()), MonadIO m, IsListBox a) => MethodInfo * ListBoxSelectAllMethodInfo a signature Source # 

listBoxSelectAll Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

Select all children of box, if the selection mode allows it.

Since: 3.14

selectRow

data ListBoxSelectRowMethodInfo Source #

Instances

((~) * signature (Maybe b -> m ()), MonadIO m, IsListBox a, IsListBoxRow b) => MethodInfo * ListBoxSelectRowMethodInfo a signature Source # 

listBoxSelectRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsListBoxRow b) 
=> a

box: a ListBox

-> Maybe b

row: The row to select or Nothing

-> m () 

Make row the currently selected row.

Since: 3.10

selectedForeach

listBoxSelectedForeach Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> ListBoxForeachFunc

func: the function to call for each selected child

-> m () 

Calls a function for each selected child.

Note that the selection cannot be modified from within this function.

Since: 3.14

setActivateOnSingleClick

listBoxSetActivateOnSingleClick Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Bool

single: a boolean

-> m () 

If single is True, rows will be activated when you click on them, otherwise you need to double-click.

Since: 3.10

setAdjustment

listBoxSetAdjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsAdjustment b) 
=> a

box: a ListBox

-> Maybe b

adjustment: the adjustment, or Nothing

-> m () 

Sets the adjustment (if any) that the widget uses to for vertical scrolling. For instance, this is used to get the page size for PageUp/Down key handling.

In the normal case when the box is packed inside a ScrolledWindow the adjustment from that will be picked up automatically, so there is no need to manually do that.

Since: 3.10

setFilterFunc

listBoxSetFilterFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Maybe ListBoxFilterFunc

filterFunc: callback that lets you filter which rows to show

-> m () 

By setting a filter function on the box one can decide dynamically which of the rows to show. For instance, to implement a search function on a list that filters the original list to only show the matching rows.

The filterFunc will be called for each row after the call, and it will continue to be called each time a row changes (via listBoxRowChanged) or when listBoxInvalidateFilter is called.

Note that using a filter function is incompatible with using a model (see listBoxBindModel).

Since: 3.10

setHeaderFunc

listBoxSetHeaderFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Maybe ListBoxUpdateHeaderFunc

updateHeader: callback that lets you add row headers

-> m () 

By setting a header function on the box one can dynamically add headers in front of rows, depending on the contents of the row and its position in the list. For instance, one could use it to add headers in front of the first item of a new kind, in a list sorted by the kind.

The updateHeader can look at the current header widget using listBoxRowGetHeader and either update the state of the widget as needed, or set a new one using listBoxRowSetHeader. If no header is needed, set the header to Nothing.

Note that you may get many calls updateHeader to this for a particular row when e.g. changing things that don’t affect the header. In this case it is important for performance to not blindly replace an existing header with an identical one.

The updateHeader function will be called for each row after the call, and it will continue to be called each time a row changes (via listBoxRowChanged) and when the row before changes (either by listBoxRowChanged on the previous row, or when the previous row becomes a different row). It is also called for all rows when listBoxInvalidateHeaders is called.

Since: 3.10

setPlaceholder

listBoxSetPlaceholder Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsWidget b) 
=> a

box: a ListBox

-> Maybe b

placeholder: a Widget or Nothing

-> m () 

Sets the placeholder widget that is shown in the list when it doesn't display any visible children.

Since: 3.10

setSelectionMode

listBoxSetSelectionMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> SelectionMode

mode: The SelectionMode

-> m () 

Sets how selection works in the listbox. See SelectionMode for details.

Since: 3.10

setSortFunc

listBoxSetSortFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> Maybe ListBoxSortFunc

sortFunc: the sort function

-> m () 

By setting a sort function on the box one can dynamically reorder the rows of the list, based on the contents of the rows.

The sortFunc will be called for each row after the call, and will continue to be called each time a row changes (via listBoxRowChanged) and when listBoxInvalidateSort is called.

Note that using a sort function is incompatible with using a model (see listBoxBindModel).

Since: 3.10

unselectAll

data ListBoxUnselectAllMethodInfo Source #

Instances

((~) * signature (m ()), MonadIO m, IsListBox a) => MethodInfo * ListBoxUnselectAllMethodInfo a signature Source # 

listBoxUnselectAll Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a) 
=> a

box: a ListBox

-> m () 

Unselect all children of box, if the selection mode allows it.

Since: 3.14

unselectRow

data ListBoxUnselectRowMethodInfo Source #

Instances

((~) * signature (b -> m ()), MonadIO m, IsListBox a, IsListBoxRow b) => MethodInfo * ListBoxUnselectRowMethodInfo a signature Source # 

listBoxUnselectRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsListBox a, IsListBoxRow b) 
=> a

box: a ListBox

-> b

row: the row to unselected

-> m () 

Unselects a single row of box, if the selection mode allows it.

Since: 3.14

Properties

activateOnSingleClick

data ListBoxActivateOnSingleClickPropertyInfo Source #

Instances

AttrInfo ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrOrigin ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrLabel ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrLabel ListBoxActivateOnSingleClickPropertyInfo = "activate-on-single-click"
type AttrGetType ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrBaseTypeConstraint ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrSetTypeConstraint ListBoxActivateOnSingleClickPropertyInfo Source # 
type AttrAllowedOps ListBoxActivateOnSingleClickPropertyInfo Source # 

selectionMode

data ListBoxSelectionModePropertyInfo Source #

Instances

AttrInfo ListBoxSelectionModePropertyInfo Source # 
type AttrOrigin ListBoxSelectionModePropertyInfo Source # 
type AttrLabel ListBoxSelectionModePropertyInfo Source # 
type AttrGetType ListBoxSelectionModePropertyInfo Source # 
type AttrBaseTypeConstraint ListBoxSelectionModePropertyInfo Source # 
type AttrSetTypeConstraint ListBoxSelectionModePropertyInfo Source # 
type AttrAllowedOps ListBoxSelectionModePropertyInfo Source # 

Signals

activateCursorRow

moveCursor

type C_ListBoxMoveCursorCallback = Ptr () -> CUInt -> Int32 -> Ptr () -> IO () Source #

rowActivated

rowSelected

selectAll

selectedRowsChanged

toggleCursorRow

unselectAll