GTK: remove tab label side-effect from refreshView'
This would cause bugs when newtab on middle-click is implemented, since creating a new tab creates also a new view, but doesn't change the current tab to that view. refreshView' would then update that view with the information from the wrong tab.
This commit is contained in:
parent
7fef11ecd2
commit
01c241a01e
@ -458,7 +458,7 @@ urlGoTo mygui myview = withErrorDialog $ do
|
|||||||
fp <- entryGetText (urlBar myview)
|
fp <- entryGetText (urlBar myview)
|
||||||
forM_ (P.parseAbs fp :: Maybe (Path Abs)) $ \fp' ->
|
forM_ (P.parseAbs fp :: Maybe (Path Abs)) $ \fp' ->
|
||||||
whenM (canOpenDirectory fp')
|
whenM (canOpenDirectory fp')
|
||||||
(goDir mygui myview =<< (readFile getFileInfo $ fp'))
|
(goDir True mygui myview =<< (readFile getFileInfo $ fp'))
|
||||||
|
|
||||||
|
|
||||||
goHome :: MyGUI -> MyView -> IO ()
|
goHome :: MyGUI -> MyView -> IO ()
|
||||||
@ -466,7 +466,7 @@ goHome mygui myview = withErrorDialog $ do
|
|||||||
mhomedir <- getEnv "HOME"
|
mhomedir <- getEnv "HOME"
|
||||||
forM_ (P.parseAbs =<< mhomedir :: Maybe (Path Abs)) $ \fp' ->
|
forM_ (P.parseAbs =<< mhomedir :: Maybe (Path Abs)) $ \fp' ->
|
||||||
whenM (canOpenDirectory fp')
|
whenM (canOpenDirectory fp')
|
||||||
(goDir mygui myview =<< (readFile getFileInfo $ fp'))
|
(goDir True mygui myview =<< (readFile getFileInfo $ fp'))
|
||||||
|
|
||||||
|
|
||||||
-- |Execute a given file.
|
-- |Execute a given file.
|
||||||
@ -484,7 +484,7 @@ open [item] mygui myview = withErrorDialog $
|
|||||||
case item of
|
case item of
|
||||||
DirOrSym r -> do
|
DirOrSym r -> do
|
||||||
nv <- readFile getFileInfo $ path r
|
nv <- readFile getFileInfo $ path r
|
||||||
goDir mygui myview nv
|
goDir True mygui myview nv
|
||||||
r ->
|
r ->
|
||||||
void $ openFile . path $ r
|
void $ openFile . path $ r
|
||||||
-- this throws on the first error that occurs
|
-- this throws on the first error that occurs
|
||||||
@ -500,7 +500,7 @@ upDir :: MyGUI -> MyView -> IO ()
|
|||||||
upDir mygui myview = withErrorDialog $ do
|
upDir mygui myview = withErrorDialog $ do
|
||||||
cdir <- getCurrentDir myview
|
cdir <- getCurrentDir myview
|
||||||
nv <- goUp cdir
|
nv <- goUp cdir
|
||||||
goDir mygui myview nv
|
goDir True mygui myview nv
|
||||||
|
|
||||||
|
|
||||||
-- |Go "back" in the history.
|
-- |Go "back" in the history.
|
||||||
@ -514,7 +514,7 @@ goHistoryPrev mygui myview = do
|
|||||||
nv <- readFile getFileInfo $ x
|
nv <- readFile getFileInfo $ x
|
||||||
modifyTVarIO (history myview)
|
modifyTVarIO (history myview)
|
||||||
(\(_, n) -> (xs, path cdir `addHistory` n))
|
(\(_, n) -> (xs, path cdir `addHistory` n))
|
||||||
refreshView' mygui myview nv
|
goDir False mygui myview nv
|
||||||
|
|
||||||
|
|
||||||
-- |Go "forth" in the history.
|
-- |Go "forth" in the history.
|
||||||
@ -528,5 +528,5 @@ goHistoryNext mygui myview = do
|
|||||||
nv <- readFile getFileInfo $ x
|
nv <- readFile getFileInfo $ x
|
||||||
modifyTVarIO (history myview)
|
modifyTVarIO (history myview)
|
||||||
(\(p, _) -> (path cdir `addHistory` p, xs))
|
(\(p, _) -> (path cdir `addHistory` p, xs))
|
||||||
refreshView' mygui myview nv
|
goDir False mygui myview nv
|
||||||
|
|
||||||
|
@ -28,11 +28,16 @@ import Control.Monad
|
|||||||
(
|
(
|
||||||
forM
|
forM
|
||||||
, forM_
|
, forM_
|
||||||
|
, when
|
||||||
)
|
)
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
(
|
(
|
||||||
liftIO
|
liftIO
|
||||||
)
|
)
|
||||||
|
import Data.Maybe
|
||||||
|
(
|
||||||
|
fromJust
|
||||||
|
)
|
||||||
import GHC.IO.Exception
|
import GHC.IO.Exception
|
||||||
(
|
(
|
||||||
IOErrorType(..)
|
IOErrorType(..)
|
||||||
@ -101,10 +106,20 @@ _doFileOperation (f:fs) to mcOverwrite mc rest = do
|
|||||||
|
|
||||||
|
|
||||||
-- |Helper that is invoked for any directory change operations.
|
-- |Helper that is invoked for any directory change operations.
|
||||||
goDir :: MyGUI -> MyView -> Item -> IO ()
|
goDir :: Bool -- ^ whether to update the history
|
||||||
goDir mygui myview item = do
|
-> MyGUI
|
||||||
|
-> MyView
|
||||||
|
-> Item
|
||||||
|
-> IO ()
|
||||||
|
goDir bhis mygui myview item = do
|
||||||
cdir <- getCurrentDir myview
|
cdir <- getCurrentDir myview
|
||||||
modifyTVarIO (history myview)
|
when bhis $ modifyTVarIO (history myview)
|
||||||
(\(p, _) -> (path cdir `addHistory` p, []))
|
(\(p, _) -> (path cdir `addHistory` p, []))
|
||||||
refreshView' mygui myview item
|
refreshView' mygui myview item
|
||||||
|
|
||||||
|
-- set notebook tab label
|
||||||
|
page <- notebookGetCurrentPage (notebook mygui)
|
||||||
|
child <- fromJust <$> notebookGetNthPage (notebook mygui) page
|
||||||
|
notebookSetTabLabelText (notebook mygui) child
|
||||||
|
(maybe (P.fromAbs $ path item) P.fromRel $ P.basename . path $ item)
|
||||||
|
|
||||||
|
@ -345,12 +345,6 @@ refreshView' mygui myview item@Dir{} = do
|
|||||||
|
|
||||||
constructView mygui myview
|
constructView mygui myview
|
||||||
|
|
||||||
-- set notebook tab label
|
|
||||||
page <- notebookGetCurrentPage (notebook mygui)
|
|
||||||
child <- fromJust <$> notebookGetNthPage (notebook mygui) page
|
|
||||||
notebookSetTabLabelText (notebook mygui) child
|
|
||||||
(maybe (P.fromAbs $ path item) P.fromRel $ P.basename . path $ item)
|
|
||||||
|
|
||||||
-- reselect selected items
|
-- reselect selected items
|
||||||
-- TODO: not implemented for icon view yet
|
-- TODO: not implemented for icon view yet
|
||||||
case view' of
|
case view' of
|
||||||
|
Loading…
Reference in New Issue
Block a user