GTK: refactor 'onRow' and split out 'getSelectedRow'
This commit is contained in:
parent
82a4269cf7
commit
585a9fcc38
@ -50,6 +50,10 @@ import Data.Maybe
|
|||||||
, catMaybes
|
, catMaybes
|
||||||
, fromMaybe
|
, fromMaybe
|
||||||
)
|
)
|
||||||
|
import Data.Traversable
|
||||||
|
(
|
||||||
|
forM
|
||||||
|
)
|
||||||
import Graphics.UI.Gtk
|
import Graphics.UI.Gtk
|
||||||
import GUI.Gtk.Icons
|
import GUI.Gtk.Icons
|
||||||
import IO.Error
|
import IO.Error
|
||||||
@ -181,6 +185,22 @@ urlGoTo mygui myview = do
|
|||||||
refreshTreeView mygui myview (Just fp)
|
refreshTreeView mygui myview (Just fp)
|
||||||
|
|
||||||
|
|
||||||
|
-- |Gets the currently selected row of the treeView, if any.
|
||||||
|
getSelectedRow :: MyGUI
|
||||||
|
-> MyView
|
||||||
|
-> IO (Maybe (DTZipper DirTreeInfo DirTreeInfo))
|
||||||
|
getSelectedRow mygui myview = do
|
||||||
|
(tp, _) <- treeViewGetCursor $ treeView mygui
|
||||||
|
rawModel' <- readTVarIO $ rawModel myview
|
||||||
|
sortedModel' <- readTVarIO $ sortedModel myview
|
||||||
|
filteredModel' <- readTVarIO $ filteredModel myview
|
||||||
|
miter <- treeModelGetIter sortedModel' tp
|
||||||
|
forM miter $ \iter -> do
|
||||||
|
cIter' <- treeModelSortConvertIterToChildIter sortedModel' iter
|
||||||
|
cIter <- treeModelFilterConvertIterToChildIter filteredModel' cIter'
|
||||||
|
treeModelGetRow rawModel' cIter
|
||||||
|
|
||||||
|
|
||||||
-- |Callback for file operations on a row, e.g. open, delete, etc.
|
-- |Callback for file operations on a row, e.g. open, delete, etc.
|
||||||
--
|
--
|
||||||
-- This might update the TVar `rawModel`.
|
-- This might update the TVar `rawModel`.
|
||||||
@ -189,15 +209,8 @@ onRow :: FileOperation
|
|||||||
-> MyView
|
-> MyView
|
||||||
-> IO ()
|
-> IO ()
|
||||||
onRow fo mygui myview = do
|
onRow fo mygui myview = do
|
||||||
(tp, _) <- treeViewGetCursor $ treeView mygui
|
mrow <- getSelectedRow mygui myview
|
||||||
rawModel' <- readTVarIO $ rawModel myview
|
for_ mrow $ \row ->
|
||||||
sortedModel' <- readTVarIO $ sortedModel myview
|
|
||||||
filteredModel' <- readTVarIO $ filteredModel myview
|
|
||||||
miter <- treeModelGetIter sortedModel' tp
|
|
||||||
for_ miter $ \iter -> do
|
|
||||||
cIter' <- treeModelSortConvertIterToChildIter sortedModel' iter
|
|
||||||
cIter <- treeModelFilterConvertIterToChildIter filteredModel' cIter'
|
|
||||||
row <- treeModelGetRow rawModel' cIter
|
|
||||||
case fo of
|
case fo of
|
||||||
Open -> open row
|
Open -> open row
|
||||||
Delete -> del row
|
Delete -> del row
|
||||||
|
Loading…
Reference in New Issue
Block a user