From 519956797d905c0925b8dd418ceb17c7495ad30a Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Fri, 20 Jun 2025 16:27:42 +0200 Subject: set up haskell bindings for c lib --- app/Main.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/Main.hs (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..609b53d --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE ImplicitParams #-} + +import Control.Monad (void) +import Data.GI.Base +import qualified GI.Gtk as Gtk +import qualified GI.Gio as Gio +import qualified GI.Foobar as FB + +activate :: Gtk.Application -> IO () +activate app = do + 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 + app <- new Gtk.Application [ #applicationId := "com.github.hannesschulze.foobar-hs" + , On #activate (activate ?self) ] + void $ app.run Nothing -- cgit v1.3.1