Integrate parsing backend with gtk. TODO: Base64 image embedding for image compatibility

This commit is contained in:
Marko Andjelic 2026-01-26 02:00:06 +00:00
commit b666d8477f
3 changed files with 72 additions and 70 deletions

View file

@ -4,18 +4,28 @@ module Gui (runWindow) where
import qualified GI.Gtk as Gtk
import qualified GI.Gio as Gio
import qualified GI.WebKit as WebKit
import qualified Data.Text as T
runWindow :: IO ()
runWindow = do
runWindow :: String -> IO ()
runWindow htmlContent = do
app <- Gtk.applicationNew (Just "com.svitak.reader") []
app <- Gtk.applicationNew (Just "com.svitak.reader") []
_ <- Gtk.on app #activate $ do
_ <- Gtk.on app #activate $ do
window <- Gtk.applicationWindowNew app
Gtk.windowSetTitle window (Just "Svitak Reader (GTK 4)")
Gtk.windowSetDefaultSize window 800 600
#present window
window <- Gtk.applicationWindowNew app
Gtk.windowSetTitle window (Just "Svitak Reader (GTK 4)")
_ <- Gio.applicationRun app Nothing
return ()
Gtk.windowSetDefaultSize window 800 600
webView <- WebKit.webViewNew
WebKit.webViewLoadHtml webView (T.pack htmlContent) (Just "file:///")
Gtk.windowSetChild window (Just webView)
#present window
_ <- Gio.applicationRun app Nothing
pure ()