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

Commit f1e20675588a461c5e3e47e034ad9538dd7c0b1e
Parent: b5940c105739a785a7814e03c767ed9cce2e8cb0
Author: mcol <mcol@posteo.net>
Date: 2021-08-22 13:29:20 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-08-22 13:29:20 +0100

Show folder icon if path is a folder

src/Icons.hs Modified

@@ -57,21 +57,25 @@
         (Just icon') -> Gtk.listStoreSet listStore iter [0, 1] [value, icon']
 
 getIcon :: Gtk.IconTheme -> Item -> MaybeT IO GValue
-getIcon iconTheme item = do
-    contentType <- Gio.contentTypeGuess (Just . pack $ itemPath item) Nothing
-    iconName <- MaybeT $ Gio.contentTypeGetGenericIconName . fst $ contentType
-    pixbuf <- Gtk.iconThemeLoadIcon iconTheme iconName 32 []
-    liftIO . Gtk.toGValue $ pixbuf
+getIcon iconTheme item =
+    if (itemIsDir item)
+        then
+            Gtk.iconThemeLoadIcon iconTheme "folder" 32 [] >>= liftIO . Gtk.toGValue
+        else do
+            contentType <- Gio.contentTypeGuess (Just . pack $ itemPath item) Nothing
+            iconName <- MaybeT $ Gio.contentTypeGetGenericIconName . fst $ contentType
+            pixbuf <- Gtk.iconThemeLoadIcon iconTheme iconName 32 []
+            liftIO . Gtk.toGValue $ pixbuf
 
 data Item = Item
     { itemPath :: FilePath
     , itemIsDir :: Bool
-    } deriving Show
+    }
 
 getItems :: FilePath -> IO [Item]
 getItems root = do
     path <- listDirectory root
-    isDir <- sequence $ doesDirectoryExist . (<>) root <$> path
+    isDir <- sequence $ doesDirectoryExist . ((<>) $ root <> "/") <$> path
     return . getZipList $ Item <$> ZipList path <*> ZipList isDir
 
 onItemActivated :: Gtk.ListStore -> FilePath -> Gtk.TreePath -> IO ()