-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An app with multiple windows #45
Comments
You're right, it's not explicitly supported right now. You can hack it in by including {-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module Windows where
import Control.Monad (void)
import qualified Data.Text as Text
import Data.Vector (Vector)
import qualified Data.Vector as Vector
import GI.Gtk (Box (..), Label (..),
Orientation (..), Window (..))
import GI.Gtk.Declarative
import GI.Gtk.Declarative.App.Simple
type State = ()
data Event = Closed
view' :: State -> AppView Window Event
view' _ =
bin Window [ #title := "Top Window"
, #widthRequest := 600
, on #deleteEvent (const (True, Closed))
]
(container Box [#orientation := OrientationVertical] windows)
where
windows :: Vector (BoxChild Event)
windows = Vector.generate 5 $ \(succ -> i) ->
let
lbl = "Window " <> Text.pack (show i)
size = 600 - fromIntegral i * 25
in
BoxChild defaultBoxChildProperties $
bin Window [ #title := lbl
, #widthRequest := size
, #heightRequest := size
, on #deleteEvent (const (True, Closed))
]
(widget Label [#label :=lbl])
update' :: State -> Event -> Transition State Event
update' _ Closed = Exit
main :: IO ()
main = void $ run App
{ view = view'
, update = update'
, inputs = []
, initialState = ()
} As you can see, "Top Window" seems to take the full height of the child windows: I can see two solutions:
I'm not sure which approach is better, but I'm leaning towards 1. Would you be interested in providing a PR? |
I'll give it a shot |
Does not seem possible right now (or am I wrong?). I wish a container for multiple windows was provided.
The text was updated successfully, but these errors were encountered: