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/package.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;
73 string const getDefaultUnit()
75 switch (lyxrc.default_papersize) {
76 case PAPER_DEFAULT: return "cm";
78 case PAPER_LEGALPAPER:
79 case PAPER_EXECUTIVEPAPER: return "in"; break;
83 case PAPER_B5PAPER: return "cm"; break;
90 void unitsComboFromLength(Gtk::ComboBox * combo,
91 Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
92 LyXLength const & len,
95 string unit = stringFromUnit(len.unit());
99 Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
100 Gtk::TreeModel::iterator end = combo->get_model()->children().end();
101 for (; it != end ; ++it) {
102 if ((*it)[stringcol] == unit) {
103 combo->set_active(it);
108 // Fallen through, we didn't find the target length!
109 combo->set_active(0);
110 lyxerr << "unitsComboFromLength: couldn't find "
111 "target unit '" << unit << "'\n";
115 vector<string> const buildLengthUnitList()
117 vector<string> data(unit_name_gui, unit_name_gui + num_units);
123 vector<string> const buildLengthNoRelUnitList()
126 for (int i = 0; i < num_units; ++i) {
127 string str(unit_name_gui[i]);
128 if (str.find("%") == string::npos)
129 data.push_back(unit_name_gui[i]);
136 string const findGladeFile(string const & name)
138 // First, search in the installation directories.
140 string filename = lyx::support::LibFileSearch("glade", name, "glade");
142 if (!filename.empty())
145 // Second, search in the src tree.
147 lyx::support::AddPath(lyx::support::package().top_srcdir(),
148 "src/frontends/gtk/glade");
150 filename = lyx::support::ChangeExtension(name, ".glade");
151 filename = lyx::support::AddName(dir, filename);
153 if (!lyx::support::IsFileReadable(filename)) {
154 lyxerr << "Unable to find glade file \"" << name
155 << "\". libglade is going to crash..." << std::endl;
161 } // namespace frontend