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 &, string const & message)
48 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
49 true, Gtk::MESSAGE_WARNING,
50 Gtk::BUTTONS_CLOSE, true);
55 void error_pimpl(string const &, string const & message)
57 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
58 true, Gtk::MESSAGE_ERROR,
59 Gtk::BUTTONS_CLOSE, true);
64 void information_pimpl(string const &, string const & message)
66 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
67 true, Gtk::MESSAGE_INFO,
68 Gtk::BUTTONS_CLOSE, true);
73 int prompt_pimpl(string const &, string const & question,
74 int defaultButton, int /*escapeButton*/,
75 string const & b1, string const & b2, string const & b3)
77 Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
78 Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));
81 gb3 = Glib::locale_to_utf8(translateShortcut(b3));
82 Gtk::MessageDialog dlg(Glib::locale_to_utf8(question),
83 true, Gtk::MESSAGE_QUESTION,
84 Gtk::BUTTONS_NONE, true);
85 dlg.add_button(gb1, 0);
86 dlg.add_button(gb2, 1);
88 dlg.add_button(gb3, 2);
89 dlg.set_default_response(defaultButton);
94 std::pair<bool, string> const askForText_pimpl(string const & msg,
97 Gtk::MessageDialog dlg(Glib::locale_to_utf8(msg),
98 true, Gtk::MESSAGE_QUESTION,
99 Gtk::BUTTONS_OK_CANCEL,
102 entry.set_text(Glib::locale_to_utf8(dflt));
103 entry.set_position(-1);
105 dlg.get_vbox()->children().push_back(
106 Gtk::Box_Helpers::Element(entry));
107 int response = dlg.run();
108 if (response == Gtk::RESPONSE_OK) {
109 string str = Glib::locale_from_utf8(entry.get_text());
110 return std::make_pair<bool, string>(true, str);
113 return std::make_pair<bool, string>(false, string());