]> git.lyx.org Git - lyx.git/commitdiff
Add gtk Texinfo dialog
authorJohn Spray <spray@lyx.org>
Fri, 8 Oct 2004 18:21:42 +0000 (18:21 +0000)
committerJohn Spray <spray@lyx.org>
Fri, 8 Oct 2004 18:21:42 +0000 (18:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9069 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gtk/ChangeLog
src/frontends/gtk/Dialogs.C
src/frontends/gtk/GTexinfo.C [new file with mode: 0644]
src/frontends/gtk/GTexinfo.h [new file with mode: 0644]
src/frontends/gtk/Makefile.am
src/frontends/gtk/glade/texinfo.glade [new file with mode: 0644]

index 57080160b0ae5833ac750c92e54009a3bcef0fb5..9131900e61eaa4babe7a32dbb5adca8e2ac70d36 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-08  John Spray  <spray_john@users.sourceforge.net>
+
+       * The Texinfo dialog
+       * Dialogs.C, GTexinfo.C, GTexinfo.h, Makefile.am
+
 2004-10-08  John Spray  <spray_john@users.sourceforge.net>
 
        * The ErrorList dialog
index 0ab29bd2bf9e243f0e05c7921eaf1d9aa7356ef6..7a636c2a6343cfcd379ad037abf211fa32ee4382 100644 (file)
@@ -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 (file)
index 0000000..9058a42
--- /dev/null
@@ -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<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, &GTexinfo::onRefresh));
+
+       xml_->get_widget("FullPath", fullpathcheck_);
+       fullpathcheck_->signal_toggled().connect(
+               sigc::mem_fun(*this, &GTexinfo::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, &GTexinfo::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, &GTexinfo::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
diff --git a/src/frontends/gtk/GTexinfo.h b/src/frontends/gtk/GTexinfo.h
new file mode 100644 (file)
index 0000000..186d8ec
--- /dev/null
@@ -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 <map>
+
+namespace lyx {
+namespace frontend {
+
+class GTexinfo
+       : public GViewCB<ControlTexinfo, GViewGladeB> {
+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<Glib::ustring> listCol_;
+       Gtk::TreeModelColumn<unsigned int> listColIndex_;
+       Gtk::TreeModel::ColumnRecord listCols_;
+       Glib::RefPtr<Gtk::ListStore> itemsstore_;
+       Glib::RefPtr<Gtk::ListStore> typestore_;
+       Glib::RefPtr<Gtk::TreeSelection> listSel_;
+
+       Gtk::CheckButton * fullpathcheck_;
+
+       void onTypeComboChanged();
+       void onItemActivate(Gtk::TreeModel::Path const & path, Gtk::TreeViewColumn * col);
+       void onRefresh();
+
+       typedef std::vector<std::string> ContentsType;
+       std::map<ControlTexinfo::texFileSuffix, ContentsType> texdata_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GTEXINFO_H
index 3d35d0726902f1df33a0727372f4672c668e39da..bf7ceeb65eb7a68f102c5cd0366f4dab0c3c1dbf 100644 (file)
@@ -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 (file)
index 0000000..66dc813
--- /dev/null
@@ -0,0 +1,218 @@
+<?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>