- let state = IS { sFrame = undefined, sPanel = undefined, buffer = undefined, usrProg = eventHandler, .. }
- run $ runGUI (sz windowWidth windowHeight) state
- putStrLn "XX"
- runGUI (sz windowWidth windowHeight) state
+ let state = IS { window = undefined, usrProg = eventHandler, .. }
+ runGUI windowWidth windowHeight state
+
+runGUI :: Int -> Int -> IState -> IO ()
+runGUI w h s = do
+ -- Init GTK.
+ Gtk.initGUI
+
+ -- Create a window, which will make the mainloop terminated when
+ -- it is closed.
+ window <- Gtk.windowNew
+
+ Gtk.set window [ Gtk.containerBorderWidth := 10
+ , Gtk.windowTitle := "FP Practicum"
+ , Gtk.windowDefaultWidth := w
+ , Gtk.windowDefaultHeight := h
+ ]
+ Gtk.onDestroy window Gtk.mainQuit
+
+ -- Add the window to the state
+ let state = s { window = window }
+
+ -- Show the window and start the Gtk mainloop.
+ Gtk.widgetShowAll window
+ Gtk.mainGUI
+