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 "ControlAboutlyx.h"
22 #include "GAboutlyx.h"
26 #include "support/filetools.h" // LibFileSearch
28 #include <libglademm.h>
32 using lyx::support::libFileSearch;
34 using std::ostringstream;
42 enum TranslateState {NORMAL, BEGIN, IN_AT, IN_BOLD, IN_ITALIC};
45 Glib::ustring translateMarkup(Glib::ustring const & lyxMarkup)
47 Glib::ustring::const_iterator it = lyxMarkup.begin();
48 Glib::ustring pangoMarkup;
49 TranslateState state = BEGIN;
50 for (; it != lyxMarkup.end(); it++) {
59 pangoMarkup.push_back('\n');
63 pangoMarkup.push_back(*it);
79 pangoMarkup.push_back('@');
80 pangoMarkup.push_back('\n');
84 pangoMarkup.push_back('@');
85 pangoMarkup.push_back(*it);
92 pangoMarkup += "</b>\n";
95 pangoMarkup.push_back(*it);
102 pangoMarkup += "</i>\n";
105 pangoMarkup.push_back(*it);
112 pangoMarkup.push_back('\n');
115 pangoMarkup.push_back(*it);
120 pangoMarkup += "amp;";
123 pangoMarkup.erase(--(pangoMarkup.end()));
124 pangoMarkup += "<";
127 pangoMarkup.erase(--(pangoMarkup.end()));
128 pangoMarkup += ">";
136 pangoMarkup.push_back('@');
139 pangoMarkup += "</i>";
142 pangoMarkup += "</b>";
154 GAboutlyx::GAboutlyx(Dialog & parent)
155 : GViewCB<ControlAboutlyx, GViewGladeB>(parent, "About LyX")
160 void GAboutlyx::doBuild()
162 string const gladeName = findGladeFile("aboutlyx");
163 xml_ = Gnome::Glade::Xml::create(gladeName);
165 Gtk::AboutDialog *dialog;
166 xml_->get_widget("dialog", dialog);
168 dialog->set_version(Glib::ustring(PACKAGE_VERSION));
170 std::ostringstream ls;
171 ls << controller().getCopyright() << "\n\n"
172 << controller().getLicense() << "\n\n"
173 << controller().getDisclaimer();
174 dialog->set_license (ls.str());
176 string const filename = libFileSearch("images", "banner", "ppm");
177 Glib::RefPtr<Gdk::Pixbuf> logo = Gdk::Pixbuf::create_from_file(filename);
178 Glib::RefPtr<Gdk::Pixbuf> logo_scaled = logo->scale_simple(
179 logo->get_width() / 2,
180 logo->get_height() / 2,
181 Gdk::INTERP_BILINEAR);
182 dialog->set_logo(logo_scaled);
184 // Total crack - find and hide the built in Credits button
185 // that glade helpfully puts there for us.
186 Glib::List_Iterator<Gtk::Box_Helpers::Child> it =
187 dialog->get_action_area()->children().begin();
188 Glib::List_Iterator<Gtk::Box_Helpers::Child> const end =
189 dialog->get_action_area()->children().end();
190 for (; it != end; ++it) {
191 Gtk::Button * button = (Gtk::Button*)(it->get_widget());
192 // The close button is a stock ID which we can reliably test for
193 // The license button has no icon
194 // What's left is the credits button
195 if (button->get_label() != "gtk-close" && button->get_image())
199 Gtk::Button &authorbutton = *Gtk::manage(
200 new Gtk::Button(_("C_redits"), true));
201 authorbutton.set_image(*Gtk::manage(
202 new Gtk::Image(Gtk::Stock::ABOUT, Gtk::ICON_SIZE_BUTTON)));
203 dialog->get_action_area()->pack_end(authorbutton);
204 dialog->get_action_area()->reorder_child(authorbutton, 0);
205 authorbutton.signal_clicked().connect(
206 sigc::mem_fun(*this, &GAboutlyx::showAuthors));
208 xml_->get_widget("AuthorsDialog", authordialog_);
209 Gtk::Label *authorlabel;
210 xml_->get_widget("Authors", authorlabel);
211 std::ostringstream crs;
212 controller().getCredits(crs);
213 authorlabel->set_markup(translateMarkup(
214 Glib::convert(crs.str(), "UTF-8", "ISO-8859-1")));
218 void GAboutlyx::showAuthors()
220 authordialog_->run();
221 authordialog_->hide();
225 } // namespace frontend