Skip to content

Commit

Permalink
[paparazzicenter] move target button to menu and print simple error m…
Browse files Browse the repository at this point in the history
…essage
  • Loading branch information
gautierhattenberger committed Nov 1, 2013
1 parent 84cf87c commit 7284adf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 73 deletions.
64 changes: 10 additions & 54 deletions sw/supervision/paparazzicenter.glade
Expand Up @@ -151,6 +151,16 @@
<signal name="activate" handler="on_save1_activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu_item_new_target">
<property name="label">New target</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_item_new_target_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
Expand Down Expand Up @@ -994,60 +1004,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_new_target">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip" translatable="yes">Add a target in the combo list</property>
<property name="use_action_appearance">False</property>
<child>
<widget class="GtkAlignment" id="alignment60">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<widget class="GtkHBox" id="hbox62">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image34">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label100">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">New Target</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
Expand Down
4 changes: 2 additions & 2 deletions sw/supervision/paparazzicenter.ml
Expand Up @@ -190,8 +190,6 @@ let () =
gui#button_clean#misc#set_sensitive false;
gui#button_build#misc#set_sensitive false;

AC.ac_combo_handler gui ac_combo target_combo;

(* Change the buffer of the text view to attach a tag_table *)
let background_tags =
List.map (fun color ->
Expand Down Expand Up @@ -235,6 +233,8 @@ let () =
let end_mark = gui#console#buffer#create_mark end_iter in
gui#console#scroll_mark_onscreen (`MARK end_mark) in

AC.ac_combo_handler gui ac_combo target_combo log;

AC.build_handler ~file gui ac_combo target_combo log;

let session_combo, execute_session = CP.supervision ~file gui log ac_combo target_combo in
Expand Down
34 changes: 17 additions & 17 deletions sw/supervision/pc_aircraft.ml
Expand Up @@ -174,15 +174,15 @@ let first_word = fun s ->

(** Parse Airframe File for Targets **)

let parse_ac_targets = fun target_combo ac_file ->
let parse_ac_targets = fun target_combo ac_file (log:string->unit) ->
let strings = ref [] in
let count = ref 0 in
let (store, column) = Gtk_tools.combo_model target_combo in
store#clear ();
(** Clear ComboBox
**)
(try
let af_xml = Xml.parse_file (Env.paparazzi_src // "conf" // ac_file) in
let af_xml = Xml.parse_file (Env.paparazzi_home // "conf" // ac_file) in
List.iter (fun tag ->
if ExtXml.tag_is tag "firmware" then begin
begin try
Expand Down Expand Up @@ -215,11 +215,11 @@ let parse_ac_targets = fun target_combo ac_file ->
(**
Gtk_tools.combo (!strings) target_combo
**)
with _ -> ())
with _ -> log (sprintf "Error while parsing targets from file %s\n" ac_file))


(* Link A/C to airframe & flight_plan labels *)
let ac_combo_handler = fun gui (ac_combo:Gtk_tools.combo) target_combo ->
let ac_combo_handler = fun gui (ac_combo:Gtk_tools.combo) target_combo (log:string->unit) ->
(* build tree for settings *)
let tree_set = Gtk_tools.tree gui#tree_settings in
let model = Gtk_tools.tree_model tree_set in
Expand Down Expand Up @@ -249,7 +249,7 @@ let ac_combo_handler = fun gui (ac_combo:Gtk_tools.combo) target_combo ->
current_color := gui_color;
gui#entry_ac_id#set_text ac_id;
(Gtk_tools.combo_widget target_combo)#misc#set_sensitive true;
parse_ac_targets target_combo (ExtXml.attrib aircraft "airframe");
parse_ac_targets target_combo (ExtXml.attrib aircraft "airframe") log;
with
Not_found ->
gui#label_airframe#set_text "";
Expand Down Expand Up @@ -295,6 +295,18 @@ let ac_combo_handler = fun gui (ac_combo:Gtk_tools.combo) target_combo ->
in
ignore (gui#delete_ac_menu_item#connect#activate ~callback);

(* New Target button *)
let callback = fun _ ->
match GToolbox.input_string ~title:"New Target" ~text:"tunnel" "New build target ?" with
None -> ()
| Some s ->
let (store, column) = Gtk_tools.combo_model target_combo in
let row = store#append () in
store#set ~row ~column s;
(Gtk_tools.combo_widget target_combo)#set_active_iter (Some row)
in
ignore (gui#menu_item_new_target#connect#activate ~callback);

(* GUI color *)
let callback = fun _ ->
let csd = GWindow.color_selection_dialog ~show:true () in
Expand Down Expand Up @@ -365,18 +377,6 @@ let build_handler = fun ~file gui ac_combo (target_combo:Gtk_tools.combo) (log:s
(* if target is sim or nps, deactivate the upload button *)
gui#button_upload#misc#set_sensitive (target <> "sim" && target <> "nps"));

(* New Target button *)
let callback = fun _ ->
match GToolbox.input_string ~title:"New Target" ~text:"tunnel" "New build target ?" with
None -> ()
| Some s ->
let (store, column) = Gtk_tools.combo_model target_combo in
let row = store#append () in
store#set ~row ~column s;
(Gtk_tools.combo_widget target_combo)#set_active_iter (Some row)
in
ignore (gui#button_new_target#connect#clicked ~callback);

(* Clean button *)
let callback = fun () ->
Utils.command ~file gui log (Gtk_tools.combo_value ac_combo) "clean_ac" in
Expand Down

0 comments on commit 7284adf

Please sign in to comment.