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:
Julian Ospald 2016-06-01 22:00:37 +02:00
parent 7fef11ecd2
commit 01c241a01e
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
3 changed files with 24 additions and 15 deletions

View File

@ -458,7 +458,7 @@ urlGoTo mygui myview = withErrorDialog $ do
fp <- entryGetText (urlBar myview)
forM_ (P.parseAbs fp :: Maybe (Path Abs)) $ \fp' ->
whenM (canOpenDirectory fp')
(goDir mygui myview =<< (readFile getFileInfo $ fp'))
(goDir True mygui myview =<< (readFile getFileInfo $ fp'))
goHome :: MyGUI -> MyView -> IO ()
@ -466,7 +466,7 @@ goHome mygui myview = withErrorDialog $ do
mhomedir <- getEnv "HOME"
forM_ (P.parseAbs =<< mhomedir :: Maybe (Path Abs)) $ \fp' ->
whenM (canOpenDirectory fp')
(goDir mygui myview =<< (readFile getFileInfo $ fp'))
(goDir True mygui myview =<< (readFile getFileInfo $ fp'))
-- |Execute a given file.
@ -484,7 +484,7 @@ open [item] mygui myview = withErrorDialog $
case item of
DirOrSym r -> do
nv <- readFile getFileInfo $ path r
goDir mygui myview nv
goDir True mygui myview nv
r ->
void $ openFile . path $ r
-- this throws on the first error that occurs
@ -500,7 +500,7 @@ upDir :: MyGUI -> MyView -> IO ()
upDir mygui myview = withErrorDialog $ do
cdir <- getCurrentDir myview
nv <- goUp cdir
goDir mygui myview nv
goDir True mygui myview nv
-- |Go "back" in the history.
@ -514,7 +514,7 @@ goHistoryPrev mygui myview = do
nv <- readFile getFileInfo $ x
modifyTVarIO (history myview)
(\(_, n) -> (xs, path cdir `addHistory` n))
refreshView' mygui myview nv
goDir False mygui myview nv
-- |Go "forth" in the history.
@ -528,5 +528,5 @@ goHistoryNext mygui myview = do
nv <- readFile getFileInfo $ x
modifyTVarIO (history myview)
(\(p, _) -> (path cdir `addHistory` p, xs))
refreshView' mygui myview nv
goDir False mygui myview nv

View File

@ -28,11 +28,16 @@ import Control.Monad
(
forM
, forM_
, when
)
import Control.Monad.IO.Class
(
liftIO
)
import Data.Maybe
(
fromJust
)
import GHC.IO.Exception
(
IOErrorType(..)
@ -101,10 +106,20 @@ _doFileOperation (f:fs) to mcOverwrite mc rest = do
-- |Helper that is invoked for any directory change operations.
goDir :: MyGUI -> MyView -> Item -> IO ()
goDir mygui myview item = do
goDir :: Bool -- ^ whether to update the history
-> MyGUI
-> MyView
-> Item
-> IO ()
goDir bhis mygui myview item = do
cdir <- getCurrentDir myview
modifyTVarIO (history myview)
when bhis $ modifyTVarIO (history myview)
(\(p, _) -> (path cdir `addHistory` p, []))
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)

View File

@ -345,12 +345,6 @@ refreshView' mygui myview item@Dir{} = do
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
-- TODO: not implemented for icon view yet
case view' of