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.
17 #include "funcrequest.h"
20 #include "support/filetools.h"
21 #include "support/path_defines.h"
29 Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func)
31 switch (func.action) {
33 case LFUN_MENUWRITE: return Gtk::Stock::SAVE;
34 case LFUN_MENUNEW: return Gtk::Stock::NEW;
35 case LFUN_WRITEAS: return Gtk::Stock::SAVE_AS;
37 case LFUN_CENTER: return Gtk::Stock::JUSTIFY_CENTER;
38 case LFUN_TOCVIEW: return Gtk::Stock::INDEX;
39 case LFUN_CLOSEBUFFER: return Gtk::Stock::CLOSE;
40 case LFUN_QUIT: return Gtk::Stock::QUIT;
41 case LFUN_UNDO: return Gtk::Stock::UNDO;
42 case LFUN_REDO: return Gtk::Stock::REDO;
43 case LFUN_PASTE: return Gtk::Stock::PASTE;
44 case LFUN_PASTESELECTION: return Gtk::Stock::PASTE;
45 case LFUN_CUT: return Gtk::Stock::CUT;
46 case LFUN_COPY: return Gtk::Stock::COPY;
47 case LFUN_BOLD: return Gtk::Stock::BOLD;
48 case LFUN_ITAL: return Gtk::Stock::ITALIC;
49 case LFUN_FILE_OPEN: return Gtk::Stock::OPEN;
50 case LFUN_RECONFIGURE: return Gtk::Stock::REFRESH;
51 case LFUN_DIALOG_SHOW:
52 if (func.argument == "findreplace")
53 return Gtk::Stock::FIND_AND_REPLACE;
54 else if (func.argument == "print")
55 return Gtk::Stock::PRINT;
56 else if (func.argument == "spellchecker")
57 return Gtk::Stock::SPELL_CHECK;
58 else if (func.argument == "prefs")
59 return Gtk::Stock::PREFERENCES;
61 return Gtk::Stock::MISSING_IMAGE;
63 default: return Gtk::Stock::MISSING_IMAGE;
67 string const getDefaultUnit()
69 switch (lyxrc.default_papersize) {
70 case PAPER_DEFAULT: return "cm";
72 case PAPER_LEGALPAPER:
73 case PAPER_EXECUTIVEPAPER: return "in"; break;
77 case PAPER_B5PAPER: return "cm"; break;
82 void unitsComboFromLength(Gtk::ComboBox * combo,
83 Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
84 LyXLength const & len,
87 string unit = stringFromUnit(len.unit());
91 Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
92 Gtk::TreeModel::iterator end = combo->get_model()->children().end();
93 for (; it != end ; ++it) {
94 if ((*it)[stringcol] == unit) {
95 combo->set_active(it);
100 // Fallen through, we didn't find the target length!
101 combo->set_active(0);
102 lyxerr << "unitsComboFromLength: couldn't find "
103 "target unit '" << unit << "'\n";
107 vector<string> const buildLengthUnitList()
109 vector<string> data(unit_name_gui, unit_name_gui + num_units);
115 vector<string> const buildLengthNoRelUnitList()
118 for (int i = 0; i < num_units; ++i) {
119 string str(unit_name_gui[i]);
120 if (str.find("%") == -1)
121 data.push_back(unit_name_gui[i]);
128 string const findGladeFile(string const & name)
130 // First, search in the installation directories.
132 string filename = lyx::support::LibFileSearch("glade", name, "glade");
134 if (!filename.empty())
137 // Second, search in the src tree.
139 lyx::support::AddPath(lyx::support::top_srcdir(),
140 "src/frontends/gtk/glade");
142 filename = lyx::support::ChangeExtension(name, ".glade");
143 filename = lyx::support::AddName(dir, filename);
145 if (!lyx::support::IsFileReadable(filename)) {
146 lyxerr << "Unable to find glade file \"" << name
147 << "\". libglade is going to crash..." << std::endl;
153 } // namespace frontend