[settings] select new modules' settings by default

This commit is contained in:
Gautier Hattenberger
2014-10-08 15:05:24 +02:00
parent f0c3dfb578
commit e2e97aa709
+10 -6
View File
@@ -159,6 +159,9 @@ let save_callback = fun ?user_save gui ac_combo tree tree_modules () ->
end; end;
write_conf_xml ?user_save () write_conf_xml ?user_save ()
(* selected state type *)
type selected_t = Selected | Unselected | Unknown
(* Get the settings (string list) with current modules *) (* Get the settings (string list) with current modules *)
let get_settings_modules = fun ac_xml settings_modules -> let get_settings_modules = fun ac_xml settings_modules ->
(* get modules *) (* get modules *)
@@ -192,16 +195,17 @@ let get_settings_modules = fun ac_xml settings_modules ->
List.iter (fun s -> List.iter (fun s ->
let l = String.length s in let l = String.length s in
if s.[0] == '[' && s.[l - 1] = ']' if s.[0] == '[' && s.[l - 1] = ']'
then Hashtbl.add current (String.sub s 1 (l - 2)) false (* unchecked *) then Hashtbl.add current (String.sub s 1 (l - 2)) Unselected
else Hashtbl.add current s true (* checked *) else Hashtbl.add current s Selected
) set; ) set;
(* build list with previous state if necessary *) (* build list with previous state if necessary *)
List.map (fun s -> List.map (fun s ->
(* get previous state, false (unchecked otherwise) *) (* get previous state, unknonw otherwise (new module, will be selected by default) *)
let checked = try Hashtbl.find current s with _ -> false in let checked = try Hashtbl.find current s with _ -> Unknown in
(* add to tree with correct state *) (* add to tree with correct state *)
if checked then s match checked with
else ("["^s^"]") | Selected | Unknown -> s
| Unselected -> ("["^s^"]")
) settings ) settings
let first_word = fun s -> let first_word = fun s ->