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.
15 #include "support/filetools.h"
21 using support::OnlyFilename;
26 GTexinfo::GTexinfo(Dialog & parent)
27 : GViewCB<ControlTexinfo, GViewGladeB>(parent, _("LaTeX Information"), false),
28 activeStyle(ControlTexinfo::cls)
32 void GTexinfo::doBuild() {
33 string const gladeName = findGladeFile("texinfo");
34 xml_ = Gnome::Glade::Xml::create(gladeName);
37 xml_->get_widget("Close", button);
40 xml_->get_widget("Refresh", button);
41 button->signal_clicked().connect(
42 sigc::mem_fun(*this, >exinfo::onRefresh));
44 xml_->get_widget("FullPath", fullpathcheck_);
45 fullpathcheck_->signal_toggled().connect(
46 sigc::mem_fun(*this, >exinfo::updateStyles));
48 // For both liststores
49 listCols_.add(listCol_);
50 listCols_.add(listColIndex_);
53 xml_->get_widget("Items", itemsview_);
54 itemsstore_ = Gtk::ListStore::create(listCols_);
55 itemsview_->set_model(itemsstore_);
56 itemsview_->append_column("Item", listCol_);
57 listSel_ = itemsview_->get_selection();
59 itemsview_->signal_row_activated().connect(
60 sigc::mem_fun(*this, >exinfo::onItemActivate));
62 // Type Selection Combobox
63 xml_->get_widget("Type", typecombo_);
64 typestore_ = Gtk::ListStore::create(listCols_);
65 typecombo_->set_model(typestore_);
66 Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText);
67 typecombo_->pack_start(*cell, true);
68 typecombo_->add_attribute(*cell, "text", 0);
69 typecombo_->signal_changed().connect(
70 sigc::mem_fun(*this, >exinfo::onTypeComboChanged));
72 Gtk::TreeModel::iterator row = typestore_->append();
73 (*row)[listCol_] = _("LaTeX classes");
74 (*row)[listColIndex_] = ControlTexinfo::cls;
75 // This is the default selection
76 typecombo_->set_active(row);
77 activeStyle = ControlTexinfo::cls;
79 row = typestore_->append();
80 (*row)[listCol_] = _("LaTeX styles");
81 (*row)[listColIndex_] = ControlTexinfo::sty;
83 row = typestore_->append();
84 (*row)[listCol_] = _("BibTeX styles");
85 (*row)[listColIndex_] = ControlTexinfo::bst;
91 void GTexinfo::onItemActivate(
92 Gtk::TreeModel::Path const & path,
93 Gtk::TreeViewColumn * col)
96 (*itemsstore_->get_iter(path))[listColIndex_];
98 ContentsType const & data = texdata_[activeStyle];
99 if (choice >= 0 && choice <= data.size() - 1)
100 controller().viewFile(data[choice]);
104 void GTexinfo::onTypeComboChanged()
106 int const typeindex =
107 (*typecombo_->get_active())[listColIndex_];
108 activeStyle = static_cast<ControlTexinfo::texFileSuffix>(typeindex);
113 void GTexinfo::onRefresh()
115 // makes sense only if the rights are set well for
116 // users (/var/lib/texmf/ls-R)
123 void GTexinfo::updateStyles()
125 ContentsType & data = texdata_[activeStyle];
126 getTexFileList(activeStyle, data);
128 bool const withFullPath = fullpathcheck_->get_active();
130 itemsstore_->clear();
131 ContentsType::const_iterator it = data.begin();
132 ContentsType::const_iterator end = data.end();
133 for (int rowindex = 0; it != end; ++it, ++rowindex) {
134 string const line = withFullPath ? *it : OnlyFilename(*it);
135 Gtk::TreeModel::iterator row = itemsstore_->append();
136 (*row)[listCol_] = line;
137 (*row)[listColIndex_] = rowindex;
141 } // namespace frontend