Commit 09b262b9 authored by Bruno Guillaume's avatar Bruno Guillaume

use statusbar for messages about strategies

parent 5a70f572
......@@ -1336,7 +1336,7 @@
</packing>
</child>
<child>
<widget class="GtkStatusbar" id="statusbar1">
<widget class="GtkStatusbar" id="statusbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
......
......@@ -106,7 +106,8 @@ module Resources = struct
begin
match (Rewrite.at_least_one ~grs ~strat, Rewrite.at_most_one ~grs ~strat) with
| (true, true) -> Rewrite.display gr grs strat
| _ -> raise (Cannot_rewrite "Only deterministic GRS can be used in GUI")
| (false, true) -> raise (Cannot_rewrite "The current strategy may not be productive (cannot be used in GUI)")
| (_, false) -> raise (Cannot_rewrite "The current strategy is not deterministic (cannot be used in GUI)")
end;
| (None, _) -> raise (Cannot_rewrite "No grs file loaded")
| (_, None) -> raise (Cannot_rewrite "No graph file loaded")
......@@ -328,6 +329,33 @@ let init () =
grew_window#strat#set_text name;
with _ -> ()) in
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 load_gr () =
reset();
......
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