let add_item (main_ui:Design.main_window_extension_points)
      ~use_values (factory:GMenu.menu GMenu.factory) name arg_opt callback =
  if use_values && not (Db.Value.is_computed ()) then
      (* add the menu item asking for running value analysis *)
    let callback () = 
      let msg = "You need to Execute Values analysis first." in
        add_msg main_ui ("[" ^ name ^ "] " ^ msg) 
    in ignore (factory#add_item name ~callback)
  else
    match arg_opt with
      | None -> (* add the menu item, but it isn't sensitive *)
          let item = factory#add_item name ~callback: (fun () -> ())
          in item#misc#set_sensitive false
      | Some arg -> (* add the menu item with its callback *)
          ignore (factory#add_item name ~callback: (fun () -> callback arg))