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:
*) |
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