diff --git a/src/HSFM/GUI/Gtk/Callbacks.hs b/src/HSFM/GUI/Gtk/Callbacks.hs index f815efd..4cecd89 100644 --- a/src/HSFM/GUI/Gtk/Callbacks.hs +++ b/src/HSFM/GUI/Gtk/Callbacks.hs @@ -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 diff --git a/src/HSFM/GUI/Gtk/Callbacks/Utils.hs b/src/HSFM/GUI/Gtk/Callbacks/Utils.hs index a974c0c..0f00758 100644 --- a/src/HSFM/GUI/Gtk/Callbacks/Utils.hs +++ b/src/HSFM/GUI/Gtk/Callbacks/Utils.hs @@ -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) + diff --git a/src/HSFM/GUI/Gtk/MyView.hs b/src/HSFM/GUI/Gtk/MyView.hs index 0c667c3..cb7d2e9 100644 --- a/src/HSFM/GUI/Gtk/MyView.hs +++ b/src/HSFM/GUI/Gtk/MyView.hs @@ -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