2 * \file gtk/Alert_pimpl.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "frontends/Alert.h"
15 #include "frontends/Alert_pimpl.h"
23 string translateShortcut(string const & str)
25 string::size_type i = str.find_first_of("&");
26 if (i == string::npos || i == str.length() - 1)
37 void warning_pimpl(string const &, string const & message)
39 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
41 Gtk::BUTTONS_CLOSE, true, true);
46 void error_pimpl(string const &, string const & message)
48 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
50 Gtk::BUTTONS_CLOSE, true, true);
55 void information_pimpl(string const &, string const & message)
57 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
59 Gtk::BUTTONS_CLOSE, true, true);
64 int prompt_pimpl(string const &, string const & question,
65 int defaultButton, int /*escapeButton*/,
66 string const & b1, string const & b2, string const & b3)
68 Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
69 Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));
72 gb3 = Glib::locale_to_utf8(translateShortcut(b3));
73 Gtk::MessageDialog dlg(Glib::locale_to_utf8(question),
74 Gtk::MESSAGE_QUESTION,
75 Gtk::BUTTONS_NONE, true, true);
76 dlg.add_button(gb1, 0);
77 dlg.add_button(gb2, 1);
79 dlg.add_button(gb3, 2);
80 dlg.set_default_response(defaultButton);
85 std::pair<bool, string> const askForText_pimpl(string const & msg,
88 Gtk::MessageDialog dlg(Glib::locale_to_utf8(msg),
89 Gtk::MESSAGE_QUESTION,
90 Gtk::BUTTONS_OK_CANCEL,
93 entry.set_text(Glib::locale_to_utf8(dflt));
94 entry.set_position(-1);
96 dlg.get_vbox()->children().push_back(
97 Gtk::Box_Helpers::Element(entry));
98 int response = dlg.run();
99 if (response == Gtk::RESPONSE_OK) {
100 string str = Glib::locale_from_utf8(entry.get_text());
101 return std::make_pair<bool, string>(true, str);
104 return std::make_pair<bool, string>(false, string());