3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
18 #include "support/filetools.h"
19 #include "support/path_defines.h"
27 string const getDefaultUnit()
29 switch (lyxrc.default_papersize) {
30 case PAPER_DEFAULT: return "cm";
32 case PAPER_LEGALPAPER:
33 case PAPER_EXECUTIVEPAPER: return "in"; break;
37 case PAPER_B5PAPER: return "cm"; break;
42 void unitsComboFromLength(Gtk::ComboBox * combo,
43 Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
44 LyXLength const & len,
47 string unit = stringFromUnit(len.unit());
51 Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
52 Gtk::TreeModel::iterator end = combo->get_model()->children().end();
53 for (; it != end ; ++it) {
54 if ((*it)[stringcol] == unit) {
55 combo->set_active(it);
60 // Fallen through, we didn't find the target length!
62 lyxerr << "unitsComboFromLength: couldn't find "
63 "target unit '" << unit << "'\n";
67 vector<string> const buildLengthUnitList()
69 vector<string> data(unit_name_gui, unit_name_gui + num_units);
75 string const findGladeFile(string const & name)
77 // First, search in the installation directories.
79 string filename = lyx::support::LibFileSearch("glade", name, "glade");
81 if (!filename.empty())
84 // Second, search in the src tree.
86 lyx::support::AddPath(lyx::support::top_srcdir(),
87 "src/frontends/gtk/glade");
89 filename = lyx::support::ChangeExtension(name, ".glade");
90 filename = lyx::support::AddName(dir, filename);
92 if (!lyx::support::IsFileReadable(filename)) {
93 lyxerr << "Unable to find glade file \"" << name
94 << "\". libglade is going to crash..." << std::endl;
100 } // namespace frontend