JuliaLang/Gtk.jl — pull request #123 by jverzani (2014-09-26 17:24:45+00:00)
Title: tidy up store interface and fix selected

This pull request does two things: it adds a few methods for manipulating GtkListStore and GtkTreeStore objects and it fixes the `selected` method and adds `selected_rows` to mirror `gtk_tree_selection_get_selected` and `gtk_tree_selection_get_selected_rows` (which don't work with G_.select or G_.selected_rows, as far as I could tell).

The changes to the store methods are summarized below with - meaning dropped, + meaning added:

## store interface
push!(listStore::GtkListStore, values::Tuple)
unshift!(listStore::GtkListStore, values::Tuple)
insert!(listStore::GtkListStoreLeaf, index::Int, values)
+ insert!(listStore::GtkListStoreLeaf, iter::TRI, values)
empty!(listStore::GtkListStore)

delete!(listStore::GtkListStore, iter::TRI)
+ deleteat!(store, iter::TRI)
-splice!(listStore::GtkListStoreLeaf, index::Int)
+ deleteat!(listStore::GtkListStoreLeaf, index::Int)
+ pop! = deleteat!(store, length(store))

length(listStore::GtkListStore)
+ size(listStore) = (length(listStore, Gtk.ncolumns(GtkTreeModel(listStore))))

isvalid(listStore::GtkListStore, iter::TRI)

## indexing
+ getindex(listStore::GtkListStore, iter::TRI, column::Integer)) = getindex(GtkTreeModel(listStore), iter, column)
+ getindex(listStore::GtkListStore, iter::TRI) = getindex(GtkTreeModel(listStore), iter)
+ getindex(listStore, row::int, column) = getindex(listStore, iter_from_index(listStore, row), column)
+ getindex(listStore, row::int) = getindex(listStore, iter_from_index(listStore, row))

## what of setindex! ??

## no symmetry here, should this be addressed?
## get store from a view
getproperty(view, :model, Gtk.GtkListStore)
## set store for view, setproperty! fails
Gtk.G_.model(view, store)

## Tree store
push!(treeStore::GtkTreeStore, values::Tuple, parent=nothing)
unshift!(treeStore::GtkTreeStore, values::Tuple, parent=nothing)
insert!(treeStore::GtkTreeStoreLeaf, index::Vector{Int}, values; how::Symbol=:parent, where::Symbol=:after)

delete!(treeStore::GtkTreeStore, iter::TRI)
deleteat!(treeStore::GtkTreeStore, iter::TRI) = delete!(treeStore::GtkTreeStore, iter::TRI))
empty!(treeStore::GtkTreeStore)
+ deleteat!(treeStore::GtkTreeStoreLeaf, iter::TRI) ## delete at
-splice!(treeStore::GtkTreeStoreLeaf, index::Vector{Int}) ## delete at as new name
+deleteat!(treeStore::GtkTreeStoreLeaf, index::Vector{Int})

isvalid(treeStore::GtkTreeStore, iter::TRI)
isancestor(treeStore::GtkTreeStore, iter::TRI, descendant::TRI)
depth(treeStore::GtkTreeStore, iter::TRI)

getindex(treeModel::GtkTreeModel, iter::TRI, column::Integer)
getindex(treeModel::GtkTreeModel, iter::TRI)

setindex!(treeModel::GtkTreeModel, value, iter::TRI, column::Integer)
setindex!(treeModel::GtkTreeModel, values, iter::TRI)

## Selection
- selected(GtkTreeSelection): returned (model, iter) but with error
+ selected(GtkTreeSelection): return GtkTreeIter or error if no selection
select!(GtkTreeSelection, Iter)
+ selected_rows(GtkTreeSelection) return GtkTreeIter[] or error if no selection
selectall!(GtkTreeSelection)

unselect!(selection::GtkTreeSelection, iter::TRI
unselectall!(GtkTreeSelection)