Our first steps are going to involve initializing the GUI for our
program. For reasons that we’ll explain later in this chapter in Using Cabal, we’re going to have a small file called
PodLocalMain.hs that loads
PodMain and passes to it the path to podresources.glade, which is the XML file
saved by Glade that gives the information about our GUI widgets:
-- file: ch23/PodLocalMain.hs module Main where import qualified PodMainGUI main = PodMainGUI.main "podresources.glade"
Now, let’s consider PodMainGUI.hs. This file is the only Haskell source file that we had to modify from the example in Chapter 22 to make it work as a GUI. Let’s begin by looking at the start of our new PodMainGUI.hs file—we’ve renamed it from PodMain.hs for clarity:
-- file: ch23/PodMainGUI.hs module PodMainGUI where import PodDownload import PodDB import PodTypes import System.Environment import Database.HDBC import Network.Socket(withSocketsDo) -- GUI libraries import Graphics.UI.Gtk hiding (disconnect) import Graphics.UI.Gtk.Glade -- Threading import Control.Concurrent
This first part of PodMainGUI.hs is similar to our non-GUI
version. We import three additional components, however. First, we have
Graphics.UI.Gtk, which provides most of the GTK+ functions we will be using.
Both this module and
provide a function named
disconnect. Since we’ll be using the HDBC
version, but not the GTK+ version,
we don’t import that function from
Graphics.UI.Gtk.Glade contains functions ...