From 83a767968b39ccbb44bbd1135cf798b5fe14ff06 Mon Sep 17 00:00:00 2001 From: Marko Andjelic Date: Tue, 27 Jan 2026 21:38:28 +0000 Subject: [PATCH] refactor:remove gui.hs --- app/Gui.hs | 66 ---------------------------------------------------- svitak.cabal | 7 ------ 2 files changed, 73 deletions(-) delete mode 100644 app/Gui.hs diff --git a/app/Gui.hs b/app/Gui.hs deleted file mode 100644 index ed91ce1..0000000 --- a/app/Gui.hs +++ /dev/null @@ -1,66 +0,0 @@ -{-# LANGUAGE OverloadedStrings, OverloadedLabels #-} - -module Gui (runReader) where - -import qualified GI.Gtk as Gtk -import qualified GI.Gio as Gio -import qualified GI.Gdk as Gdk -import qualified GI.WebKit as WebKit - -import Data.IORef (newIORef, readIORef, writeIORef) -import Control.Monad.Reader (runReaderT) -import Text.HTML.TagSoup (renderTags) - -import EpubParser (EpubEnv, resolveSpine, getChapter) - -runReader :: EpubEnv -> IO () -runReader env = do - app <- Gtk.applicationNew (Just "com.svitak.reader") [] - - _ <- Gtk.on app #activate $ do - window <- Gtk.applicationWindowNew app - Gtk.windowSetTitle window (Just "Svitak") - Gtk.windowSetDefaultSize window 800 600 - - -- Web View - webView <- WebKit.webViewNew - Gtk.windowSetChild window (Just webView) - - -- Book Data - spine <- runReaderT resolveSpine env - currentChapterIndex <- newIORef 0 - - let loadChapter index = do - let maxIdx = length spine - 1 - -- index to valid range - let safeIdx = max 0 (min index maxIdx) - - -- Update state - writeIORef currentChapterIndex safeIdx - - let filename = spine !! safeIdx - tags <- runReaderT (getChapter filename) env - - WebKit.webViewLoadHtml webView (renderTags tags) (Just "file:///") - - loadChapter 0 - - -- Keyboard Input - keyController <- Gtk.eventControllerKeyNew - Gtk.widgetAddController window keyController - - _ <- Gtk.on keyController #keyPressed $ \keyval _ _ -> do - currentIndex <- readIORef currentChapterIndex - case keyval of - Gdk.KEY_Right -> do - loadChapter (currentIndex + 1) - return True - Gdk.KEY_Left -> do - loadChapter (currentIndex - 1) - return True - _ -> return False - - #present window - - _ <- Gio.applicationRun app Nothing - pure () diff --git a/svitak.cabal b/svitak.cabal index 8edb8b2..1e255ca 100644 --- a/svitak.cabal +++ b/svitak.cabal @@ -44,12 +44,6 @@ maintainer: oijrewgoijreg@eaoigjoirejg.com -- copyright: build-type: Simple --- Extra doc files to be distributed with the package, such as a CHANGELOG or a README. -extra-doc-files: CHANGELOG.md - --- Extra source files to be distributed with the package, such as examples, or a tutorial module. --- extra-source-files: - common warnings ghc-options: -Wall @@ -58,7 +52,6 @@ executable svitak main-is: Main.hs other-modules: EpubParser, - Gui, UI, Persistence