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"
21 string translateShortcut(string const & str)
23 string::size_type i = str.find_first_of("&");
24 if (i == string::npos || i == str.length() - 1)
35 void warning_pimpl(string const &, string const & message)
37 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
39 Gtk::BUTTONS_CLOSE, true, true);
44 void error_pimpl(string const &, string const & message)
46 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
48 Gtk::BUTTONS_CLOSE, true, true);
53 void information_pimpl(string const &, string const & message)
55 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
57 Gtk::BUTTONS_CLOSE, true, true);
62 int prompt_pimpl(string const &, string const & question,
63 int defaultButton, int /*escapeButton*/,
64 string const & b1, string const & b2, string const & b3)
66 Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
67 Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));
70 gb3 = Glib::locale_to_utf8(translateShortcut(b3));
71 Gtk::MessageDialog dlg(Glib::locale_to_utf8(question),
72 Gtk::MESSAGE_QUESTION,
73 Gtk::BUTTONS_NONE, true, true);
74 dlg.add_button(gb1, 0);
75 dlg.add_button(gb2, 1);
77 dlg.add_button(gb3, 2);
78 dlg.set_default_response(defaultButton);
83 std::pair<bool, string> const askForText_pimpl(string const & msg,
86 Gtk::MessageDialog dlg(Glib::locale_to_utf8(msg),
87 Gtk::MESSAGE_QUESTION,
88 Gtk::BUTTONS_OK_CANCEL,
91 entry.set_text(Glib::locale_to_utf8(dflt));
92 entry.set_position(-1);
94 dlg.get_vbox()->children().push_back(
95 Gtk::Box_Helpers::Element(entry));
96 int response = dlg.run();
97 if (response == Gtk::RESPONSE_OK) {
98 string str = Glib::locale_from_utf8(entry.get_text());
99 return std::make_pair<bool, string>(true, str);
102 return std::make_pair<bool, string>(false, string());