bug fixed while adding new aircraft

This commit is contained in:
Pascal Brisset
2007-10-13 08:20:15 +00:00
parent 2e8b89c6fd
commit ca45ac5a5f
+19 -20
View File
@@ -144,16 +144,15 @@ let first_word = fun s ->
(* Link A/C to airframe & flight_plan labels *) (* Link A/C to airframe & flight_plan labels *)
let ac_combo_handler = fun gui (ac_combo:Utils.combo) target_combo -> let ac_combo_handler = fun gui (ac_combo:Utils.combo) target_combo ->
combo_connect ac_combo let update_params = fun ac_name ->
(fun ac_name -> try
try let aircraft = Hashtbl.find Utils.aircrafts ac_name in
let aircraft = Hashtbl.find Utils.aircrafts ac_name in let sample = aircraft_sample ac_name "42" in
let sample = aircraft_sample ac_name "42" in let value = fun a ->
let value = fun a -> try (ExtXml.attrib aircraft a) with _ -> Xml.attrib sample a in
try (ExtXml.attrib aircraft a) with _ -> Xml.attrib sample a in List.iter
List.iter (fun (a, label, _, _, _, _) -> label#set_text (value a))
(fun (a, label, _, _, _, _) -> label#set_text (value a)) (ac_files gui);
(ac_files gui);
let ac_id = ExtXml.attrib aircraft "ac_id" let ac_id = ExtXml.attrib aircraft "ac_id"
and gui_color = ExtXml.attrib_or_default aircraft "gui_color" "white" in and gui_color = ExtXml.attrib_or_default aircraft "gui_color" "white" in
gui#button_clean#misc#set_sensitive true; gui#button_clean#misc#set_sensitive true;
@@ -162,14 +161,15 @@ let ac_combo_handler = fun gui (ac_combo:Utils.combo) target_combo ->
current_color := gui_color; current_color := gui_color;
gui#entry_ac_id#set_text ac_id; gui#entry_ac_id#set_text ac_id;
(Utils.combo_widget target_combo)#misc#set_sensitive true; (Utils.combo_widget target_combo)#misc#set_sensitive true;
with with
Not_found -> Not_found ->
gui#label_airframe#set_text ""; gui#label_airframe#set_text "";
gui#label_flight_plan#set_text ""; gui#label_flight_plan#set_text "";
gui#button_clean#misc#set_sensitive false; gui#button_clean#misc#set_sensitive false;
gui#button_build#misc#set_sensitive false; gui#button_build#misc#set_sensitive false;
(Utils.combo_widget target_combo)#misc#set_sensitive false (Utils.combo_widget target_combo)#misc#set_sensitive false
); in
combo_connect ac_combo update_params;
(* New A/C button *) (* New A/C button *)
let callback = fun _ -> let callback = fun _ ->
@@ -179,7 +179,7 @@ let ac_combo_handler = fun gui (ac_combo:Utils.combo) target_combo ->
Utils.add_to_combo ac_combo s; Utils.add_to_combo ac_combo s;
let a = aircraft_sample s (string_of_int (new_ac_id ())) in let a = aircraft_sample s (string_of_int (new_ac_id ())) in
Hashtbl.add Utils.aircrafts s a; Hashtbl.add Utils.aircrafts s a;
Utils.aircrafts_table_has_changed := true update_params s
in in
ignore (gui#menu_item_new_ac#connect#activate ~callback); ignore (gui#menu_item_new_ac#connect#activate ~callback);
@@ -190,7 +190,6 @@ let ac_combo_handler = fun gui (ac_combo:Utils.combo) target_combo ->
match GToolbox.question_box ~title:"Delete A/C" ~buttons:["Cancel"; "Delete"] ~default:2 (sprintf "Delete %s ? (no undo after Save)" ac_name) with match GToolbox.question_box ~title:"Delete A/C" ~buttons:["Cancel"; "Delete"] ~default:2 (sprintf "Delete %s ? (no undo after Save)" ac_name) with
2 -> begin 2 -> begin
begin try Hashtbl.remove Utils.aircrafts ac_name with _ -> () end; begin try Hashtbl.remove Utils.aircrafts ac_name with _ -> () end;
Utils.aircrafts_table_has_changed := true;
let combo_box = Utils.combo_widget ac_combo in let combo_box = Utils.combo_widget ac_combo in
match combo_box#active_iter with match combo_box#active_iter with
| None -> () | None -> ()