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];
109 if (choice >= 0 && choice <= data.size() - 1)
110 controller().viewFile(data[choice]);
114 void GTexinfo::onTypeComboChanged()
116 int const typeindex =
117 (*typecombo_->get_active())[listColIndex_];
118 activeStyle = static_cast<ControlTexinfo::texFileSuffix>(typeindex);
123 void GTexinfo::onRefresh()
125 // makes sense only if the rights are set well for
126 // users (/var/lib/texmf/ls-R)
133 void GTexinfo::updateStyles()
135 ContentsType & data = texdata_[activeStyle];
136 getTexFileList(activeStyle, data);
138 bool const withFullPath = fullpathcheck_->get_active();
140 itemsstore_->clear();
141 ContentsType::const_iterator it = data.begin();
142 ContentsType::const_iterator end = data.end();
143 for (int rowindex = 0; it != end; ++it, ++rowindex) {
144 string const line = withFullPath ? *it : OnlyFilename(*it);
145 Gtk::TreeModel::iterator row = itemsstore_->append();
146 (*row)[listCol_] = line;
147 (*row)[listColIndex_] = rowindex;
151 } // namespace frontend