]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/ghelpers.h
Menu icons, gtk stock icons in toolbar
[lyx.git] / src / frontends / gtk / ghelpers.h
1 // -*- C++ -*-
2 /**
3  * \file ghelpers.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GHELPERS_H
13 #define GHELPERS_H
14
15 #include "lengthcommon.h"
16
17 #include <gtkmm.h>
18
19 #include <string>
20 #include <vector>
21
22 class FuncRequest;
23
24 namespace lyx {
25 namespace frontend {
26
27 // Get a GTK stockID from a lyx function id.
28 // Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
29 Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func);
30
31 std::string const getDefaultUnit();
32
33 void unitsComboFromLength(Gtk::ComboBox * combo,
34                            Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
35                            LyXLength const & len,
36                            std::string defunit);
37
38 std::vector<std::string> const buildLengthUnitList();
39
40 /** name is the name of the glade file, without path or extension.
41  *  Eg, "aboutlyx", "tableCreate".
42  */
43 std::string const findGladeFile(std::string const & name);
44
45 template<class A>
46 typename std::vector<A>::size_type
47 findPos(std::vector<A> const & vec, A const & val)
48 {
49         typename std::vector<A>::const_iterator it =
50                 std::find(vec.begin(), vec.end(), val);
51         if (it == vec.end())
52                 return 0;
53         return std::distance(vec.begin(), it);
54 }
55
56 } // namespace frontend
57 } // namespace lyx
58
59 #endif // NOT GHELPERS_H