module Graphics.UI.Gtk.Generics.TreeStore where
import Graphics.UI.Gtk
import Data.Tree
treeStoreGetActivatedElements :: TreeStore a
-> TreePath
-> IO [a]
treeStoreGetActivatedElements store path
| null ( init path ) = treeStoreGetValue store path >>= (\r -> return [r] )
| otherwise = ( treeStoreGetValue store path ) >>= ( \l ->
( treeStoreGetActivatedElements store ( init path ) ) >>= ( \f ->
return ( l : f ) ) )
findPath :: Eq a => Forest a
-> [a]
-> TreePath
findPath [] _ = []
findPath _ [] = []
findPath (x:xs) (y:ys)
| rootLabel x == y = 0 : findPath ( subForest x ) ys
| otherwise = case res of
[] -> []
(z:[]) -> 1 + z : []
(z:zs) -> 1 + z : zs
where res = findPath xs (y:ys)