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 _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
18 #include "frontends/Alert.h"
19 #include "frontends/Alert_pimpl.h"
29 string translateShortcut(string const & str)
31 string::size_type i = str.find_first_of("&");
32 if (i == string::npos || i == str.length() - 1)
43 void warning_pimpl(string const &, string const & message)
45 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
46 true, Gtk::MESSAGE_WARNING,
47 Gtk::BUTTONS_CLOSE, true);
52 void error_pimpl(string const &, string const & message)
54 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
55 true, Gtk::MESSAGE_ERROR,
56 Gtk::BUTTONS_CLOSE, true);
61 void information_pimpl(string const &, string const & message)
63 Gtk::MessageDialog dlg(Glib::locale_to_utf8(message),
64 true, Gtk::MESSAGE_INFO,
65 Gtk::BUTTONS_CLOSE, true);
70 int prompt_pimpl(string const &, string const & question,
71 int defaultButton, int /*escapeButton*/,
72 string const & b1, string const & b2, string const & b3)
74 Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
75 Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));
78 gb3 = Glib::locale_to_utf8(translateShortcut(b3));
79 Gtk::MessageDialog dlg(Glib::locale_to_utf8(question),
80 true, Gtk::MESSAGE_QUESTION,
81 Gtk::BUTTONS_NONE, true);
82 dlg.add_button(gb1, 0);
83 dlg.add_button(gb2, 1);
85 dlg.add_button(gb3, 2);
86 dlg.set_default_response(defaultButton);
91 std::pair<bool, string> const askForText_pimpl(string const & msg,
94 Gtk::MessageDialog dlg(Glib::locale_to_utf8(msg),
95 true, Gtk::MESSAGE_QUESTION,
96 Gtk::BUTTONS_OK_CANCEL,
99 entry.set_text(Glib::locale_to_utf8(dflt));
100 entry.set_position(-1);
102 dlg.get_vbox()->children().push_back(
103 Gtk::Box_Helpers::Element(entry));
104 int response = dlg.run();
105 if (response == Gtk::RESPONSE_OK) {
106 string str = Glib::locale_from_utf8(entry.get_text());
107 return std::make_pair<bool, string>(true, str);
110 return std::make_pair<bool, string>(false, string());