2004-10-08 18:21:42 +00:00
|
|
|
/**
|
|
|
|
* \file GTexinfo.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Spray
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2005-04-26 10:30:24 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2005-01-29 15:09:14 +00:00
|
|
|
// Too hard to make concept checks work with this file
|
|
|
|
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
|
|
|
#undef _GLIBCXX_CONCEPT_CHECKS
|
|
|
|
#endif
|
2005-04-26 10:30:24 +00:00
|
|
|
#ifdef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#undef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#endif
|
2005-01-29 15:09:14 +00:00
|
|
|
|
2004-10-08 18:21:42 +00:00
|
|
|
#include "GTexinfo.h"
|
|
|
|
|
|
|
|
#include "ghelpers.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2006-04-08 22:31:11 +00:00
|
|
|
using support::onlyFilename;
|
2004-10-08 18:21:42 +00:00
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
|
|
|
GTexinfo::GTexinfo(Dialog & parent)
|
2005-05-19 18:53:09 +00:00
|
|
|
: GViewCB<ControlTexinfo, GViewGladeB>(parent, _("TeX Information"), false),
|
2004-10-08 18:21:42 +00:00
|
|
|
activeStyle(ControlTexinfo::cls)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void GTexinfo::doBuild() {
|
|
|
|
string const gladeName = findGladeFile("texinfo");
|
|
|
|
xml_ = Gnome::Glade::Xml::create(gladeName);
|
|
|
|
|
|
|
|
Gtk::Button * button;
|
|
|
|
xml_->get_widget("Close", button);
|
|
|
|
setCancel(button);
|
|
|
|
|
|
|
|
xml_->get_widget("Refresh", button);
|
|
|
|
button->signal_clicked().connect(
|
|
|
|
sigc::mem_fun(*this, >exinfo::onRefresh));
|
|
|
|
|
|
|
|
xml_->get_widget("FullPath", fullpathcheck_);
|
|
|
|
fullpathcheck_->signal_toggled().connect(
|
|
|
|
sigc::mem_fun(*this, >exinfo::updateStyles));
|
|
|
|
|
|
|
|
// For both liststores
|
|
|
|
listCols_.add(listCol_);
|
|
|
|
listCols_.add(listColIndex_);
|
|
|
|
|
|
|
|
// Items ListView
|
|
|
|
xml_->get_widget("Items", itemsview_);
|
|
|
|
itemsstore_ = Gtk::ListStore::create(listCols_);
|
|
|
|
itemsview_->set_model(itemsstore_);
|
|
|
|
itemsview_->append_column("Item", listCol_);
|
|
|
|
listSel_ = itemsview_->get_selection();
|
|
|
|
|
|
|
|
itemsview_->signal_row_activated().connect(
|
|
|
|
sigc::mem_fun(*this, >exinfo::onItemActivate));
|
|
|
|
|
|
|
|
// Type Selection Combobox
|
|
|
|
xml_->get_widget("Type", typecombo_);
|
|
|
|
typestore_ = Gtk::ListStore::create(listCols_);
|
|
|
|
typecombo_->set_model(typestore_);
|
|
|
|
Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText);
|
|
|
|
typecombo_->pack_start(*cell, true);
|
|
|
|
typecombo_->add_attribute(*cell, "text", 0);
|
|
|
|
typecombo_->signal_changed().connect(
|
|
|
|
sigc::mem_fun(*this, >exinfo::onTypeComboChanged));
|
|
|
|
|
|
|
|
Gtk::TreeModel::iterator row = typestore_->append();
|
|
|
|
(*row)[listCol_] = _("LaTeX classes");
|
|
|
|
(*row)[listColIndex_] = ControlTexinfo::cls;
|
|
|
|
// This is the default selection
|
|
|
|
typecombo_->set_active(row);
|
|
|
|
activeStyle = ControlTexinfo::cls;
|
|
|
|
|
|
|
|
row = typestore_->append();
|
|
|
|
(*row)[listCol_] = _("LaTeX styles");
|
|
|
|
(*row)[listColIndex_] = ControlTexinfo::sty;
|
|
|
|
|
|
|
|
row = typestore_->append();
|
|
|
|
(*row)[listCol_] = _("BibTeX styles");
|
|
|
|
(*row)[listColIndex_] = ControlTexinfo::bst;
|
|
|
|
|
|
|
|
updateStyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GTexinfo::onItemActivate(
|
|
|
|
Gtk::TreeModel::Path const & path,
|
2005-01-29 15:09:14 +00:00
|
|
|
Gtk::TreeViewColumn * /* col */)
|
2004-10-08 18:21:42 +00:00
|
|
|
{
|
|
|
|
int const choice =
|
|
|
|
(*itemsstore_->get_iter(path))[listColIndex_];
|
|
|
|
|
|
|
|
ContentsType const & data = texdata_[activeStyle];
|
2005-07-27 17:46:15 +00:00
|
|
|
|
|
|
|
string file = data[choice];
|
|
|
|
if (!fullpathcheck_->get_active())
|
|
|
|
file = getTexFileFromList(data[choice],
|
|
|
|
controller().getFileType(activeStyle));
|
|
|
|
|
2004-10-08 18:21:42 +00:00
|
|
|
if (choice >= 0 && choice <= data.size() - 1)
|
2005-07-27 17:46:15 +00:00
|
|
|
controller().viewFile(file);
|
2004-10-08 18:21:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GTexinfo::onTypeComboChanged()
|
|
|
|
{
|
|
|
|
int const typeindex =
|
|
|
|
(*typecombo_->get_active())[listColIndex_];
|
|
|
|
activeStyle = static_cast<ControlTexinfo::texFileSuffix>(typeindex);
|
|
|
|
updateStyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GTexinfo::onRefresh()
|
|
|
|
{
|
|
|
|
// makes sense only if the rights are set well for
|
|
|
|
// users (/var/lib/texmf/ls-R)
|
|
|
|
texhash();
|
|
|
|
rescanTexStyles();
|
|
|
|
updateStyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GTexinfo::updateStyles()
|
|
|
|
{
|
|
|
|
ContentsType & data = texdata_[activeStyle];
|
|
|
|
bool const withFullPath = fullpathcheck_->get_active();
|
2005-07-27 17:46:15 +00:00
|
|
|
getTexFileList(activeStyle, data, withFullPath);
|
2004-10-08 18:21:42 +00:00
|
|
|
|
|
|
|
itemsstore_->clear();
|
|
|
|
ContentsType::const_iterator it = data.begin();
|
|
|
|
ContentsType::const_iterator end = data.end();
|
|
|
|
for (int rowindex = 0; it != end; ++it, ++rowindex) {
|
|
|
|
Gtk::TreeModel::iterator row = itemsstore_->append();
|
2005-07-27 17:46:15 +00:00
|
|
|
(*row)[listCol_] = *it;
|
2004-10-08 18:21:42 +00:00
|
|
|
(*row)[listColIndex_] = rowindex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|