[More ch24 tweaks John Goerzen **20080422101125] { hunk ./en/ch23-webclient.xml 305 - your output. + your output. To install the program system-wide, run + runghc Setup.hs install. hunk ./en/ch24-gui.xml 188 - our program. For reasons that we'll explain later, - FIXME: add link we're going to have a small + our program. For reasons that we'll explain in + , we're going to have a small hunk ./en/ch24-gui.xml 462 - hunk ./en/ch24-gui.xml 463 - + + + Using Cabal + + We presented a Cabal file to build this project for the + command-line version in . We need to + make a few tweaks for it to work with our GUI version. First, + there's the obvious need to add the gtk2hs packages to the list + of build dependencies. There is also the matter of the Glade + XML file. + + + Earlier, we wrote a PodLocalMain.hs that + simply assumed this file was named + podresources.glade and stored in the current + working directory. For a real, system-wide installation, we + can't make that assumption. Moreover, different systems may + place the file at different locations. + + + Cabal provides a way around this problem. It automatically + generates a module that exports functions that can interrogate + the environment. We must add a Data-files + line to our Cabal description file. This file names all data + files that will be part of a system-wide installation. Then, + Cabal will export a Paths_pod module (the + "pod" part comes from the Name line in the + Cabal file) that we can interrogate for the location at + runtime. Here's our new Cabal description file: + + +-- ch24/pod.cabal +Name: pod +Version: 1.0.0 +Build-type: Simple +Build-Depends: HTTP, HaXml, network, HDBC, HDBC-sqlite3, base, + gtk, glade +Data-files: podresources.glade + +Executable: pod +Main-Is: PodCabalMain.hs +GHC-Options: -O2 + + + And, to go with it, PodCabalMain.hs: + + &PodCabalMain.hs:all; + + hunk ./en/ch24-gui.xml 514 - + }