Virtual desktop underlay for Wayland and X11
git clone https://github.com/m-col/xanadu
Files | Refs | Readme | License

Commit b63f12726d93ee6f1a74c301ef67249719f0510c
Parent: 3ece7cc647600da5a19df05e8069f94fc054f691
Author: mcol <mcol@posteo.net>
Date: 2021-08-19 13:50:15 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-08-19 20:18:37 +0100

Set second column of listview to gdk pixbufs

xanadu.cabal Modified

@@ -19,6 +19,7 @@
   default-language:    Haskell2010
   build-depends:       base >= 4.7 && < 5
                      , directory
+                     , gi-gdkpixbuf
                      , gi-gio
                      , gi-gtk
                      , haskell-gi-base

src/Main.hs Modified

@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings, OverloadedLabels #-}
+{-# LANGUAGE OverloadedStrings, OverloadedLabels, TypeApplications #-}
 
 module Main where
 
@@ -10,6 +10,7 @@
 
 import Data.GI.Base
 import qualified Data.GI.Base.GType as GType
+import qualified GI.GdkPixbuf as Pixbuf
 import qualified GI.Gio as Gio
 import qualified GI.Gtk as Gtk
 
@@ -29,7 +30,8 @@
         [ #application := app
         , #title := "xanadu"
         ]
-    listStore <- Gtk.listStoreNew [GType.gtypeString]
+    pixbufGType <- glibType @Pixbuf.Pixbuf
+    listStore <- Gtk.listStoreNew [GType.gtypeString, pixbufGType]
     view <- new Gtk.IconView
         [ #model := listStore
         , #selectionMode := Gtk.SelectionModeMultiple
@@ -48,8 +50,10 @@
 addItem :: Gtk.ListStore -> FilePath -> IO ()
 addItem listStore path = do
     value <- Gtk.toGValue $ Just path
+    pixbuf <- Pixbuf.pixbufNewFromFile "/usr/share/icons/Adwaita/32x32/mimetypes/image-x-generic.png"
+    icon <- Gtk.toGValue pixbuf
     iter <- Gtk.listStoreAppend listStore
-    Gtk.listStoreSet listStore iter [0] [value]
+    Gtk.listStoreSet listStore iter [0, 1] [value, icon]
 
 ls :: FilePath -> IO [FilePath]
 ls = fmap (filter (\f -> f /= "." && f /= "..")) . getDirectoryContents