From e8b0d829e7e0b75873c19983c9d9250cfd603cc0 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 8 Oct 2004 18:21:42 +0000 Subject: [PATCH] Add gtk Texinfo dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9069 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 + src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GTexinfo.C | 142 +++++++++++++++++ src/frontends/gtk/GTexinfo.h | 63 ++++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/texinfo.glade | 218 ++++++++++++++++++++++++++ 6 files changed, 433 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GTexinfo.C create mode 100644 src/frontends/gtk/GTexinfo.h create mode 100644 src/frontends/gtk/glade/texinfo.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 57080160b0..9131900e61 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2004-10-08 John Spray + + * The Texinfo dialog + * Dialogs.C, GTexinfo.C, GTexinfo.h, Makefile.am + 2004-10-08 John Spray * The ErrorList dialog diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 0ab29bd2bf..7a636c2a63 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -81,7 +81,7 @@ #include "GSearch.h" #include "FormSendto.h" #include "FormTabular.h" -#include "FormTexinfo.h" +#include "GTexinfo.h" #include "FormShowFile.h" #include "GSpellchecker.h" #include "GTableCreate.h" @@ -494,8 +494,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GTableCreate(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "texinfo") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlTexinfo(*dialog)); - dialog->setView(new FormTexinfo(*dialog)); + dialog->setView(new GTexinfo(*dialog)); dialog->bc().bp(new OkCancelPolicy); #ifdef HAVE_LIBAIKSAURUS } else if (name == "thesaurus") { diff --git a/src/frontends/gtk/GTexinfo.C b/src/frontends/gtk/GTexinfo.C new file mode 100644 index 0000000000..9058a42495 --- /dev/null +++ b/src/frontends/gtk/GTexinfo.C @@ -0,0 +1,142 @@ +/** + * \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(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(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 diff --git a/src/frontends/gtk/GTexinfo.h b/src/frontends/gtk/GTexinfo.h new file mode 100644 index 0000000000..186d8ecc2f --- /dev/null +++ b/src/frontends/gtk/GTexinfo.h @@ -0,0 +1,63 @@ +// -*- C++ -*- +/** + * \file GTexinfo.h + * 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. + */ + +#ifndef GTEXINFO_H +#define GTEXINFO_H + +#include "ControlTexinfo.h" + +#include "GViewBase.h" + +#include + +namespace lyx { +namespace frontend { + +class GTexinfo + : public GViewCB { +public: + + GTexinfo(Dialog &); +private: + // not needed + virtual void apply() {} + // Build the dialog. + virtual void doBuild(); + // not needed + virtual void update() {} + + void updateStyles(); + + ControlTexinfo::texFileSuffix activeStyle; + + Gtk::TreeView * itemsview_; + Gtk::ComboBox * typecombo_; + Gtk::TreeModelColumn listCol_; + Gtk::TreeModelColumn listColIndex_; + Gtk::TreeModel::ColumnRecord listCols_; + Glib::RefPtr itemsstore_; + Glib::RefPtr typestore_; + Glib::RefPtr listSel_; + + Gtk::CheckButton * fullpathcheck_; + + void onTypeComboChanged(); + void onItemActivate(Gtk::TreeModel::Path const & path, Gtk::TreeViewColumn * col); + void onRefresh(); + + typedef std::vector ContentsType; + std::map texdata_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GTEXINFO_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 3d35d07269..bf7ceeb65e 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -54,6 +54,8 @@ libgtk_la_SOURCES = \ GSpellchecker.h \ GTableCreate.C \ GTableCreate.h \ + GTexinfo.C \ + GTexinfo.h \ GText.C \ GText.h \ GTimeout.C \ @@ -124,7 +126,6 @@ xforms_objects = \ ../xforms/forms_gettext.lo \ ../xforms/FormShowFile.lo \ ../xforms/FormTabular.lo \ - ../xforms/FormTexinfo.lo \ ../xforms/FormText.lo \ ../xforms/FormThesaurus.lo \ ../xforms/FormVSpace.lo \ diff --git a/src/frontends/gtk/glade/texinfo.glade b/src/frontends/gtk/glade/texinfo.glade new file mode 100644 index 0000000000..66dc813751 --- /dev/null +++ b/src/frontends/gtk/glade/texinfo.glade @@ -0,0 +1,218 @@ + + + + + + + Lyx: LaTeX Information + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + 200 + 400 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + + + 0 + True + True + + + + + + True + Show the full path instead of just the file name + True + Show Full _Path + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 6 + False + False + + + + + 6 + False + True + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + Double click to view contents of file + True + False + False + False + True + + + + + 0 + True + True + + + + + + True + Build new file lists + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-refresh + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Refresh List + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 6 + False + False + + + + + 0 + True + True + + + + + + + -- 2.39.2