GTK: add symlink icons
This commit is contained in:
parent
3bd201f1b6
commit
2ee0d33f44
@ -156,9 +156,11 @@ startMainWindow startdir = do
|
|||||||
|
|
||||||
-- get the icons
|
-- get the icons
|
||||||
iT <- iconThemeGetDefault
|
iT <- iconThemeGetDefault
|
||||||
folderPix <- getIcon IFolder 24
|
folderPix <- getIcon IFolder iT 24
|
||||||
filePix <- getIcon IFile 24
|
folderSymPix <- getSymlinkIcon IFolder iT 24
|
||||||
errorPix <- getIcon IError 24
|
filePix <- getIcon IFile iT 24
|
||||||
|
fileSymPix <- getSymlinkIcon IFile iT 24
|
||||||
|
errorPix <- getIcon IError iT 24
|
||||||
|
|
||||||
operationBuffer <- newTVarIO None
|
operationBuffer <- newTVarIO None
|
||||||
|
|
||||||
|
@ -82,7 +82,9 @@ data MyGUI = MkMyGUI {
|
|||||||
, renderPix :: CellRendererPixbuf
|
, renderPix :: CellRendererPixbuf
|
||||||
, settings :: TVar FMSettings
|
, settings :: TVar FMSettings
|
||||||
, folderPix :: Pixbuf
|
, folderPix :: Pixbuf
|
||||||
|
, folderSymPix :: Pixbuf
|
||||||
, filePix :: Pixbuf
|
, filePix :: Pixbuf
|
||||||
|
, fileSymPix :: Pixbuf
|
||||||
, errorPix :: Pixbuf
|
, errorPix :: Pixbuf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import Graphics.UI.Gtk.Gdk.Pixbuf
|
|||||||
|
|
||||||
-- |Icon type we use in our GUI.
|
-- |Icon type we use in our GUI.
|
||||||
data GtkIcon = IFolder
|
data GtkIcon = IFolder
|
||||||
|
| SymL
|
||||||
| IFile
|
| IFile
|
||||||
| IError
|
| IError
|
||||||
|
|
||||||
@ -35,12 +36,12 @@ data GtkIcon = IFolder
|
|||||||
-- |Gets an icon from the default icon theme and falls back to project-icons
|
-- |Gets an icon from the default icon theme and falls back to project-icons
|
||||||
-- if not found. The requested icon size is not guaranteed.
|
-- if not found. The requested icon size is not guaranteed.
|
||||||
getIcon :: GtkIcon -- ^ icon we want
|
getIcon :: GtkIcon -- ^ icon we want
|
||||||
|
-> IconTheme -- ^ which icon theme to get the icon from
|
||||||
-> Int -- ^ requested icon size
|
-> Int -- ^ requested icon size
|
||||||
-> IO Pixbuf
|
-> IO Pixbuf
|
||||||
getIcon icon isize = do
|
getIcon icon itheme isize = do
|
||||||
let iname = iconToStr icon
|
let iname = iconToStr icon
|
||||||
iT <- iconThemeGetDefault
|
mpix <- iconThemeLoadIcon itheme iname isize IconLookupUseBuiltin
|
||||||
mpix <- iconThemeLoadIcon iT iname isize IconLookupUseBuiltin
|
|
||||||
case mpix of
|
case mpix of
|
||||||
Just pix -> return pix
|
Just pix -> return pix
|
||||||
Nothing -> pixbufNewFromFile ("data/Gtk/icons/" ++ iname)
|
Nothing -> pixbufNewFromFile ("data/Gtk/icons/" ++ iname)
|
||||||
@ -48,3 +49,14 @@ getIcon icon isize = do
|
|||||||
iconToStr IFolder = "gtk-directory"
|
iconToStr IFolder = "gtk-directory"
|
||||||
iconToStr IFile = "gtk-file"
|
iconToStr IFile = "gtk-file"
|
||||||
iconToStr IError = "error"
|
iconToStr IError = "error"
|
||||||
|
iconToStr SymL = "emblem-symbolic-link"
|
||||||
|
|
||||||
|
|
||||||
|
getSymlinkIcon :: GtkIcon -> IconTheme -> Int -> IO Pixbuf
|
||||||
|
getSymlinkIcon icon itheme isize = do
|
||||||
|
pix <- pixbufCopy =<< getIcon icon itheme isize
|
||||||
|
sympix <- getIcon SymL itheme isize
|
||||||
|
|
||||||
|
pixbufScale sympix pix 0 0 12 12 0 0 0.5 0.5 InterpNearest
|
||||||
|
|
||||||
|
return pix
|
||||||
|
@ -278,6 +278,8 @@ constructTreeView mygui myview = do
|
|||||||
where
|
where
|
||||||
dirtreePix (Dir {}) = folderPix mygui
|
dirtreePix (Dir {}) = folderPix mygui
|
||||||
dirtreePix (RegFile {}) = filePix mygui
|
dirtreePix (RegFile {}) = filePix mygui
|
||||||
|
dirtreePix (SDir _) = folderSymPix mygui
|
||||||
|
dirtreePix (SRegFile {}) = fileSymPix mygui
|
||||||
dirtreePix (Failed {}) = errorPix mygui
|
dirtreePix (Failed {}) = errorPix mygui
|
||||||
dirtreePix _ = errorPix mygui
|
dirtreePix _ = errorPix mygui
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user