- let nonvars_uris = lazy (List.filter (non is_var_uri) uris) in
- if (selection_mode <> `SINGLE) &&
- (Helm_registry.get_bool "matita.auto_disambiguation")
- then
- Lazy.force nonvars_uris
- else begin
- let dialog = gui#newUriDialog () in
- dialog#uriChoiceTreeView#selection#set_mode selection_mode;
- let model = new stringListModel dialog#uriChoiceTreeView in
- let choices = ref None in
- let nonvars = ref false in
- dialog#uriChoiceDialog#set_title title;
- dialog#uriChoiceLabel#set_text msg;
- List.iter model#easy_append uris;
- dialog#uriChoiceConstantsButton#misc#set_sensitive nonvars_button;
- let return v =
- choices := v;
- dialog#uriChoiceDialog#destroy ();
- GMain.Main.quit ()
- in
- ignore (dialog#uriChoiceConstantsButton#connect#clicked (fun _ ->
- return (Some (Lazy.force nonvars_uris))));
- ignore (dialog#uriChoiceAutoButton#connect#clicked (fun _ ->
- Helm_registry.set_bool "matita.auto_disambiguation" true;
- return (Some (Lazy.force nonvars_uris))));
- ignore (dialog#uriChoiceSelectedButton#connect#clicked (fun _ ->
- match model#easy_selection () with
- | [] -> ()
- | uris -> return (Some uris)));
- ignore (dialog#uriChoiceAbortButton#connect#clicked (fun _ -> return None));
- ignore (dialog#uriChoiceDialog#event#connect#delete (fun _ -> true));
- dialog#uriChoiceDialog#show ();
- GtkThread.main ();
- (match !choices with
- | None -> raise MatitaTypes.No_choice
- | Some uris -> uris)
- end
+ let m =
+ GWindow.message_dialog
+ ~message ~use_markup ~message_type ~buttons ?parent ~destroy_with_parent
+ ~title ~allow_grow ~allow_shrink ?icon ~modal ~resizable ?screen
+ ?type_hint ~position ?wm_name ?wm_class ?border_width ?width ?height
+ ~show ()
+ in
+ ignore(m#connect#response
+ ~callback:(fun a -> GMain.Main.quit ();callback a));
+ ignore(m#connect#close
+ ~callback:(fun _ -> GMain.Main.quit ();raise PopupClosed));
+ GtkThread.main ();
+ m#destroy ()
+
+let popup_message_lowlevel
+ ~title ~message ?(no_separator=true) ~callback ~message_type ~buttons
+ ?parent ?(destroy_with_parent=true) ?(allow_grow=false) ?(allow_shrink=false)
+ ?icon ?(modal=true) ?(resizable=false) ?screen ?type_hint
+ ?(position=`CENTER_ON_PARENT) ?wm_name ?wm_class ?border_width ?width
+ ?height ?(show=true) ()
+=
+ let m =
+ GWindow.dialog
+ ~no_separator
+ ?parent ~destroy_with_parent
+ ~title ~allow_grow ~allow_shrink ?icon ~modal ~resizable ?screen
+ ?type_hint ~position ?wm_name ?wm_class ?border_width ?width ?height
+ ~show:false ()
+ in
+ let stock =
+ match message_type with
+ | `WARNING -> `DIALOG_WARNING
+ | `INFO -> `DIALOG_INFO
+ | `ERROR ->`DIALOG_ERROR
+ | `QUESTION -> `DIALOG_QUESTION
+ in
+ let image = GMisc.image ~stock ~icon_size:`DIALOG () in
+ let label = GMisc.label ~markup:message () in
+ label#set_line_wrap true;
+ let hbox = GPack.hbox ~spacing:10 () in
+ hbox#pack ~from:`START ~expand:true ~fill:true (image:>GObj.widget);
+ hbox#pack ~from:`START ~expand:true ~fill:true (label:>GObj.widget);
+ m#vbox#pack ~from:`START
+ ~padding:20 ~expand:true ~fill:true (hbox:>GObj.widget);
+ List.iter (fun (x, y) ->
+ m#add_button_stock x y;
+ if y = `CANCEL then
+ m#set_default_response y
+ ) buttons;
+ ignore(m#connect#response
+ ~callback:(fun a -> GMain.Main.quit ();callback a));
+ ignore(m#connect#close
+ ~callback:(fun _ -> GMain.Main.quit ();callback `POPUPCLOSED));
+ if show = true then
+ m#show ();
+ GtkThread.main ();
+ m#destroy ()
+
+
+let ask_confirmation ~title ~message ?parent () =
+ let rc = ref `YES in
+ let callback =
+ function
+ | `YES -> rc := `YES
+ | `NO -> rc := `NO
+ | `CANCEL -> rc := `CANCEL
+ | `DELETE_EVENT -> rc := `CANCEL
+ | `POPUPCLOSED -> rc := `CANCEL
+ in
+ let buttons = [`YES,`YES ; `NO,`NO ; `CANCEL,`CANCEL] in
+ popup_message_lowlevel
+ ~title ~message ~message_type:`WARNING ~callback ~buttons ?parent ();
+ !rc