3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
14 // Too hard to make concept checks work with this file
15 #ifdef _GLIBCPP_CONCEPT_CHECKS
16 #undef _GLIBCPP_CONCEPT_CHECKS
22 #include "funcrequest.h"
25 #include "support/filetools.h"
26 #include "support/path_defines.h"
34 Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func)
36 switch (func.action) {
38 case LFUN_MENUWRITE: return Gtk::Stock::SAVE;
39 case LFUN_MENUNEW: return Gtk::Stock::NEW;
40 case LFUN_WRITEAS: return Gtk::Stock::SAVE_AS;
42 case LFUN_CENTER: return Gtk::Stock::JUSTIFY_CENTER;
43 case LFUN_TOCVIEW: return Gtk::Stock::INDEX;
44 case LFUN_CLOSEBUFFER: return Gtk::Stock::CLOSE;
45 case LFUN_QUIT: return Gtk::Stock::QUIT;
46 case LFUN_UNDO: return Gtk::Stock::UNDO;
47 case LFUN_REDO: return Gtk::Stock::REDO;
48 case LFUN_PASTE: return Gtk::Stock::PASTE;
49 case LFUN_PASTESELECTION: return Gtk::Stock::PASTE;
50 case LFUN_CUT: return Gtk::Stock::CUT;
51 case LFUN_COPY: return Gtk::Stock::COPY;
52 case LFUN_BOLD: return Gtk::Stock::BOLD;
53 case LFUN_ITAL: return Gtk::Stock::ITALIC;
54 case LFUN_FILE_OPEN: return Gtk::Stock::OPEN;
55 case LFUN_RECONFIGURE: return Gtk::Stock::REFRESH;
56 case LFUN_DIALOG_SHOW:
57 if (func.argument == "findreplace")
58 return Gtk::Stock::FIND_AND_REPLACE;
59 else if (func.argument == "print")
60 return Gtk::Stock::PRINT;
61 else if (func.argument == "spellchecker")
62 return Gtk::Stock::SPELL_CHECK;
63 else if (func.argument == "prefs")
64 return Gtk::Stock::PREFERENCES;
66 return Gtk::Stock::MISSING_IMAGE;
68 default: return Gtk::Stock::MISSING_IMAGE;
72 string const getDefaultUnit()
74 switch (lyxrc.default_papersize) {
75 case PAPER_DEFAULT: return "cm";
77 case PAPER_LEGALPAPER:
78 case PAPER_EXECUTIVEPAPER: return "in"; break;
82 case PAPER_B5PAPER: return "cm"; break;
87 void unitsComboFromLength(Gtk::ComboBox * combo,
88 Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
89 LyXLength const & len,
92 string unit = stringFromUnit(len.unit());
96 Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
97 Gtk::TreeModel::iterator end = combo->get_model()->children().end();
98 for (; it != end ; ++it) {
99 if ((*it)[stringcol] == unit) {
100 combo->set_active(it);
105 // Fallen through, we didn't find the target length!
106 combo->set_active(0);
107 lyxerr << "unitsComboFromLength: couldn't find "
108 "target unit '" << unit << "'\n";
112 vector<string> const buildLengthUnitList()
114 vector<string> data(unit_name_gui, unit_name_gui + num_units);
120 vector<string> const buildLengthNoRelUnitList()
123 for (int i = 0; i < num_units; ++i) {
124 string str(unit_name_gui[i]);
125 if (str.find("%") == -1)
126 data.push_back(unit_name_gui[i]);
133 string const findGladeFile(string const & name)
135 // First, search in the installation directories.
137 string filename = lyx::support::LibFileSearch("glade", name, "glade");
139 if (!filename.empty())
142 // Second, search in the src tree.
144 lyx::support::AddPath(lyx::support::top_srcdir(),
145 "src/frontends/gtk/glade");
147 filename = lyx::support::ChangeExtension(name, ".glade");
148 filename = lyx::support::AddName(dir, filename);
150 if (!lyx::support::IsFileReadable(filename)) {
151 lyxerr << "Unable to find glade file \"" << name
152 << "\". libglade is going to crash..." << std::endl;
158 } // namespace frontend