gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.TreeStore

Contents

- Exported types
- Methods
  - append
  - clear
  - insert
  - insertAfter
  - insertBefore
  - insertWithValues
  - isAncestor
  - iterDepth
  - iterIsValid
  - moveAfter
  - moveBefore
  - new
  - prepend
  - remove
  - set
  - setColumnTypes
  - setValue
  - swap

Description

A tree-like data structure that can be used with the `TreeView`.

The `GtkTreeStore` object is a list model for use with a `GtkTreeView` widget. It implements the `TreeModel` interface, and consequently, can use all of the methods available there. It also implements the `TreeSortable` interface so it can be sorted by the view. Finally, it also implements the tree [drag]t`TreeDragSource` and [drop]t`TreeDragDest` interfaces.

`GtkTreeStore` is deprecated since GTK 4.10, and should not be used in newly written code. You should use `TreeListModel` for a tree-like model object.

## GtkTreeStore as GtkBuildable

The GtkTreeStore implementation of the `GtkBuildable` interface allows to specify the model columns with a `<columns>` element that may contain multiple `<column>` elements, each specifying one model column. The “type” attribute specifies the data type for the column.

An example of a UI Definition fragment for a tree store:

### xml code

    <object class="GtkTreeStore">
      <columns>
        <column type="gchararray"/>
        <column type="gchararray"/>
        <column type="gint"/>
      </columns>
    </object>

Synopsis

- newtype TreeStore = TreeStore (ManagedPtr TreeStore)
- class (GObject o, IsDescendantOf TreeStore o) => IsTreeStore o
- toTreeStore :: (MonadIO m, IsTreeStore o) => o -> m TreeStore
- treeStoreAppend :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> m TreeIter
- treeStoreClear :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> m ()
- treeStoreInsert :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> Int32 -> m TreeIter
- treeStoreInsertAfter :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> Maybe TreeIter -> m TreeIter
- treeStoreInsertBefore :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> Maybe TreeIter -> m TreeIter
- treeStoreInsertWithValues :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> Int32 -> [Int32] -> [GValue] -> m TreeIter
- treeStoreIsAncestor :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> TreeIter -> m Bool
- treeStoreIterDepth :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> m Int32
- treeStoreIterIsValid :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> m Bool
- treeStoreMoveAfter :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> Maybe TreeIter -> m ()
- treeStoreMoveBefore :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> Maybe TreeIter -> m ()
- treeStoreNew :: (HasCallStack, MonadIO m) => [GType] -> m TreeStore
- treeStorePrepend :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> Maybe TreeIter -> m TreeIter
- treeStoreRemove :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> m Bool
- treeStoreSet :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> [Int32] -> [GValue] -> m ()
- treeStoreSetColumnTypes :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> [GType] -> m ()
- treeStoreSetValue :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> Int32 -> GValue -> m ()
- treeStoreSwap :: (HasCallStack, MonadIO m, IsTreeStore a) => a -> TreeIter -> TreeIter -> m ()

# Exported types

newtype TreeStore Source #

Memory-managed wrapper type.

Constructors

TreeStore (ManagedPtr TreeStore) |

#### Instances

Instances details

Eq TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore Methods (==) :: TreeStore -> TreeStore -> Bool Source # (/=) :: TreeStore -> TreeStore -> Bool Source #
GObject TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore
ManagedPtrNewtype TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore Methods toManagedPtr :: TreeStore -> ManagedPtr TreeStore Source #
TypedObject TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore Methods glibType :: IO GType Source #
HasParentTypes TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore
IsGValue (Maybe TreeStore) Source # | Convert `TreeStore` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.TreeStore Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe TreeStore -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe TreeStore) Source #
type ParentTypes TreeStore Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore type ParentTypes TreeStore = '[Object, Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable]

class (GObject o, IsDescendantOf TreeStore o) => IsTreeStore o Source #

Type class for types which can be safely cast to `TreeStore`, for instance with `toTreeStore`.

#### Instances

Instances details

(GObject o, IsDescendantOf TreeStore o) => IsTreeStore o Source # |
Instance details Defined in GI.Gtk.Objects.TreeStore

toTreeStore :: (MonadIO m, IsTreeStore o) => o -> m TreeStore Source #

Cast to `TreeStore`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

append, bindProperty, bindPropertyFull, clear, dragDataDelete, dragDataGet, dragDataReceived, filterNew, forceFloating, foreach, freezeNotify, getv, hasDefaultSortFunc, insert, insertAfter, insertBefore, insertWithValues, isAncestor, isFloating, iterChildren, iterDepth, iterHasChild, iterIsValid, iterNChildren, iterNext, iterNthChild, iterParent, iterPrevious, moveAfter, moveBefore, notify, notifyByPspec, prepend, ref, refNode, refSink, remove, rowChanged, rowDeleted, rowDraggable, rowDropPossible, rowHasChildToggled, rowInserted, rowsReordered, runDispose, set, sortColumnChanged, stealData, stealQdata, swap, thawNotify, unref, unrefNode, watchClosure.

#### Getters

getBuildableId, getColumnType, getData, getFlags, getIter, getIterFirst, getIterFromString, getNColumns, getPath, getProperty, getQdata, getSortColumnId, getStringFromIter, getValue.

#### Setters

setColumnTypes, setData, setDataFull, setDefaultSortFunc, setProperty, setSortColumnId, setSortFunc, setValue.

## append

treeStoreAppend Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Appends a new row to `treeStore`.

If `parent` is non-`Nothing`, then it will append the new row after the last child of `parent`, otherwise it will append a row to the top level.

The `iter` parameter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call `gtk_tree_store_set()` or `treeStoreSetValue`.

## clear

treeStoreClear Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: a `GtkTreeStore`
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Removes all rows from `treeStore`

## insert

treeStoreInsert Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> Int32 | `position`: position to insert the new row, or -1 for last
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Creates a new row at `position`.

If parent is non-`Nothing`, then the row will be made a child of `parent`. Otherwise, the row will be created at the toplevel.

If `position` is `-1` or is larger than the number of rows at that level, then the new row will be inserted to the end of the list.

The `iter` parameter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call `gtk_tree_store_set()` or `treeStoreSetValue`.

## insertAfter

treeStoreInsertAfter Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> Maybe TreeIter | `sibling`: A valid `GtkTreeIter`
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Inserts a new row after `sibling`.

If `sibling` is `Nothing`, then the row will be prepended to `parent`’s children.

If `parent` and `sibling` are `Nothing`, then the row will be prepended to the toplevel.

If both `sibling` and `parent` are set, then `parent` must be the parent of `sibling`. When `sibling` is set, `parent` is optional.

The `iter` parameter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call `gtk_tree_store_set()` or `treeStoreSetValue`.

## insertBefore

treeStoreInsertBefore Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> Maybe TreeIter | `sibling`: A valid `GtkTreeIter`
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Inserts a new row before `sibling`.

If `sibling` is `Nothing`, then the row will be appended to `parent`’s children.

If `parent` and `sibling` are `Nothing`, then the row will be appended to the toplevel.

If both `sibling` and `parent` are set, then `parent` must be the parent of `sibling`. When `sibling` is set, `parent` is optional.

The `iter` parameter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call `gtk_tree_store_set()` or `treeStoreSetValue`.

## insertWithValues

treeStoreInsertWithValues Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> Int32 | `position`: position to insert the new row, or -1 for last
-> [Int32] | `columns`: an array of column numbers
-> [GValue] | `values`: an array of GValues
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

A variant of `gtk_tree_store_insert_with_values()` which takes the columns and values as two arrays, instead of varargs.

This function is mainly intended for language bindings.

## isAncestor

treeStoreIsAncestor Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A valid `GtkTreeIter`
-> TreeIter | `descendant`: A valid `GtkTreeIter`
-> m Bool | Returns: true if `iter` is an ancestor of `descendant`, and false otherwise

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Checks if `iter` is an ancestor of `descendant`.

## iterDepth

treeStoreIterDepth Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A valid `GtkTreeIter`
-> m Int32 | Returns: The depth of the position pointed by the iterator

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Returns the depth of the position pointed by the iterator

The depth will be 0 for anything on the root level, 1 for anything down a level, etc.

## iterIsValid

treeStoreIterIsValid Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: a tree store
-> TreeIter | `iter`: the iterator to check
-> m Bool | Returns: true if the iter is valid, and false otherwise

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Checks if the given iter is a valid iter for this `GtkTreeStore`.

This function is slow. Only use it for debugging and/or testing purposes.

## moveAfter

treeStoreMoveAfter Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A `GtkTreeIter`.
-> Maybe TreeIter | `position`: A `GtkTreeIter`.
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Moves `iter` in `treeStore` to the position after `position`.

`iter` and `position` should be in the same level.

Note that this function only works with unsorted stores.

If `position` is `Nothing`, `iter` will be moved to the start of the level.

## moveBefore

treeStoreMoveBefore Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A `GtkTreeIter`
-> Maybe TreeIter | `position`: A `GtkTreeIter`
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Moves `iter` in `treeStore` to the position before `position`.

`iter` and `position` should be in the same level.

Note that this function only works with unsorted stores.

If `position` is `Nothing`, `iter` will be moved to the end of the level.

## new

treeStoreNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> [GType] | `types`: an array of `GType` types for the columns, from first to last
-> m TreeStore | Returns: a new `GtkTreeStore`

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Creates a new tree store.

This constructor is meant for language bindings.

## prepend

treeStorePrepend Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> Maybe TreeIter | `parent`: A valid `GtkTreeIter`
-> m TreeIter |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Prepends a new row to `treeStore`.

If `parent` is non-`Nothing`, then it will prepend the new row before the first child of `parent`, otherwise it will prepend a row to the top level. The `iter` parameter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call `gtk_tree_store_set()` or `treeStoreSetValue`.

## remove

treeStoreRemove Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A valid `GtkTreeIter`
-> m Bool | Returns: true if `iter` is still valid, and false otherwise

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Removes `iter` from `treeStore`.

After being removed, `iter` is set to the next valid row at that level, or invalidated if it previously pointed to the last one.

## set

treeStoreSet Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> TreeIter | `iter`: A valid `GtkTreeIter` for the row being modified
-> [Int32] | `columns`: an array of column numbers
-> [GValue] | `values`: an array of GValues
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

A variant of `gtk_tree_store_set_valist()` which takes the columns and values as two arrays, instead of using variadic arguments.

This function is mainly intended for language bindings or in case the number of columns to change is not known until run-time.

## setColumnTypes

treeStoreSetColumnTypes Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`
-> [GType] | `types`: An array of `GType` types, one for each column
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Sets the type of the columns in a tree store.

This function is meant primarily for types that inherit from `GtkTreeStore`, and should only be used when constructing a new `GtkTreeStore`.

This functions cannot be called after a row has been added, or a method on the `GtkTreeModel` interface is called on the tree store.

## setValue

treeStoreSetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: a `GtkTreeStore`
-> TreeIter | `iter`: A valid `GtkTreeIter` for the row being modified
-> Int32 | `column`: column number to modify
-> GValue | `value`: new value for the cell
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Sets the data in the cell specified by `iter` and `column`.

The type of `value` must be convertible to the type of the column.

## swap

treeStoreSwap Source #

Arguments

:: (HasCallStack, MonadIO m, IsTreeStore a) |
=> a | `treeStore`: A `GtkTreeStore`.
-> TreeIter | `a`: A `GtkTreeIter`.
-> TreeIter | `b`: Another `GtkTreeIter`.
-> m () |

Deprecated: (Since version 4.10)Use `TreeListModel` instead

Swaps `a` and `b` in the same level of `treeStore`.

Note that this function only works with unsorted stores.