LIB/GTK: cleanup

This commit is contained in:
Julian Ospald 2016-06-12 23:40:55 +02:00
parent 369278e734
commit df0b5e3e16
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
5 changed files with 6 additions and 64 deletions

View File

@ -34,7 +34,6 @@ library
build-depends: build-depends:
base >= 4.8 && < 5, base >= 4.8 && < 5,
bytestring, bytestring,
data-default,
filepath >= 1.3.0.0, filepath >= 1.3.0.0,
hinotify-bytestring, hinotify-bytestring,
hpath >= 0.8.0, hpath >= 0.8.0,
@ -73,7 +72,6 @@ executable hsfm-gtk
Cabal >= 1.22.0.0, Cabal >= 1.22.0.0,
base >= 4.8 && < 5, base >= 4.8 && < 5,
bytestring, bytestring,
data-default,
filepath >= 1.3.0.0, filepath >= 1.3.0.0,
glib >= 0.13, glib >= 0.13,
gtk3 >= 0.14.1, gtk3 >= 0.14.1,

View File

@ -42,7 +42,6 @@ import Data.ByteString.UTF8
( (
toString toString
) )
import Data.Default
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX
( (
POSIXTime POSIXTime
@ -57,7 +56,6 @@ import HPath
import qualified HPath as P import qualified HPath as P
import HPath.IO hiding (FileType(..)) import HPath.IO hiding (FileType(..))
import HPath.IO.Errors import HPath.IO.Errors
import HSFM.Utils.MyPrelude
import Prelude hiding(readFile) import Prelude hiding(readFile)
import System.Posix.FilePath import System.Posix.FilePath
( (
@ -437,8 +435,6 @@ isSocketC _ = False
-- |Gets all file information. -- |Gets all file information.
getFileInfo :: Path Abs -> IO FileInfo getFileInfo :: Path Abs -> IO FileInfo
getFileInfo fp = do getFileInfo fp = do
@ -483,13 +479,13 @@ isBrokenSymlink _ = False
-- |Pack the modification time into a string. -- |Pack the modification time into a string.
packModTime :: File FileInfo packModTime :: File FileInfo
-> String -> String
packModTime = fromFreeVar $ epochToString . modificationTime packModTime = epochToString . modificationTime . fvar
-- |Pack the modification time into a string. -- |Pack the modification time into a string.
packAccessTime :: File FileInfo packAccessTime :: File FileInfo
-> String -> String
packAccessTime = fromFreeVar $ epochToString . accessTime packAccessTime = epochToString . accessTime . fvar
epochToString :: EpochTime -> String epochToString :: EpochTime -> String
@ -499,12 +495,12 @@ epochToString = show . posixSecondsToUTCTime . realToFrac
-- |Pack the permissions into a string, similar to what "ls -l" does. -- |Pack the permissions into a string, similar to what "ls -l" does.
packPermissions :: File FileInfo packPermissions :: File FileInfo
-> String -> String
packPermissions dt = fromFreeVar (pStr . fileMode) dt packPermissions file = (pStr . fileMode) . fvar $ file
where where
pStr :: FileMode -> String pStr :: FileMode -> String
pStr ffm = typeModeStr ++ ownerModeStr ++ groupModeStr ++ otherModeStr pStr ffm = typeModeStr ++ ownerModeStr ++ groupModeStr ++ otherModeStr
where where
typeModeStr = case dt of typeModeStr = case file of
Dir {} -> "d" Dir {} -> "d"
RegFile {} -> "-" RegFile {} -> "-"
SymLink {} -> "l" SymLink {} -> "l"
@ -549,23 +545,6 @@ packLinkDestination file = case file of
---- OTHER: ---- ---- 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 :: File a -> String
getFPasStr = toString . P.fromAbs . path 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

View File

@ -275,7 +275,7 @@ showFilePropertyDialog [item] mygui _ = do
entrySetText (fpropFnEntry fprop') (maybe BS.empty P.fromRel entrySetText (fpropFnEntry fprop') (maybe BS.empty P.fromRel
$ P.basename . path $ item) $ P.basename . path $ item)
entrySetText (fpropLocEntry fprop') (P.fromAbs . P.dirname . 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 (fpropModEntry fprop') (packModTime item)
entrySetText (fpropAcEntry fprop') (packAccessTime item) entrySetText (fpropAcEntry fprop') (packAccessTime item)
entrySetText (fpropFTEntry fprop') (packFileType item) entrySetText (fpropFTEntry fprop') (packFileType item)

View File

@ -63,7 +63,6 @@ import HSFM.FileSystem.FileType
import HSFM.GUI.Glib.GlibString() import HSFM.GUI.Glib.GlibString()
import HSFM.GUI.Gtk.Data import HSFM.GUI.Gtk.Data
import HSFM.GUI.Gtk.Icons import HSFM.GUI.Gtk.Icons
import HSFM.GUI.Gtk.Plugins
import HSFM.GUI.Gtk.Utils import HSFM.GUI.Gtk.Utils
import HSFM.History import HSFM.History
import HSFM.Utils.IO import HSFM.Utils.IO
@ -160,36 +159,7 @@ createMyView mygui iofmv = do
urlBar <- builderGetObject builder castToEntry urlBar <- builderGetObject builder castToEntry
"urlBar" "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 <- builderGetObject builder castToButton
"backViewB" "backViewB"
upViewB <- builderGetObject builder castToButton upViewB <- builderGetObject builder castToButton
@ -205,7 +175,6 @@ createMyView mygui iofmv = do
viewBox <- builderGetObject builder castToBox viewBox <- builderGetObject builder castToBox
"viewBox" "viewBox"
let rcmenu = MkRightClickMenu {..}
let myview = MkMyView {..} let myview = MkMyView {..}
-- set the bindings -- set the bindings

View File

@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module HSFM.Utils.MyPrelude where module HSFM.Utils.MyPrelude where
import Data.Default
import Data.List import Data.List
@ -31,6 +30,3 @@ listIndices :: [a] -> [Int]
listIndices = findIndices (const True) listIndices = findIndices (const True)
-- |A `maybe` flavor using the `Default` class.
maybeD :: (Default b) => (a -> b) -> Maybe a -> b
maybeD = maybe def