Commit da06df2d authored by Bruno Guillaume's avatar Bruno Guillaume

Fix pble with non visible errors in GUI

parent f392e911
......@@ -304,8 +304,7 @@ let init () =
let show_error msg =
messages := [];
error "%s" msg;
refresh_error () in
error "%s" msg in
let reset () =
(* empty all webkits *)
......@@ -333,17 +332,13 @@ let init () =
| Libgrew.Bug msg -> show_error (sprintf "Libgrew.bug, please report: %s" msg)
| exc -> show_error (sprintf "Uncaught exception, please report: %s" (Printexc.to_string exc))
end;
refresh_error () in
(** CALLBACKS *)
let strat_list = ref [] in
let refresh_btn_run () =
match (!Resources.current_grs, !Resources.current_corpus, !strat_list) with
| (Some _, Some _, _::_) -> grew_window#btn_run#misc#set_sensitive true
| _ -> grew_window#btn_run#misc#set_sensitive false in
let _ = (fst combo_box_text)#connect#changed
(fun () ->
try
......@@ -353,30 +348,28 @@ let init () =
let nc = grew_window#statusbar#new_context ~name:"context" in
let _ = grew_window#strat#connect#changed
(fun () ->
ignore (nc#pop () );
let strat = grew_window#strat#text in
match !Resources.current_grs with
| Some grs ->
begin
try
match (Rewrite.at_least_one ~grs ~strat, Rewrite.at_most_one ~grs ~strat) with
| (true, true) -> grew_window#btn_run#misc#set_sensitive true
| (false, true) ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push "The current strategy may not be productive (cannot be used in GUI)")
| (_, false) ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push "The current strategy is not deterministic (cannot be used in GUI)")
with Error s ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push ("Cannot parse strategy: "^s))
end
| None -> ()
) in
let refresh_btn_run () =
ignore (nc#pop () );
match !Resources.current_grs with
| Some grs ->
begin
try
let strat = grew_window#strat#text in
match (Rewrite.at_least_one ~grs ~strat, Rewrite.at_most_one ~grs ~strat) with
| (true, true) -> grew_window#btn_run#misc#set_sensitive true
| (false, true) ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push "The current strategy may not be productive (cannot be used in GUI)")
| (_, false) ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push "The current strategy is not deterministic (cannot be used in GUI)")
with Error s ->
grew_window#btn_run#misc#set_sensitive false;
ignore (nc#push ("Cannot parse strategy: "^s))
end
| None -> grew_window#btn_run#misc#set_sensitive false in
let _ = grew_window#strat#connect#changed refresh_btn_run in
let load_graph () =
match !Resources.current_graph with
......@@ -407,7 +400,6 @@ let init () =
(* -------------------------------------------------------------------------------- *)
let load_corpus () =
messages := []; reset();
error_handling Resources.load_corpus ();
Resources.update_graph ();
match (!Resources.current_corpus, !Resources.current_corpus_file) with
......@@ -429,8 +421,7 @@ let init () =
| Some gr_file ->
error_handling load_corpus ();
refresh_btn_run ()
);
refresh_error () in
) in
(* -------------------------------------------------------------------------------- *)
......@@ -475,12 +466,12 @@ let init () =
begin
match strat with
| None -> ()
| None -> (fst combo_box_text)#set_active 0
| Some strat ->
grew_window#strat#set_text strat;
begin
match List_.index strat !strat_list with
| None -> ()
| None -> (fst combo_box_text)#set_active 0
| Some i -> (fst combo_box_text)#set_active i
end
end
......@@ -514,7 +505,8 @@ let init () =
let _ = grew_window#btn_refresh_grs#connect#clicked
~callback: (fun () ->
messages := [];
error_handling load_grs ();
let strat = grew_window#strat#text in
error_handling (load_grs ~strat) ();
refresh_corpus ()
) in
......@@ -566,6 +558,7 @@ let init () =
let _ = grew_window#toplevel#connect#destroy ~callback:(GMain.quit) in
let run () =
messages := [];
let rew_display = Resources.rewrite grew_window#strat#text in
let fl = ref "G0" in
grew_window#vpaned_right#set_position 30;
......@@ -977,5 +970,6 @@ let init () =
load_corpus ();
refresh_btn_run ();
refresh_error ();
GMain.Main.main ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment