struct

(** Makes a dynamic submenu of a given menu (the father). When the father is activated, the submenu entries are recalculated with the given function (dynList).

Exemple:

make              
  ~submenu:w#MACHINE_ELIM_menu 
  ~menu:w#MACHINE_ELIM         
  ~dynList:machineList       
  ~action:(fun x ->fun _ -> prerr_endline x)   ;; 
*)

let make 
   ?(set_active:(string->bool)=(fun x->false))
   ~(submenu: GMenu.menu) 
   ~(menu:    GMenu.image_menu_item) 
   ~(dynList: unit->(string list)) 
   ~(action:  string->unit->unit) () = 

  let recalc () = (

    List.iter  (submenu#remove) (submenu#children) ;

    List.iter  (fun x -> let i=(GMenu.check_menu_item ~active:(set_active x) ~label:x  ~packing:(submenu#add) ()) in 
                         let _ = i#connect#toggled ~callback:(action x) in ()
                ) 
               (dynList ())          ) in 

  let _ = menu#connect#activate ~callback:recalc in 
  ()
;;
end