Documentation ¶
Index ¶
- type TreeViewStructure
- func (tvs *TreeViewStructure) AddColumn(name, attribute string, ...)
- func (tvs *TreeViewStructure) AddColumns(nameAndAttribute [][]string, ...)
- func (tvs *TreeViewStructure) AddRow(parent *gtk.TreeIter, row ...interface{}) (iter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) AddTree(toggleCol, filepathCol int, stateDefault bool, ...) (outIter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) AllChildsCheckedState(parentIter *gtk.TreeIter, col int, state bool) bool
- func (tvs *TreeViewStructure) ChangeCheckState(toggleCol int, setState, orInvert bool)
- func (tvs *TreeViewStructure) ChildsPropagateColValue(parentIter *gtk.TreeIter, col int, value interface{}) (modifiedIters []*gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) Clear()
- func (tvs *TreeViewStructure) ClearAll() (err error)
- func (tvs *TreeViewStructure) ColNamesToStringSlice() (outSlice []string)
- func (tvs *TreeViewStructure) ColValuesStringSliceToIfaceSlice(inSlice ...string) (outIface []interface{})
- func (tvs *TreeViewStructure) CountRows() (count int)
- func (tvs *TreeViewStructure) DuplicateRow(inIter, parent *gtk.TreeIter) (iter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) ExpandAll(collapse ...bool)
- func (tvs *TreeViewStructure) GetColValue(iter *gtk.TreeIter, col int) (value interface{})
- func (tvs *TreeViewStructure) GetColValuePath(path *gtk.TreePath, col int) (value interface{})
- func (tvs *TreeViewStructure) GetColumns() (out []*gtk.TreeViewColumn)
- func (tvs *TreeViewStructure) GetRow(iter *gtk.TreeIter) (outSlice []string, err error)
- func (tvs *TreeViewStructure) GetRowIface(iter *gtk.TreeIter) (outIface []interface{}, err error)
- func (tvs *TreeViewStructure) GetRowNbIter(iter *gtk.TreeIter) int
- func (tvs *TreeViewStructure) GetSelectedIters() (iters []*gtk.TreeIter)
- func (tvs *TreeViewStructure) GetSelectedPaths() (paths []*gtk.TreePath)
- func (tvs *TreeViewStructure) GetSelectedRows() (outSlice [][]string, err error)
- func (tvs *TreeViewStructure) GetTreeCol(toggleCol, dataCols int) (checked, unChecked []string, err error)
- func (tvs *TreeViewStructure) GetTreeFullIface(toggleCol int) (checked, unChecked [][]interface{}, err error)
- func (tvs *TreeViewStructure) GetTreeParentIface(iter *gtk.TreeIter) ([]interface{}, error)
- func (tvs *TreeViewStructure) InsertColumn(name, attribute string, pos int, ...)
- func (tvs *TreeViewStructure) InsertRow(parent *gtk.TreeIter, insertPos int, row ...interface{}) (iter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) InsertRowAtIter(inIter, parent *gtk.TreeIter, row ...interface{}) (iter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) InsertRowAtIterN(inIter, parent *gtk.TreeIter, row []interface{}, before ...bool) (iter *gtk.TreeIter, err error)
- func (tvs *TreeViewStructure) IsNotEmpty() bool
- func (tvs *TreeViewStructure) IterScrollTo(iter *gtk.TreeIter, column ...int) (err error)
- func (tvs *TreeViewStructure) ItersSelect(iters ...*gtk.TreeIter)
- func (tvs *TreeViewStructure) ItersSelectRange(startIter, endIter *gtk.TreeIter) (err error)
- func (tvs *TreeViewStructure) ItersUnselect(iters ...*gtk.TreeIter)
- func (tvs *TreeViewStructure) ItersUnselectAll()
- func (tvs *TreeViewStructure) RemoveColumn(col int) (columnCount int)
- func (tvs *TreeViewStructure) RemoveRows(iters ...*gtk.TreeIter) (count int)
- func (tvs *TreeViewStructure) RemoveRowsPath(paths ...interface{}) (count int, err error)
- func (tvs *TreeViewStructure) RemoveSelectedRows(iters ...*gtk.TreeIter) (count int)
- func (tvs *TreeViewStructure) SetColValue(iter *gtk.TreeIter, col int, value interface{}) (err error)
- func (tvs *TreeViewStructure) SetColValuePath(path *gtk.TreePath, col int, goValue interface{}) (err error)
- func (tvs *TreeViewStructure) StoreAttach()
- func (tvs *TreeViewStructure) StoreColToIfaceSl(colIdx int) (outIface []interface{}, err error)
- func (tvs *TreeViewStructure) StoreColToStringSl(colIdx int) (out []string, err error)
- func (tvs *TreeViewStructure) StoreDetach()
- func (tvs *TreeViewStructure) StoreSetup(store gtk.ITreeModel) (err error)
- func (tvs *TreeViewStructure) StoreToIfaceSlice() (out [][]interface{}, err error)
- func (tvs *TreeViewStructure) StoreToStringSlice() (out [][]string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TreeViewStructure ¶
type TreeViewStructure struct { // Actual TreeModel. Used in some functions to avoid use of // (switch ... case) type selection. Model *gtk.TreeModel // Direct acces to implicated objects TreeView *gtk.TreeView ListStore *gtk.ListStore TreeStore *gtk.TreeStore Selection *gtk.TreeSelection // Basic options MultiSelection bool ActivateSingleClick bool // The model has been modified? Modified bool // All columns option are available throught this structure Columns []column ColumnsMinWidth int // Set a minimum width to avoid a warning gtk // TODO MAY CAUSE WHOLE FREEZE SOMETIME (undefined) // When "HasTooltip" is true, this function is launched, // Case of use: display tooltip according to rows currently hovered. // returned "bool" means display or not the tooltip. CallbackTooltipFunc func(iter *gtk.TreeIter, path *gtk.TreePath, column *gtk.TreeViewColumn, tooltip *gtk.Tooltip) bool HasTooltip, UseQueryTooltip bool // Function to call when the selection has (possibly) changed. SelectionChangedFunc func() // This function is called (if not nil) each time a column value is changed. CallbackOnSetColValue func(iter *gtk.TreeIter, col int, value interface{}) // Used for gtk.Model.ForEach functions ModelForEachFunc func(model *gtk.TreeModel, path *gtk.TreePath, iter *gtk.TreeIter) bool // Used for gtk.TreeSelection.SetSelectFunction SelectFunction func(selection *gtk.TreeSelection, model *gtk.TreeModel, path *gtk.TreePath, selected bool) bool // Used for gtk.TreeSelection.ForEachFunc SelectionForEachFunc func(model *gtk.TreeModel, path *gtk.TreePath, iter *gtk.TreeIter) // Used to determine wich TreeModel we work with. StoreType gtk.ITreeModel // contains filtered or unexported fields }
This library allow you to facilitate Treeview operations. Can manage ListView and TreeView, only one of them at a time. This lib handle every kind of column type as defined in the gtk3 development manual. Some conveignant functions are available to manage entries, columns, values, rows ... Notice: All options, functions, if they're needed, must be set before starting "StoreSetup" function. Otherwise, you can modify all of them at runtime using Gtk3 objects (TreeView, ListStore, TreeStore, Columns, and so on). You can access it using the main structure.
func TreeViewStructureNew ¶
func TreeViewStructureNew(treeView *gtk.TreeView, multiselection, activateSingleClick bool) (tvs *TreeViewStructure, err error)
Create a new treeview structure.
func (*TreeViewStructure) AddColumn ¶
func (tvs *TreeViewStructure) AddColumn(name, attribute string, editable, readOnly, sortable, resizable, expand, visible bool)
AddColumn: Adds a single new column to MainStructure. attribute may be: text, markup, pixbuf, combo, progress, spinner, active ... see above for complete list.
func (*TreeViewStructure) AddColumns ¶
func (tvs *TreeViewStructure) AddColumns(nameAndAttribute [][]string, editable, readOnly, sortable, resizable, expand, visible bool)
AddColumns: Adds several new columns to MainStructure. attribute may be: text, markup, pixbuf, combo, progress, spinner, active
func (*TreeViewStructure) AddRow ¶
func (tvs *TreeViewStructure) AddRow(parent *gtk.TreeIter, row ...interface{}) (iter *gtk.TreeIter, err error)
AddRow: Append a row to the Store (defined by type of "StoreType" variable). "parent" is useless for ListStore, if its set to nil on TreeStore, it will create a new parent
func (*TreeViewStructure) AddTree ¶
func (tvs *TreeViewStructure) AddTree( toggleCol, filepathCol int, stateDefault bool, callbackParentCreation func(store *gtk.TreeStore, iter *gtk.TreeIter, currentAddIdx int, iRow *[]interface{}) bool, iFace ...interface{}) (outIter *gtk.TreeIter, err error)
AddTree: This function, add a full tree to a TreeStore, childs will be added to parent's tree if exists or to a new created parent. Each entry handle a checkbox and a name only.
e.g: in 3 calls to 'AddTree' 'iFace' = []interface{"github.com", "hfmrow", "gtk3Import", "pango.go"} 'iFace' = []interface{"github.com", "hfmrow", "gtk3Import", "main.go"} 'iFace' = []interface{"github.com", "hfmrow", "gtk3Import", "view.go"} add all nodes for this tree to column 'filepathCol' and checkbox at 'toggleCol'
[] github.com [] ╰── hfmrow [] ╰── gtk3Import [] ├── pango.go [] ├── main.go [] ╰── view.go
- 'stateDefault' default value for 'toggleCol'.
- 'callbackParentCreation' can be 'nil', otherwise, this callback corresponds to the creation of the iter during the construction of the tree, allow to control (allows to manually add some usefull data to the row).
- The returned 'outIter', target the iter used by the the last entry, useful for manually adding more entries to columns if needed.
func (*TreeViewStructure) AllChildsCheckedState ¶
func (tvs *TreeViewStructure) AllChildsCheckedState(parentIter *gtk.TreeIter, col int, state bool) bool
AllChildsCheckedState: verify all childs and childs of childs then return false if one of them correspond to 'state' parameter. Otherwise, true is returned.
func (*TreeViewStructure) ChangeCheckState ¶
func (tvs *TreeViewStructure) ChangeCheckState(toggleCol int, setState, orInvert bool)
changeCheckState: 'setState' or invert list/treeview 'toggleCol'. NOTE: 'orInvert' is prioritized
func (*TreeViewStructure) ChildsPropagateColValue ¶
func (tvs *TreeViewStructure) ChildsPropagateColValue(parentIter *gtk.TreeIter, col int, value interface{}) (modifiedIters []*gtk.TreeIter, err error)
ChildsPropagateColValue: Add value to parent and to all childs at specific column. If 'value' is nil, no modification will be done but all children are returned.
func (*TreeViewStructure) Clear ¶
func (tvs *TreeViewStructure) Clear()
Clear: Clear the current used Model: unified version of gtk.TreeStore.Clear() or gtk.ListStore.Clear()
func (*TreeViewStructure) ClearAll ¶
func (tvs *TreeViewStructure) ClearAll() (err error)
ClearAll: Clear TreeView's columns, ListStore / TreeStore object. Depending on provided object type into the "StoreType" variable. To reuse structure, you must execute StoreSetup() again after added new columns.
func (*TreeViewStructure) ColNamesToStringSlice ¶
func (tvs *TreeViewStructure) ColNamesToStringSlice() (outSlice []string)
ColNamesToStringSlice: Retrieve column names as string slice
func (*TreeViewStructure) ColValuesStringSliceToIfaceSlice ¶
func (tvs *TreeViewStructure) ColValuesStringSliceToIfaceSlice(inSlice ...string) (outIface []interface{})
ColValuesStringSliceToIfaceSlice: Convert string list to []interface, for simplify adding text rows
func (*TreeViewStructure) CountRows ¶
func (tvs *TreeViewStructure) CountRows() (count int)
CountRows: Return the number of rows in treeview.
func (*TreeViewStructure) DuplicateRow ¶
func (tvs *TreeViewStructure) DuplicateRow(inIter, parent *gtk.TreeIter) (iter *gtk.TreeIter, err error)
TODO rewrite to be much faster DuplicateRow: Copy a row after iter to the listStore
func (*TreeViewStructure) ExpandAll ¶
func (tvs *TreeViewStructure) ExpandAll(collapse ...bool)
ExpandAll: Expand or collapse all tree/liststore nodes
func (*TreeViewStructure) GetColValue ¶
func (tvs *TreeViewStructure) GetColValue(iter *gtk.TreeIter, col int) (value interface{})
GetColValue: Get value from iter of specific column as interface type.
func (*TreeViewStructure) GetColValuePath ¶
func (tvs *TreeViewStructure) GetColValuePath(path *gtk.TreePath, col int) (value interface{})
GetColValueFromPath: Get value from path of specific column as interface type. Note: should be used only if there is no other choice, prefer using iter to get values.
func (*TreeViewStructure) GetColumns ¶
func (tvs *TreeViewStructure) GetColumns() (out []*gtk.TreeViewColumn)
GetColumns: Retieve columns available in the current TreeView.
func (*TreeViewStructure) GetRow ¶
func (tvs *TreeViewStructure) GetRow(iter *gtk.TreeIter) (outSlice []string, err error)
getRow: Get row from iter as []string
func (*TreeViewStructure) GetRowIface ¶
func (tvs *TreeViewStructure) GetRowIface(iter *gtk.TreeIter) (outIface []interface{}, err error)
GetRowIface: Get row from iter as []interface{}
func (*TreeViewStructure) GetRowNbIter ¶
func (tvs *TreeViewStructure) GetRowNbIter(iter *gtk.TreeIter) int
GetRowNbIter: Return the row number handled by the given iter, without any depth consideration.
func (*TreeViewStructure) GetSelectedIters ¶
func (tvs *TreeViewStructure) GetSelectedIters() (iters []*gtk.TreeIter)
GetSelectedIters: retrieve list of selected iters, return nil whether nothing selected.
func (*TreeViewStructure) GetSelectedPaths ¶
func (tvs *TreeViewStructure) GetSelectedPaths() (paths []*gtk.TreePath)
GetSelectedPaths: retrieve list of selected paths, return nil whether nothing selected.
func (*TreeViewStructure) GetSelectedRows ¶
func (tvs *TreeViewStructure) GetSelectedRows() (outSlice [][]string, err error)
GetSelectedRows: Get entries from selected iters as [][]string.
func (*TreeViewStructure) GetTreeCol ¶
func (tvs *TreeViewStructure) GetTreeCol(toggleCol, dataCols int) (checked, unChecked []string, err error)
GetTreeCol: This method retrieve data from a [single column] of the current 'GtkTreeStore' as []string. Use GetTreeFullIface to retrieve multiple columns at once.
func (*TreeViewStructure) GetTreeFullIface ¶
func (tvs *TreeViewStructure) GetTreeFullIface(toggleCol int) (checked, unChecked [][]interface{}, err error)
GetTreeFullIface: Retrieve the whole content of the current 'GtkTreeStore'.
func (*TreeViewStructure) GetTreeParentIface ¶
func (tvs *TreeViewStructure) GetTreeParentIface(iter *gtk.TreeIter) ([]interface{}, error)
GetTreeParentIface: return the 'row' holded by the parent of 'iter' or from itself whether having children. After call with success, provided 'iter' argument points to the one the line came from.
func (*TreeViewStructure) InsertColumn ¶
func (tvs *TreeViewStructure) InsertColumn(name, attribute string, pos int, editable, readOnly, sortable, resizable, expand, visible bool)
InsertColumn: Insert new column to MainStructure, StoreSetup method must be called after.
func (*TreeViewStructure) InsertRow ¶
func (tvs *TreeViewStructure) InsertRow(parent *gtk.TreeIter, insertPos int, row ...interface{}) (iter *gtk.TreeIter, err error)
InsertRow: Insert a row to the Store (defined by type of "StoreType" variable). "parent" is useless for ListStore, if its set to nil on TreeStore, it will create a new parent otherwise the new iter will be a child of it. "insertPos" indicate row number for insertion, set to -1 means append at the end.
func (*TreeViewStructure) InsertRowAtIter ¶
func (tvs *TreeViewStructure) InsertRowAtIter(inIter, parent *gtk.TreeIter, row ...interface{}) (iter *gtk.TreeIter, err error)
InsertRowAtIter: Insert a row after/before iter to "StoreType": ListStore/Treestore. Parent may be nil for Liststore.
func (*TreeViewStructure) InsertRowAtIterN ¶
func (tvs *TreeViewStructure) InsertRowAtIterN(inIter, parent *gtk.TreeIter, row []interface{}, before ...bool) (iter *gtk.TreeIter, err error)
InsertRowAtIter: Insert a row after/before iter to "StoreType": ListStore/Treestore. Parent may be nil for Liststore.
func (*TreeViewStructure) IsNotEmpty ¶
func (tvs *TreeViewStructure) IsNotEmpty() bool
IsNotEmpty: Returns 'true' if the TreeView is not empty.
func (*TreeViewStructure) IterScrollTo ¶
func (tvs *TreeViewStructure) IterScrollTo(iter *gtk.TreeIter, column ...int) (err error)
ScrollToIter: scroll to iter, pointing to the column if it has been specified.
func (*TreeViewStructure) ItersSelect ¶
func (tvs *TreeViewStructure) ItersSelect(iters ...*gtk.TreeIter)
ItersSelect: Select provided Iters.
func (*TreeViewStructure) ItersSelectRange ¶
func (tvs *TreeViewStructure) ItersSelectRange(startIter, endIter *gtk.TreeIter) (err error)
ItersSelectRange: Select range between start and end iters.
func (*TreeViewStructure) ItersUnselect ¶
func (tvs *TreeViewStructure) ItersUnselect(iters ...*gtk.TreeIter)
ItersUnselect: Unselect provided Iters.
func (*TreeViewStructure) ItersUnselectAll ¶
func (tvs *TreeViewStructure) ItersUnselectAll()
ItersUnselectAll: Unselect all selected iters.
func (*TreeViewStructure) RemoveColumn ¶
func (tvs *TreeViewStructure) RemoveColumn(col int) (columnCount int)
RemoveColumn: Remove column from MainStructure and TreeView.
func (*TreeViewStructure) RemoveRows ¶
func (tvs *TreeViewStructure) RemoveRows(iters ...*gtk.TreeIter) (count int)
RemoveRows: Unified remove iter(s) function
func (*TreeViewStructure) RemoveRowsPath ¶
func (tvs *TreeViewStructure) RemoveRowsPath(paths ...interface{}) (count int, err error)
RemoveRowsPath: Unified remove path(s) function. accept '*gtk.TreePath' & 'TreePath' as string
func (*TreeViewStructure) RemoveSelectedRows ¶
func (tvs *TreeViewStructure) RemoveSelectedRows(iters ...*gtk.TreeIter) (count int)
RemoveSelectedRows: Delete entries from selected iters or from given iters.
func (*TreeViewStructure) SetColValue ¶
func (tvs *TreeViewStructure) SetColValue(iter *gtk.TreeIter, col int, value interface{}) (err error)
SetColValue: Set value to iter for a specific column as interface type. If CallbackOnSetColValue is set, on each access, the function will be called.
func (*TreeViewStructure) SetColValuePath ¶
func (tvs *TreeViewStructure) SetColValuePath(path *gtk.TreePath, col int, goValue interface{}) (err error)
SetColValue: Set value to path for a specific column as interface type. Note: should be used only if there is no other choice, prefer using iter to set values.
func (*TreeViewStructure) StoreAttach ¶
func (tvs *TreeViewStructure) StoreAttach()
StoreAttach: To use after data insertion to restore the link with TreeView.
func (*TreeViewStructure) StoreColToIfaceSl ¶
func (tvs *TreeViewStructure) StoreColToIfaceSl(colIdx int) (outIface []interface{}, err error)
StoreColToIfaceSl: Retrieve specified column of the entire store as []interface{}.
func (*TreeViewStructure) StoreColToStringSl ¶
func (tvs *TreeViewStructure) StoreColToStringSl(colIdx int) (out []string, err error)
StoreColToStringSl: Retrieve specified column of the entire store as []string.
func (*TreeViewStructure) StoreDetach ¶
func (tvs *TreeViewStructure) StoreDetach()
StoreDetach: Unlink "TreeModel" from TreeView. Useful when lot of rows need be inserted. After insertion, StoreAttach() must be used to restore the link with the treeview. tips: must be used before ListStore/TreeStore.Clear().
func (*TreeViewStructure) StoreSetup ¶
func (tvs *TreeViewStructure) StoreSetup(store gtk.ITreeModel) (err error)
StoreSetup: Configure the TreeView columns and build the gtk.ListStore or gtk.TreeStore object. All parameters, personals or callback functions must be defined before calling StoreSetup in case you don't want to use the predefined ones and prefer to use your own (functions / callback). The "store" argument must be *gtk.ListStore or *gtk.TreeStore to indicate which kind of TreeModel we are working with ... i.e:
StoreSetup(new(gtk.TreeStore)), configure struct to work with a TreeStore. StoreSetup(new(gtk.ListStore)), configure struct to work with a ListStore.
func (*TreeViewStructure) StoreToIfaceSlice ¶
func (tvs *TreeViewStructure) StoreToIfaceSlice() (out [][]interface{}, err error)
GetTreeViewIface: retrieve whole content of a TreeView as [][]interface
func (*TreeViewStructure) StoreToStringSlice ¶
func (tvs *TreeViewStructure) StoreToStringSlice() (out [][]string, err error)
StoreToStringSlice: Retrieve all the rows values from a 'StoreType' as [][]string