diff --git a/hsfm.cabal b/hsfm.cabal index ccdc4b4..04c312f 100644 --- a/hsfm.cabal +++ b/hsfm.cabal @@ -34,7 +34,6 @@ library build-depends: base >= 4.8 && < 5, bytestring, - data-default, filepath >= 1.3.0.0, hinotify-bytestring, hpath >= 0.8.0, @@ -73,7 +72,6 @@ executable hsfm-gtk Cabal >= 1.22.0.0, base >= 4.8 && < 5, bytestring, - data-default, filepath >= 1.3.0.0, glib >= 0.13, gtk3 >= 0.14.1, diff --git a/src/HSFM/FileSystem/FileType.hs b/src/HSFM/FileSystem/FileType.hs index fe5d223..a3e9034 100644 --- a/src/HSFM/FileSystem/FileType.hs +++ b/src/HSFM/FileSystem/FileType.hs @@ -42,7 +42,6 @@ import Data.ByteString.UTF8 ( toString ) -import Data.Default import Data.Time.Clock.POSIX ( POSIXTime @@ -57,7 +56,6 @@ import HPath import qualified HPath as P import HPath.IO hiding (FileType(..)) import HPath.IO.Errors -import HSFM.Utils.MyPrelude import Prelude hiding(readFile) import System.Posix.FilePath ( @@ -437,8 +435,6 @@ isSocketC _ = False - - -- |Gets all file information. getFileInfo :: Path Abs -> IO FileInfo getFileInfo fp = do @@ -483,13 +479,13 @@ isBrokenSymlink _ = False -- |Pack the modification time into a string. packModTime :: File FileInfo -> String -packModTime = fromFreeVar $ epochToString . modificationTime +packModTime = epochToString . modificationTime . fvar -- |Pack the modification time into a string. packAccessTime :: File FileInfo -> String -packAccessTime = fromFreeVar $ epochToString . accessTime +packAccessTime = epochToString . accessTime . fvar epochToString :: EpochTime -> String @@ -499,12 +495,12 @@ epochToString = show . posixSecondsToUTCTime . realToFrac -- |Pack the permissions into a string, similar to what "ls -l" does. packPermissions :: File FileInfo -> String -packPermissions dt = fromFreeVar (pStr . fileMode) dt +packPermissions file = (pStr . fileMode) . fvar $ file where pStr :: FileMode -> String pStr ffm = typeModeStr ++ ownerModeStr ++ groupModeStr ++ otherModeStr where - typeModeStr = case dt of + typeModeStr = case file of Dir {} -> "d" RegFile {} -> "-" SymLink {} -> "l" @@ -549,23 +545,6 @@ packLinkDestination file = case file of ---- OTHER: ---- --- |Apply a function on the free variable. If there is no free variable --- for the given constructor the value from the `Default` class is used. -fromFreeVar :: (Default d) => (a -> d) -> File a -> d -fromFreeVar f df = maybeD f $ getFreeVar df - - getFPasStr :: File a -> String getFPasStr = toString . P.fromAbs . path - --- |Gets the free variable. Returns Nothing if the constructor is of `Failed`. -getFreeVar :: File a -> Maybe a -getFreeVar (Dir _ d) = Just d -getFreeVar (RegFile _ d) = Just d -getFreeVar (SymLink _ d _ _) = Just d -getFreeVar (BlockDev _ d) = Just d -getFreeVar (CharDev _ d) = Just d -getFreeVar (NamedPipe _ d) = Just d -getFreeVar (Socket _ d) = Just d - diff --git a/src/HSFM/GUI/Gtk/Dialogs.hs b/src/HSFM/GUI/Gtk/Dialogs.hs index d61e9c3..f07706b 100644 --- a/src/HSFM/GUI/Gtk/Dialogs.hs +++ b/src/HSFM/GUI/Gtk/Dialogs.hs @@ -275,7 +275,7 @@ showFilePropertyDialog [item] mygui _ = do entrySetText (fpropFnEntry fprop') (maybe BS.empty P.fromRel $ P.basename . path $ item) entrySetText (fpropLocEntry fprop') (P.fromAbs . P.dirname . path $ item) - entrySetText (fpropTsEntry fprop') (fromFreeVar (show . fileSize) item) + entrySetText (fpropTsEntry fprop') (show . fileSize $ fvar item) entrySetText (fpropModEntry fprop') (packModTime item) entrySetText (fpropAcEntry fprop') (packAccessTime item) entrySetText (fpropFTEntry fprop') (packFileType item) diff --git a/src/HSFM/GUI/Gtk/MyView.hs b/src/HSFM/GUI/Gtk/MyView.hs index 2e1b139..ddd4c9e 100644 --- a/src/HSFM/GUI/Gtk/MyView.hs +++ b/src/HSFM/GUI/Gtk/MyView.hs @@ -63,7 +63,6 @@ import HSFM.FileSystem.FileType import HSFM.GUI.Glib.GlibString() import HSFM.GUI.Gtk.Data import HSFM.GUI.Gtk.Icons -import HSFM.GUI.Gtk.Plugins import HSFM.GUI.Gtk.Utils import HSFM.History import HSFM.Utils.IO @@ -160,36 +159,7 @@ createMyView mygui iofmv = do urlBar <- builderGetObject builder castToEntry "urlBar" - rcMenu <- builderGetObject builder castToMenu - "rcMenu" - rcFileOpen <- builderGetObject builder castToImageMenuItem - "rcFileOpen" - rcFileExecute <- builderGetObject builder castToImageMenuItem - "rcFileExecute" - rcFileNewRegFile <- builderGetObject builder castToImageMenuItem - "rcFileNewRegFile" - rcFileNewDir <- builderGetObject builder castToImageMenuItem - "rcFileNewDir" - rcFileNewTab <- builderGetObject builder castToImageMenuItem - "rcFileNewTab" - rcFileNewTerm <- builderGetObject builder castToImageMenuItem - "rcFileNewTerm" - rcFileCut <- builderGetObject builder castToImageMenuItem - "rcFileCut" - rcFileCopy <- builderGetObject builder castToImageMenuItem - "rcFileCopy" - rcFileRename <- builderGetObject builder castToImageMenuItem - "rcFileRename" - rcFilePaste <- builderGetObject builder castToImageMenuItem - "rcFilePaste" - rcFileDelete <- builderGetObject builder castToImageMenuItem - "rcFileDelete" - rcFileProperty <- builderGetObject builder castToImageMenuItem - "rcFileProperty" - rcFileIconView <- builderGetObject builder castToImageMenuItem - "rcFileIconView" - rcFileTreeView <- builderGetObject builder castToImageMenuItem - "rcFileTreeView" + backViewB <- builderGetObject builder castToButton "backViewB" upViewB <- builderGetObject builder castToButton @@ -205,7 +175,6 @@ createMyView mygui iofmv = do viewBox <- builderGetObject builder castToBox "viewBox" - let rcmenu = MkRightClickMenu {..} let myview = MkMyView {..} -- set the bindings diff --git a/src/HSFM/Utils/MyPrelude.hs b/src/HSFM/Utils/MyPrelude.hs index 367467f..5f5dd91 100644 --- a/src/HSFM/Utils/MyPrelude.hs +++ b/src/HSFM/Utils/MyPrelude.hs @@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module HSFM.Utils.MyPrelude where -import Data.Default import Data.List @@ -31,6 +30,3 @@ listIndices :: [a] -> [Int] listIndices = findIndices (const True) --- |A `maybe` flavor using the `Default` class. -maybeD :: (Default b) => (a -> b) -> Maybe a -> b -maybeD = maybe def