mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 07:53:43 +08:00
[pprzcenter] check if backup actually differs
and always delete backup conf/conf.xml~ if it doesn't differ (e.g. it was created when you changed something, but then you reversed that change again)
This commit is contained in:
@@ -122,13 +122,19 @@ let write_preferences = fun (gui:Gtk_pc.window) file (ac_combo:Gtk_tools.combo)
|
||||
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt xml);
|
||||
close_out f
|
||||
|
||||
let backup_file_differs = fun () ->
|
||||
if Sys.file_exists Utils.backup_xml_file then
|
||||
ExtXml.parse_file Utils.backup_xml_file <> ExtXml.parse_file Utils.conf_xml_file
|
||||
else
|
||||
false
|
||||
|
||||
let quit_callback = fun gui ac_combo session_combo target_combo _ ->
|
||||
CP.close_programs gui;
|
||||
write_preferences gui Env.gconf_file ac_combo session_combo target_combo;
|
||||
exit 0
|
||||
|
||||
let quit_button_callback = fun gui ac_combo session_combo target_combo ?(confirm_quit = true) () ->
|
||||
if Sys.file_exists Utils.backup_xml_file then begin
|
||||
if backup_file_differs () then begin
|
||||
let rec question_box = fun () ->
|
||||
match GToolbox.question_box ~title:"Quit" ~buttons:["Save changes"; "Discard changes"; "View changes"; "Cancel"] ~default:1 "Configuration changes have not been saved" with
|
||||
| 2 ->
|
||||
@@ -142,13 +148,16 @@ let quit_button_callback = fun gui ac_combo session_combo target_combo ?(confirm
|
||||
quit_callback gui ac_combo session_combo target_combo ()
|
||||
| _ -> () in
|
||||
question_box ()
|
||||
end else
|
||||
end else begin
|
||||
if Sys.file_exists Utils.backup_xml_file then
|
||||
Sys.remove Utils.backup_xml_file;
|
||||
if confirm_quit then
|
||||
match GToolbox.question_box ~title:"Quit" ~buttons:["Cancel"; "Quit"] ~default:2 "Quit ?" with
|
||||
2 -> quit_callback gui ac_combo session_combo target_combo ()
|
||||
| _ -> ()
|
||||
else
|
||||
quit_callback gui ac_combo session_combo target_combo ()
|
||||
end
|
||||
|
||||
let quit_window_callback = fun gui ac_combo session_combo target_combo _ ->
|
||||
quit_button_callback gui ac_combo session_combo target_combo ~confirm_quit:false ();
|
||||
|
||||
Reference in New Issue
Block a user