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.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
21 #include "frontends/Alert.h"
22 #include "frontends/Alert_pimpl.h"
32 string translateShortcut(string const & str)
34 string::size_type i = str.find_first_of("&");
35 if (i == string::npos || i == str.length() - 1)
46 void warning_pimpl(string const & title, string const & message)
48 Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
49 true, Gtk::MESSAGE_WARNING,
50 Gtk::BUTTONS_CLOSE, true);
56 void error_pimpl(string const & title, string const & message)
58 Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
59 true, Gtk::MESSAGE_ERROR,
60 Gtk::BUTTONS_CLOSE, true);
66 void information_pimpl(string const & title, string const & message)
68 Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
69 true, Gtk::MESSAGE_INFO,
70 Gtk::BUTTONS_CLOSE, true);
76 int prompt_pimpl(string const & title, string const & question,
77 int defaultButton, int /*escapeButton*/,
78 string const & b1, string const & b2, string const & b3)
80 Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
81 Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));
84 gb3 = Glib::locale_to_utf8(translateShortcut(b3));
85 Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(question)),
86 true, Gtk::MESSAGE_QUESTION,
87 Gtk::BUTTONS_NONE, true);
89 dlg.add_button(gb1, 0);
90 dlg.add_button(gb2, 1);
92 dlg.add_button(gb3, 2);
93 dlg.set_default_response(defaultButton);
98 std::pair<bool, string> const askForText_pimpl(string const & msg,
101 Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(msg)),
102 true, Gtk::MESSAGE_QUESTION,
103 Gtk::BUTTONS_OK_CANCEL,
106 entry.set_text(Glib::locale_to_utf8(dflt));
107 entry.set_position(-1);
109 dlg.get_vbox()->children().push_back(
110 Gtk::Box_Helpers::Element(entry));
111 int response = dlg.run();
112 if (response == Gtk::RESPONSE_OK) {
113 string str = Glib::locale_from_utf8(entry.get_text());
114 return std::make_pair<bool, string>(true, str);
117 return std::make_pair<bool, string>(false, string());