Skip to content

Instantly share code, notes, and snippets.

@saidie
Created August 24, 2013 08:33
Show Gist options
  • Save saidie/6326917 to your computer and use it in GitHub Desktop.
Save saidie/6326917 to your computer and use it in GitHub Desktop.
Haskell code which shows GTK default theme icons.
module Main
( main
) where
import Control.Monad (filterM)
import Data.Maybe (fromJust)
import Graphics.UI.Gtk
import qualified Graphics.UI.Gtk.ModelView
withScroll comp = do
scr <- scrolledWindowNew Nothing Nothing
containerAdd scr comp
return scr
mkGUI win = do
ids <- stockListIds
theme <- iconThemeGetDefault
pbs <- fmap (map fromJust) $ filterM (iconThemeHasIcon theme) ids >>=
mapM (\id -> iconThemeLoadIcon theme id thumbSize IconLookupUseBuiltin)
store <- listStoreNew $ zip ids pbs
customStoreSetColumn store colText fst
customStoreSetColumn store colPb snd
entrylist <- iconViewNewWithModel store
iconViewSetItemWidth entrylist $ ceiling $ fromIntegral thumbSize * 2
iconViewSetSelectionMode entrylist SelectionMultiple
iconViewSetSpacing entrylist 0
set entrylist [ iconViewTextColumn := colText
, iconViewPixbufColumn := colPb
]
containerAdd win =<< withScroll entrylist
where
thumbSize = 32
colText = makeColumnIdString 0
colPb = makeColumnIdPixbuf 1
main = do
initGUI
win <- windowNew
win `onDestroy` mainQuit
widgetSetSizeRequest win 800 600
mkGUI win
widgetShowAll win
mainGUI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment