Commit 6c7c3b45fa71f88a81a76ac4f8aa674bcf13af26 Parent: Author: mcol <mcol@posteo.net> Date: 2021-08-19 11:02:08 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-08-19 11:02:08 +0100 Commit initial somewhat-working version
xanadu.cabal Added
@@ -0,0 +1,24 @@ +name: xanadu +version: 0.1.0.0 +-- synopsis: +-- description: +homepage: https://mcol.xyz/code/xanadu +license: BSD3 +license-file: LICENSE +author: Matt Colligan +maintainer: mlv@posteo.net +copyright: 2021 Matt Colligan +category: Desktop +build-type: Simple +cabal-version: >=1.10 +extra-source-files: README.rst + +executable xanadu + hs-source-dirs: src + main-is: Main.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , directory + , gi-gio + , gi-gtk + , haskell-gi-base
stack.yaml.lock Added
@@ -0,0 +1,13 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 585817 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/5.yaml + sha256: 22d24d0dacad9c1450b9a174c28d203f9bb482a2a8da9710a2f2a9f4afee2887 + original: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/5.yaml
stack.yaml Added
@@ -0,0 +1,5 @@ +resolver: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/5.yaml + +packages: +- .
src/Main.hs Added
@@ -0,0 +1,59 @@ +{-# LANGUAGE OverloadedStrings, OverloadedLabels #-} + +module Main where + +import Data.Functor (void) +import Data.Maybe +import Data.Void +import GHC.Int (Int32) +import System.Directory (getDirectoryContents) + +import Data.GI.Base +import qualified Data.GI.Base.GType as GType +import qualified GI.Gio as Gio +import qualified GI.Gtk as Gtk + +main :: IO () +main = do + app <- new Gtk.Application + [ #applicationId := "xanadu" + , #flags := [ Gio.ApplicationFlagsFlagsNone ] + ] + on app #activate $ activateApp app + Gio.applicationRun app Nothing + return () + +activateApp :: Gtk.Application -> IO () +activateApp app = do + win <- new Gtk.ApplicationWindow + [ #application := app + , #title := "xanadu" + ] + listStore <- Gtk.listStoreNew [GType.gtypeString] + view <- new Gtk.IconView + [ #model := listStore + , #textColumn := 0 + , #pixbufColumn := 1 + ] + populate listStore "/home/mcol/Desktop" + #add win view + #showAll win + return () + +populate :: Gtk.ListStore -> FilePath -> IO () +populate listStore root = do + contents <- ls root + addItems contents + return () + where + addItems :: [FilePath] -> IO [()] + addItems paths = sequence $ map (addItem listStore) paths + +addItem :: Gtk.ListStore -> FilePath -> IO () +addItem listStore path = do + value <- Gtk.toGValue $ Just path + iter <- Gtk.listStoreAppend listStore + Gtk.listStoreSet listStore iter [0] [value] + +ls :: FilePath -> IO [FilePath] +ls = fmap (filter (\f -> f /= "." && f /= "..")) . getDirectoryContents
Setup.hs Added
@@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain
README.rst Added
@@ -0,0 +1,2 @@ +xanadu +======
LICENSE Added
@@ -0,0 +1,30 @@ +Copyright Matt Colligan (c) 2021 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Matt Colligan nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.gitignore Added
@@ -0,0 +1 @@
+.stack-work