2 * Copyright (c) 2011-2016, JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 // MessageDialog doesn't allow subclassing, so we merely wrap the
35 // constructor for it the dialog, and then run it, returning the result.
38 public static bool confirm(Window parent, string message, string dialog_name)
40 Gdk.Color white = make_color(65535, 65535, 65535);
42 MessageDialog dialog = new Gtk.MessageDialog(parent,
43 Gtk.DialogFlags.DESTROY_WITH_PARENT,
44 Gtk.MessageType.WARNING,
45 Gtk.ButtonsType.YES_NO,
48 var content_area = dialog.get_content_area();
49 CheckButton remember_checkbutton;
51 if (dialog_name != null && dialog_name != "")
53 remember_checkbutton = new CheckButton.with_label(_("Do not show this message again"));
54 remember_checkbutton.set_focus_on_click(false);
55 remember_checkbutton.has_focus = false;
56 content_area.has_focus = true;
58 // Not sure if 0.26 is the minimum for MessageDialog.get_message_area. 0.16 sure isn't :-(
60 var message_area = dialog.get_message_area();
61 ((Box)message_area).pack_start(remember_checkbutton, false, false, 12);
63 HBox hbox = new HBox(false, 0);
64 hbox.pack_start(new HBox(false, 0), true, true, 20);
65 hbox.pack_start(remember_checkbutton, false, false, 12);
66 ((Box)content_area).pack_start(hbox, true, true, 12);
70 // dialog.set_modal(true);
71 dialog.set_title(_("Warning"));
72 dialog.modify_bg(StateType.NORMAL, white);
74 // ((Box) content_area).set_spacing(12);
75 content_area.modify_bg(StateType.NORMAL, white);
77 content_area.show_all();
79 dialog.set_markup(message);
81 var ret = dialog.run();
83 return (ret == Gtk.ResponseType.YES);