aboutsummaryrefslogtreecommitdiff
path: root/ch23/23_a_1/PodMainGUI.hs
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-09-14 17:10:23 +0200
committerJan Sucan <jan@jansucan.com>2025-09-14 21:18:59 +0200
commit9d89965b0661d1968151d9b646148b6a71209705 (patch)
tree6da0620222dabbf8dd9c038af305a174d4c68868 /ch23/23_a_1/PodMainGUI.hs
parentad4cf7db4cd61d01f1e2191d1d69edd5916d6e88 (diff)
23_a_2: Add solution
Diffstat (limited to 'ch23/23_a_1/PodMainGUI.hs')
-rw-r--r--ch23/23_a_1/PodMainGUI.hs38
1 files changed, 5 insertions, 33 deletions
diff --git a/ch23/23_a_1/PodMainGUI.hs b/ch23/23_a_1/PodMainGUI.hs
index 6c7190d..b9badf3 100644
--- a/ch23/23_a_1/PodMainGUI.hs
+++ b/ch23/23_a_1/PodMainGUI.hs
@@ -1,6 +1,7 @@
{-- snippet imports --}
-module PodMainGUI where
+module Main where
+import PodMain
import PodDownload
import PodDB
import PodTypes
@@ -39,8 +40,9 @@ data GUI = GUI {
{-- /snippet type --}
{-- snippet main --}
-main :: FilePath -> IO ()
-main gladepath = withSocketsDo $ handleSqlError $
+gladepath = "podresources.glade"
+
+main = withSocketsDo $ handleSqlError $
do initGUI -- Initialize GTK+ engine
-- Every so often, we try to run other threads.
@@ -193,33 +195,3 @@ guiFetch gui dbh =
statusWindow gui dbh "Pod: Fetch"
(\logf -> update dbh logf >> download dbh logf)
{-- /snippet statusWindowFuncs --}
-
-{-- snippet workerFuncs --}
-addUrl dbh url =
- do addPodcast dbh pc
- commit dbh
- where pc = Podcast {castId = 0, castURL = url}
-
-update :: IConnection conn => conn -> (String -> IO ()) -> IO ()
-update dbh logf =
- do pclist <- getPodcasts dbh
- mapM_ procPodcast pclist
- logf "Update complete."
- where procPodcast pc =
- do logf $ "Updating from " ++ (castURL pc)
- updatePodcastFromFeed dbh pc
-
-download dbh logf =
- do pclist <- getPodcasts dbh
- mapM_ procPodcast pclist
- logf "Download complete."
- where procPodcast pc =
- do logf $ "Considering " ++ (castURL pc)
- episodelist <- getPodcastEpisodes dbh pc
- let dleps = filter (\ep -> epDone ep == False)
- episodelist
- mapM_ procEpisode dleps
- procEpisode ep =
- do logf $ "Downloading " ++ (epURL ep)
- getEpisode dbh ep
-{-- /snippet workerFuncs --}