module Graphics.UI.Gtk.Helpers.ModelViewNotebookSync where
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Helpers.ModelViewPath
import Graphics.UI.Gtk.Layout.MaybeWidget
modelViewNotebookSync :: (ViewWithPathSelection a c, NotebookClass b)
=> a -> b -> (TreePath -> Int) -> IO()
modelViewNotebookSync modelView notebook syncF = do
(path, _) <- modelViewGetCursor modelView
let page = syncF path
notebookSetCurrentPage notebook page
modelViewNotebookSyncId :: (ViewWithPathSelection a c, NotebookClass b) => a -> b -> IO()
modelViewNotebookSyncId modelView notebook = do
(path, _) <- modelViewGetCursor modelView
case path of
[page] -> notebookSetCurrentPage notebook page
_ -> return ()
modelViewMaybeNotebookSync :: (ViewWithPathSelection a c, NotebookClass b)
=> a -> MaybeWidget b -> (TreePath -> Maybe Int) -> IO()
modelViewMaybeNotebookSync modelView maybeNotebook syncF = do
(path, _) <- modelViewGetCursor modelView
case syncF path of
Nothing -> set maybeNotebook [ maybeWidgetActivated := False]
Just p -> do set maybeNotebook [ maybeWidgetActivated := True ]
notebookSetCurrentPage (maybeWidgetGetWidget maybeNotebook) p
modelViewMaybeNotebookSyncId :: (ViewWithPathSelection a c, NotebookClass b)
=> a -> MaybeWidget b -> IO()
modelViewMaybeNotebookSyncId modelView maybeNotebook = do
(path, _) <- modelViewGetCursor modelView
case path of
[page] -> do set maybeNotebook [ maybeWidgetActivated := True ]
notebookSetCurrentPage (maybeWidgetGetWidget maybeNotebook) page
_ -> set maybeNotebook [ maybeWidgetActivated := False ]