GTK: improve file property dialog
Adds the following fields: * file type * permissions * link destination of symlink (if applicable)
This commit is contained in:
@@ -607,3 +607,21 @@ packPermissions dt = fromFreeVar (pStr . fileMode) dt
|
||||
| otherwise = "-"
|
||||
hasFM fm = ffm `PF.intersectFileModes` fm == fm
|
||||
|
||||
|
||||
packFileType :: File a -> String
|
||||
packFileType file = case file of
|
||||
Dir {} -> "Directory"
|
||||
RegFile {} -> "Regular File"
|
||||
SymLink {} -> "Symbolic Link"
|
||||
BlockDev {} -> "Block Device"
|
||||
CharDev {} -> "Char Device"
|
||||
NamedPipe {} -> "Named Pipe"
|
||||
Socket {} -> "Socket"
|
||||
_ -> "Unknown"
|
||||
|
||||
|
||||
packLinkDestination :: File a -> Maybe ByteString
|
||||
packLinkDestination file = case file of
|
||||
SymLink { rawdest = dest } -> Just dest
|
||||
_ -> Nothing
|
||||
|
||||
|
||||
@@ -106,12 +106,15 @@ data RightClickMenu = MkRightClickMenu {
|
||||
}
|
||||
|
||||
data FilePropertyGrid = MkFilePropertyGrid {
|
||||
fpropGrid :: !Grid
|
||||
, fpropFnEntry :: !Entry
|
||||
, fpropLocEntry :: !Entry
|
||||
, fpropTsEntry :: !Entry
|
||||
, fpropModEntry :: !Entry
|
||||
, fpropAcEntry :: !Entry
|
||||
fpropGrid :: !Grid
|
||||
, fpropFnEntry :: !Entry
|
||||
, fpropLocEntry :: !Entry
|
||||
, fpropTsEntry :: !Entry
|
||||
, fpropModEntry :: !Entry
|
||||
, fpropAcEntry :: !Entry
|
||||
, fpropFTEntry :: !Entry
|
||||
, fpropPermEntry :: !Entry
|
||||
, fpropLDEntry :: !Entry
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -267,6 +267,16 @@ showFilePropertyDialog [item] mygui _ = do
|
||||
entrySetText (fpropTsEntry fprop') (fromFreeVar (show . fileSize) item)
|
||||
entrySetText (fpropModEntry fprop') (packModTime item)
|
||||
entrySetText (fpropAcEntry fprop') (packAccessTime item)
|
||||
entrySetText (fpropFTEntry fprop') (packFileType item)
|
||||
entrySetText (fpropPermEntry fprop') (tail $ packPermissions item)
|
||||
case packLinkDestination item of
|
||||
(Just dest) -> do
|
||||
widgetSetSensitive (fpropLDEntry fprop') True
|
||||
entrySetText (fpropLDEntry fprop') dest
|
||||
Nothing -> do
|
||||
widgetSetSensitive (fpropLDEntry fprop') False
|
||||
entrySetText (fpropLDEntry fprop') "( Not a symlink )"
|
||||
|
||||
|
||||
cbox <- dialogGetActionArea dialog
|
||||
_ <- dialogAddButton dialog "Ok" (ResponseUser 0)
|
||||
|
||||
@@ -126,6 +126,12 @@ createMyGUI = do
|
||||
"fpropModEntry"
|
||||
fpropAcEntry <- builderGetObject builder castToEntry
|
||||
"fpropAcEntry"
|
||||
fpropFTEntry <- builderGetObject builder castToEntry
|
||||
"fpropFTEntry"
|
||||
fpropPermEntry <- builderGetObject builder castToEntry
|
||||
"fpropPermEntry"
|
||||
fpropLDEntry <- builderGetObject builder castToEntry
|
||||
"fpropLDEntry"
|
||||
|
||||
-- construct the gui object
|
||||
let menubar = MkMenuBar {..}
|
||||
|
||||
Reference in New Issue
Block a user