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

Commit d5e6de3dfdd031751f6db1d8d4cacaabb463ac85
Parent: 1050dbd759ff90f75bbdcd46613ae601317bb979
Author: mcol <mcol@posteo.net>
Date: 2021-08-21 22:31:22 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-08-21 22:31:22 +0100

Hook function to activaiton of item

src/Icons.hs Modified

@@ -24,13 +24,15 @@
     iconTheme <- Gtk.iconThemeGetForScreen =<< Gtk.windowGetScreen win
     root <- getRoot
     populate listStore iconTheme root
-    new Gtk.IconView
+    iconView <- new Gtk.IconView
         [ #model := listStore
         , #selectionMode := Gtk.SelectionModeMultiple
         , #textColumn := 0
         , #tooltipColumn := 0
         , #pixbufColumn := 1
         ]
+    on iconView #itemActivated $ onItemActivated listStore
+    return iconView
 
 -- Root folder is $(XDG_DESKTOP_DIR:-$HOME/Desktop)
 getRoot :: IO FilePath
@@ -70,3 +72,12 @@
     path <- listDirectory root
     isDir <- sequence $ doesDirectoryExist . (<>) root <$> path
     return . getZipList $ Item <$> ZipList path <*> ZipList isDir
+
+onItemActivated :: Gtk.ListStore -> Gtk.TreePath -> IO ()
+onItemActivated listStore treePath = do
+    (_, iter) <- Gtk.treeModelGetIter listStore treePath
+    gvalue <- Gtk.treeModelGetValue listStore iter 0
+    maybeValue <- (Gtk.fromGValue gvalue :: IO (Maybe String))
+    case maybeValue of
+        Nothing -> return ()
+        Just value -> putStrLn $ show value