GTK: try to fix icon crap

Not sure if this is right, though.
This commit is contained in:
Julian Ospald 2016-03-30 02:47:05 +02:00
parent 74b83fe2e8
commit 09d8910eae
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
3 changed files with 13 additions and 19 deletions

View File

@ -77,11 +77,6 @@ data MyGUI = MkMyGUI {
, statusBar :: Statusbar , statusBar :: Statusbar
, clearStatusBar :: Button , clearStatusBar :: Button
, settings :: TVar FMSettings , settings :: TVar FMSettings
, folderPix :: Pixbuf
, folderSymPix :: Pixbuf
, filePix :: Pixbuf
, fileSymPix :: Pixbuf
, errorPix :: Pixbuf
, scroll :: ScrolledWindow , scroll :: ScrolledWindow
} }
@ -90,6 +85,7 @@ data MyGUI = MkMyGUI {
data FMSettings = MkFMSettings { data FMSettings = MkFMSettings {
showHidden :: Bool showHidden :: Bool
, isLazy :: Bool , isLazy :: Bool
, iconSize :: Int
} }
data FMView = FMTreeView TreeView data FMView = FMTreeView TreeView

View File

@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module GUI.Gtk.Icons where module GUI.Gtk.Icons where
import Data.Maybe
(
fromJust
)
import Graphics.UI.Gtk import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.Pixbuf import Graphics.UI.Gtk.Gdk.Pixbuf
import Paths_hsfm import Paths_hsfm
@ -45,10 +49,12 @@ getIcon :: GtkIcon -- ^ icon we want
-> IO Pixbuf -> IO Pixbuf
getIcon icon itheme isize = do getIcon icon itheme isize = do
let iname = iconToStr icon let iname = iconToStr icon
mpix <- iconThemeLoadIcon itheme iname isize IconLookupUseBuiltin hasicon <- iconThemeHasIcon itheme iname
case mpix of case hasicon of
Just pix -> return pix True -> fromJust <$> iconThemeLoadIcon itheme iname isize
Nothing -> pixbufNewFromFile =<< getDataFileName ("data/Gtk/icons/" ++ iname) IconLookupUseBuiltin
False -> pixbufNewFromFile =<< getDataFileName
("data/Gtk/icons/" ++ iname ++ ".png")
where where
iconToStr IFolder = "gtk-directory" iconToStr IFolder = "gtk-directory"
iconToStr IFile = "gtk-file" iconToStr IFile = "gtk-file"

View File

@ -27,7 +27,6 @@ import Control.Concurrent.STM
) )
import Graphics.UI.Gtk import Graphics.UI.Gtk
import GUI.Gtk.Data import GUI.Gtk.Data
import GUI.Gtk.Icons
import Paths_hsfm import Paths_hsfm
( (
getDataFileName getDataFileName
@ -45,15 +44,8 @@ import Paths_hsfm
createMyGUI :: IO MyGUI createMyGUI :: IO MyGUI
createMyGUI = do createMyGUI = do
settings <- newTVarIO (MkFMSettings False True) let settings' = MkFMSettings False True 24
settings <- newTVarIO settings'
-- get the icons
iT <- iconThemeGetDefault
folderPix <- getIcon IFolder iT 24
folderSymPix <- getSymlinkIcon IFolder iT 24
filePix <- getIcon IFile iT 24
fileSymPix <- getSymlinkIcon IFile iT 24
errorPix <- getIcon IError iT 24
builder <- builderNew builder <- builderNew
builderAddFromFile builder =<< getDataFileName "data/Gtk/builder.xml" builderAddFromFile builder =<< getDataFileName "data/Gtk/builder.xml"