Ticket #1164: gc.hs

File gc.hs, 1.0 kB (added by guest, 6 years ago)

example program that shows the error

Line 
1{-# OPTIONS -Wall #-}
2
3{-
4works fine via gconftool:
5
6$ gconftool-2 --type list --list-type string --set "/apps/nautilus/icon_view" [size,date_modified,none]
7
8$ gconftool-2 --get "/apps/nautilus/icon_view"
9[size,date_modified,none]
10
11.. i.e we get back what we just set.
12but lists appear to be reversed in "System.Gnome.GConf.gconfSet".
13-}
14
15import System.Gnome.GConf
16import Data.Maybe
17
18main :: IO ()
19main = do
20  gc <- gconfGetDefault :: IO GConf
21  let key = "/apps/nautilus/icon_view"
22  let val = ["size", "date_modified", "none"]
23
24  putStrLn$ "setting value: "++show val
25  gconfSet gc key $
26    GConfValueList (map GConfValueString val)
27
28  v <- gconfGet gc key
29  putStrLn$ "result from reading: "++show (toStringList v)
30
31toStringList :: GConfValueDyn -> Maybe [String]
32toStringList (GConfValueList ds) =
33  let vs = map fromGConfValueString ds
34  in if any (==Nothing) vs
35       then Nothing
36       else Just $ map fromJust vs
37 where
38 fromGConfValueString (GConfValueString s) = Just s
39 fromGConfValueString _ = Nothing
40toStringList _ = Nothing