From 8b94854da995a34790d194dcc01b654409e77593 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 27 Oct 2019 12:34:02 +0100 Subject: Add runWhileEventsPending to be able to show something before starting a long task on the main thread --- src/Gtk/State.icl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Gtk/State.icl') diff --git a/src/Gtk/State.icl b/src/Gtk/State.icl index 4db51af..32c2b19 100644 --- a/src/Gtk/State.icl +++ b/src/Gtk/State.icl @@ -107,3 +107,12 @@ worldToVoid _ = () quit :: GtkM () quit = modState (\st -> {st & return=True}) >>| pure () + +runWhileEventsPending :: GtkM () +runWhileEventsPending = + toStateR gtk_events_pending >>= \pending + | not pending -> + pure () + | otherwise -> + toStateR gtk_main_iteration >>| + runWhileEventsPending -- cgit v1.2.3