--- /dev/null
+/**
+ * \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.
+ */
+
+#include "GTexinfo.h"
+
+#include "ghelpers.h"
+
+#include "support/filetools.h"
+
+using std::string;
+
+namespace lyx {
+
+using support::OnlyFilename;
+
+namespace frontend {
+
+
+GTexinfo::GTexinfo(Dialog & parent)
+ : GViewCB<ControlTexinfo, GViewGladeB>(parent, _("LaTeX Information"), false),
+ 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,
+ Gtk::TreeViewColumn * col)
+{
+ int const choice =
+ (*itemsstore_->get_iter(path))[listColIndex_];
+
+ ContentsType const & data = texdata_[activeStyle];
+ if (choice >= 0 && choice <= data.size() - 1)
+ controller().viewFile(data[choice]);
+}
+
+
+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];
+ getTexFileList(activeStyle, data);
+
+ bool const withFullPath = fullpathcheck_->get_active();
+
+ itemsstore_->clear();
+ ContentsType::const_iterator it = data.begin();
+ ContentsType::const_iterator end = data.end();
+ for (int rowindex = 0; it != end; ++it, ++rowindex) {
+ string const line = withFullPath ? *it : OnlyFilename(*it);
+ Gtk::TreeModel::iterator row = itemsstore_->append();
+ (*row)[listCol_] = line;
+ (*row)[listColIndex_] = rowindex;
+ }
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="dialog">
+ <property name="title" translatable="yes">Lyx: LaTeX Information</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="modal">False</property>
+ <property name="default_width">200</property>
+ <property name="default_height">400</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="Close">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkComboBox" id="Type">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="FullPath">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show the full path instead of just the file name</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show Full _Path</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">6</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">6</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTreeView" id="Items">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Double click to view contents of file</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="Refresh">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Build new file lists</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-refresh</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Refresh List</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">6</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>