3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
25 #include "support/filetools.h"
31 using support::OnlyFilename;
36 GTexinfo::GTexinfo(Dialog & parent)
37 : GViewCB<ControlTexinfo, GViewGladeB>(parent, _("TeX Information"), false),
38 activeStyle(ControlTexinfo::cls)
42 void GTexinfo::doBuild() {
43 string const gladeName = findGladeFile("texinfo");
44 xml_ = Gnome::Glade::Xml::create(gladeName);
47 xml_->get_widget("Close", button);
50 xml_->get_widget("Refresh", button);
51 button->signal_clicked().connect(
52 sigc::mem_fun(*this, >exinfo::onRefresh));
54 xml_->get_widget("FullPath", fullpathcheck_);
55 fullpathcheck_->signal_toggled().connect(
56 sigc::mem_fun(*this, >exinfo::updateStyles));
58 // For both liststores
59 listCols_.add(listCol_);
60 listCols_.add(listColIndex_);
63 xml_->get_widget("Items", itemsview_);
64 itemsstore_ = Gtk::ListStore::create(listCols_);
65 itemsview_->set_model(itemsstore_);
66 itemsview_->append_column("Item", listCol_);
67 listSel_ = itemsview_->get_selection();
69 itemsview_->signal_row_activated().connect(
70 sigc::mem_fun(*this, >exinfo::onItemActivate));
72 // Type Selection Combobox
73 xml_->get_widget("Type", typecombo_);
74 typestore_ = Gtk::ListStore::create(listCols_);
75 typecombo_->set_model(typestore_);
76 Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText);
77 typecombo_->pack_start(*cell, true);
78 typecombo_->add_attribute(*cell, "text", 0);
79 typecombo_->signal_changed().connect(
80 sigc::mem_fun(*this, >exinfo::onTypeComboChanged));
82 Gtk::TreeModel::iterator row = typestore_->append();
83 (*row)[listCol_] = _("LaTeX classes");
84 (*row)[listColIndex_] = ControlTexinfo::cls;
85 // This is the default selection
86 typecombo_->set_active(row);
87 activeStyle = ControlTexinfo::cls;
89 row = typestore_->append();
90 (*row)[listCol_] = _("LaTeX styles");
91 (*row)[listColIndex_] = ControlTexinfo::sty;
93 row = typestore_->append();
94 (*row)[listCol_] = _("BibTeX styles");
95 (*row)[listColIndex_] = ControlTexinfo::bst;
101 void GTexinfo::onItemActivate(
102 Gtk::TreeModel::Path const & path,
103 Gtk::TreeViewColumn * /* col */)
106 (*itemsstore_->get_iter(path))[listColIndex_];
108 ContentsType const & data = texdata_[activeStyle];
110 string file = data[choice];
111 if (!fullpathcheck_->get_active())
112 file = getTexFileFromList(data[choice],
113 controller().getFileType(activeStyle));
115 if (choice >= 0 && choice <= data.size() - 1)
116 controller().viewFile(file);
120 void GTexinfo::onTypeComboChanged()
122 int const typeindex =
123 (*typecombo_->get_active())[listColIndex_];
124 activeStyle = static_cast<ControlTexinfo::texFileSuffix>(typeindex);
129 void GTexinfo::onRefresh()
131 // makes sense only if the rights are set well for
132 // users (/var/lib/texmf/ls-R)
139 void GTexinfo::updateStyles()
141 ContentsType & data = texdata_[activeStyle];
142 bool const withFullPath = fullpathcheck_->get_active();
143 getTexFileList(activeStyle, data, withFullPath);
145 itemsstore_->clear();
146 ContentsType::const_iterator it = data.begin();
147 ContentsType::const_iterator end = data.end();
148 for (int rowindex = 0; it != end; ++it, ++rowindex) {
149 Gtk::TreeModel::iterator row = itemsstore_->append();
150 (*row)[listCol_] = *it;
151 (*row)[listColIndex_] = rowindex;
155 } // namespace frontend