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.
11 // Too hard to make concept checks work with this file
12 #ifdef _GLIBCXX_CONCEPT_CHECKS
13 #undef _GLIBCXX_CONCEPT_CHECKS
20 #include "support/filetools.h"
26 using support::OnlyFilename;
31 GTexinfo::GTexinfo(Dialog & parent)
32 : GViewCB<ControlTexinfo, GViewGladeB>(parent, _("LaTeX Information"), false),
33 activeStyle(ControlTexinfo::cls)
37 void GTexinfo::doBuild() {
38 string const gladeName = findGladeFile("texinfo");
39 xml_ = Gnome::Glade::Xml::create(gladeName);
42 xml_->get_widget("Close", button);
45 xml_->get_widget("Refresh", button);
46 button->signal_clicked().connect(
47 sigc::mem_fun(*this, >exinfo::onRefresh));
49 xml_->get_widget("FullPath", fullpathcheck_);
50 fullpathcheck_->signal_toggled().connect(
51 sigc::mem_fun(*this, >exinfo::updateStyles));
53 // For both liststores
54 listCols_.add(listCol_);
55 listCols_.add(listColIndex_);
58 xml_->get_widget("Items", itemsview_);
59 itemsstore_ = Gtk::ListStore::create(listCols_);
60 itemsview_->set_model(itemsstore_);
61 itemsview_->append_column("Item", listCol_);
62 listSel_ = itemsview_->get_selection();
64 itemsview_->signal_row_activated().connect(
65 sigc::mem_fun(*this, >exinfo::onItemActivate));
67 // Type Selection Combobox
68 xml_->get_widget("Type", typecombo_);
69 typestore_ = Gtk::ListStore::create(listCols_);
70 typecombo_->set_model(typestore_);
71 Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText);
72 typecombo_->pack_start(*cell, true);
73 typecombo_->add_attribute(*cell, "text", 0);
74 typecombo_->signal_changed().connect(
75 sigc::mem_fun(*this, >exinfo::onTypeComboChanged));
77 Gtk::TreeModel::iterator row = typestore_->append();
78 (*row)[listCol_] = _("LaTeX classes");
79 (*row)[listColIndex_] = ControlTexinfo::cls;
80 // This is the default selection
81 typecombo_->set_active(row);
82 activeStyle = ControlTexinfo::cls;
84 row = typestore_->append();
85 (*row)[listCol_] = _("LaTeX styles");
86 (*row)[listColIndex_] = ControlTexinfo::sty;
88 row = typestore_->append();
89 (*row)[listCol_] = _("BibTeX styles");
90 (*row)[listColIndex_] = ControlTexinfo::bst;
96 void GTexinfo::onItemActivate(
97 Gtk::TreeModel::Path const & path,
98 Gtk::TreeViewColumn * /* col */)
101 (*itemsstore_->get_iter(path))[listColIndex_];
103 ContentsType const & data = texdata_[activeStyle];
104 if (choice >= 0 && choice <= data.size() - 1)
105 controller().viewFile(data[choice]);
109 void GTexinfo::onTypeComboChanged()
111 int const typeindex =
112 (*typecombo_->get_active())[listColIndex_];
113 activeStyle = static_cast<ControlTexinfo::texFileSuffix>(typeindex);
118 void GTexinfo::onRefresh()
120 // makes sense only if the rights are set well for
121 // users (/var/lib/texmf/ls-R)
128 void GTexinfo::updateStyles()
130 ContentsType & data = texdata_[activeStyle];
131 getTexFileList(activeStyle, data);
133 bool const withFullPath = fullpathcheck_->get_active();
135 itemsstore_->clear();
136 ContentsType::const_iterator it = data.begin();
137 ContentsType::const_iterator end = data.end();
138 for (int rowindex = 0; it != end; ++it, ++rowindex) {
139 string const line = withFullPath ? *it : OnlyFilename(*it);
140 Gtk::TreeModel::iterator row = itemsstore_->append();
141 (*row)[listCol_] = line;
142 (*row)[listColIndex_] = rowindex;
146 } // namespace frontend