diff options
author | Adrien Nader <adrien@notk.org> | 2016-10-23 12:52:46 +0200 |
---|---|---|
committer | Adrien Nader <adrien@notk.org> | 2016-10-23 12:52:46 +0200 |
commit | 3680b3a3ed7aa94b2c5c9e41853b89cecdbf33c1 (patch) | |
tree | 63942cfec570cc98838eb40a1e0dc715f5df45fa | |
parent | c5c27f831afe94dcd54e7f89a9a8f2097a62de0a (diff) |
GUI_Settings: the end of subsettings init should not commit the config.
-rw-r--r-- | src/yypkg/gui/GUI_Settings.ml | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/yypkg/gui/GUI_Settings.ml b/src/yypkg/gui/GUI_Settings.ml index bb5c8f6..209f2a6 100644 --- a/src/yypkg/gui/GUI_Settings.ml +++ b/src/yypkg/gui/GUI_Settings.ml @@ -286,15 +286,14 @@ class repo_predicates ~box = end -let settings_message settings f conf_get = +let settings_message ~settings ~conf_get ~f ~on_done = let k next conf = send (`SettingIter (conf, next)) in let wrap next setting conf = f setting conf (k next) in - let confirm conf = send (`CheckValidated conf) in - let first = List.fold_left wrap confirm (List.rev settings) in + let first = List.fold_left wrap on_done (List.rev settings) in if List.length settings <> 0 then first (conf_get ()) @@ -319,27 +318,32 @@ let t shared = (new local_predicates ~box:box_scroller :> setting); (new repo_predicates ~box:box_scroller :> setting); ] in - let send_inits = settings_message settings (fun s conf -> s#init conf) in - let send_checks = settings_message settings (fun s conf -> s#check conf) in + let settings_message = settings_message ~settings ~conf_get:Config.read in + let send_inits () = settings_message + ~f:(fun s conf -> s#init conf) + ~on_done:ignore in + let send_checks () = settings_message + ~f:(fun s conf -> s#check conf) + ~on_done:(fun conf -> send (`CheckValidated conf)) in let apply = - let box = Elm_box.addx ~box ~size_hint:[ `hfill; `hexpand ] box in - Elm_box.horizontal_set box true; - Elm_box.homogeneous_set box true; - let apply = Elm_button.addx box ~box ~text:check_button_text in - ignore (Elm_connect.Button.clicked apply (fun _o -> - Elm_object.part_text_set apply "Validating..."; - Elm_object.disabled_set apply true; - Checks.send `Show; - send_checks Config.read; - )); - Elm_object.focus_set apply true; - apply + Elm_box.addx ~box ~size_hint:[ `hfill; `hexpand ] box + |> (fun box -> Elm_box.horizontal_set box true; box) + |> (fun box -> Elm_box.homogeneous_set box true; box) + |> (fun box -> Elm_button.addx box ~box ~text:check_button_text) + |> (fun apply -> + ignore @@ Elm_connect.Button.clicked apply (fun _o -> + Elm_object.part_text_set apply "Validating..."; + Elm_object.disabled_set apply true; + Checks.send `Show; + send_checks ()); + apply) + |> (fun apply -> Elm_object.focus_set apply true; apply) in let check_failed () = Elm_object.part_text_set apply check_button_text; Elm_object.disabled_set apply false in - send_inits Config.read; + send_inits (); { check_failed; box; checks_progress } let state_machine settings _shared (msg : ev) = |