diff options
author | Camil Staps | 2019-10-22 21:55:08 +0200 |
---|---|---|
committer | Camil Staps | 2019-10-22 21:58:19 +0200 |
commit | 3b6a396b2f87ad40df39c22eed5175df80d843f3 (patch) | |
tree | 8b3af82582b86b87e987539a1a403d22946608ce /src/Gtk/State.icl | |
parent | Add whileFrozen, ensureDimensions, setColumnTitle and setCellText to GtkSheet (diff) |
Restructure signal handling: callbacks cannot be delayed because they may have pointer arguments referring to the stack; also, some callbacks expect a return value
Diffstat (limited to 'src/Gtk/State.icl')
-rw-r--r-- | src/Gtk/State.icl | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/Gtk/State.icl b/src/Gtk/State.icl index f6e56fe..405b8b4 100644 --- a/src/Gtk/State.icl +++ b/src/Gtk/State.icl @@ -54,30 +54,20 @@ where runGtk :: !(GtkM a) !*World -> (!a, !*World) runGtk f w = (getResult (wrapped_f newGtkState), w) where - (GtkM wrapped_f) = toState gtk_init >>| f >>= \x -> main >>| pure x - getResult :: !(!a, !GtkState) -> a getResult (r,_) = r - main = + (GtkM wrapped_f) = + toState gtk_init >>| + f >>= \x -> + saveState >>| + main x + + main x = toStateR gtk_main_iteration >>| - handle_signals >>| - getState >>= \{return} - | return -> pure () - | otherwise -> main - - handle_signals = - toStateR g_signal_pop >>= \sig_args -> case sig_args of - Nothing -> - pure () - Just sig_args -> - getState >>= \{signal_handlers} -> - let (Just handler) = 'Data.Map'.get sig_args.sig_id signal_handlers in - run handler >>| - handle_signals - with - run handler = case handler of - GSHI_Void st -> st + retrieveState >>= \{return} + | return -> pure x + | otherwise -> main x getState :: GtkM GtkState getState = GtkM \st -> (st,st) |