From 876b51e784f4d86fd538f45680314517bd139678 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Sat, 21 Jun 2025 09:42:22 +0200 Subject: use updated gi-gtk --- app/Main.hs | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs index 25ad7d4..4f7e757 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,42 +1,15 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE OverloadedLabels #-} -{-# LANGUAGE OverloadedRecordDot #-} -{-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE OverloadedStrings, OverloadedRecordDot #-} import Control.Monad (void) import Control.Exception (bracket_) -import Data.Maybe (fromJust) -import Data.GI.Base +import System.Environment (getArgs) +import Foobar.Application (mkApplication) -import qualified GI.Gtk as Gtk -import qualified GI.Gdk as Gdk -import qualified GI.Gio as Gio import qualified GI.Foobar as FB -activate :: Gtk.Application -> IO () -activate app = do - provider <- new Gtk.CssProvider [] - provider.loadFromResource "/foobar/styles/default.css" - disp <- Gdk.displayGetDefault - Gtk.styleContextAddProviderForDisplay (fromJust disp) - provider - (fromIntegral Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) - button <- new Gtk.Button [ #label := "Hello, world!" ] - window <- new Gtk.ApplicationWindow [ #application := app - , #title := "Test" - , #child := button ] - _ <- FB.serverProxyNewForBusSync Gio.BusTypeSession - [] - "com.github.hannesschulze.foobar" - "/com/github/hannesschulze/foobar/server" - (Nothing :: Maybe Gio.Cancellable) - window.show - main :: IO () -main = do - bracket_ - (do FB.stylesRegisterResource; FB.iconsRegisterResource) - (do FB.stylesUnregisterResource; FB.iconsUnregisterResource) $ - do app <- new Gtk.Application [ #applicationId := "com.github.hannesschulze.foobar-hs" - , On #activate (activate ?self) ] - void $ app.run Nothing +main = bracket_ FB.stylesRegisterResource FB.stylesUnregisterResource $ + bracket_ FB.iconsRegisterResource FB.iconsUnregisterResource $ + do args <- getArgs + app <- mkApplication + void $ app.run (Just ("com.github.hannesschulze.foobar" : args)) -- cgit v1.3.1