You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code below, after clicking the close button of the window, the window will not close, staying open while the program is still running. Only after pressing enter on the command prompt, unblocking the getLine function, does the window close when the process exits. For my use case I need the window to close when the "run" function returns.
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
moduleMainwhereimportData.Function ( (&) )
importData.Text ( Text )
importPipesimportqualifiedPipes.ExtrasasPipesimportControl.Monad ( void )
importGI.Gtk ( Label(..)
, Window(..)
)
importGI.Gtk.DeclarativeimportGI.Gtk.Declarative.App.SimpletypeState=()dataEvent=Closedview'::State->AppViewWindowEvent
view' _ =
bin
Window
[ #title :="Hello"
, on #deleteEvent (const (True, Closed))
, #widthRequest :=400
, #heightRequest :=300
]
$ widget Label [#label :="Nothing here yet."]
update'::State->Event->TransitionStateEvent
update' _ Closed=Exitmain'::IO()
main' = void $ run App { view = view'
, update = update'
, inputs =[]
, initialState =()
}
main =do
main'
getLine
In the following gi-gtk program that does not happen:
{-# LANGUAGE OverloadedStrings, OverloadedLabels #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
{- Hello World example of GTK+ documentation. For information please refer to README -}moduleMainwhere-- import qualified Data.Text as TimportData.Text ()
importqualifiedGI.GioasGioimportqualifiedGI.GtkasGtkimportData.GI.BaseimportControl.ConcurrentprintHello::IO()
printHello =putStrLn"Hello, World!"activateApp::Gtk.Application->IO()
activateApp app =do
w <- new Gtk.ApplicationWindow [ #application := app
, #title :="Haskell Gi - Examples - Hello World"
, #defaultHeight :=200
, #defaultWidth :=200
]
bbox <- new Gtk.ButtonBox [ #orientation :=Gtk.OrientationHorizontal ]
#add w bbox
btn <- new Gtk.Button [ #label :="Hello World!"]
on btn #clicked printHello
--on btn #clicked $ Gtk.widgetDestroy w#add bbox btn
#showAll w
return()main'::IO()
main' =do
app <- new Gtk.Application [ #applicationId :="haskell-gi.examples.hello-world"
, #flags := [ Gio.ApplicationFlagsFlagsNone ]
]
on app #activate $ activateApp app
Gio.applicationRun app Nothingreturn()
main =do
main'
getLine
The text was updated successfully, but these errors were encountered:
rvl
added a commit
to rvl/gi-gtk-declarative
that referenced
this issue
Sep 17, 2024
Gtk doesn't destroy its windows when `gtk_main_exit()` is called. It
relies on the X server to DestroyAll resources when the app's
connection to the X server is closed.
This can result in zombie windows for programs which don't immediately
exit after the Gtk main loop finishes.
We solve it by explicitly destroying the window widget in response to
the `Exit` transition.
Also, for gtk_widget_destroy() to have any effect, the Gtk main loop
needs to be still running. Thankfully, the `run` function provided by
`GI.Gtk.Declarative.App.Simple` will ensure that is the case.
Resolvesowickstrom#105
rvl
linked a pull request
Sep 17, 2024
that will
close
this issue
In the code below, after clicking the close button of the window, the window will not close, staying open while the program is still running. Only after pressing enter on the command prompt, unblocking the getLine function, does the window close when the process exits. For my use case I need the window to close when the "run" function returns.
In the following gi-gtk program that does not happen:
The text was updated successfully, but these errors were encountered: