]> git.lyx.org Git - features.git/commitdiff
add ErrorList dialog, implement GViewBase::setTitle
authorJohn Spray <spray@lyx.org>
Fri, 8 Oct 2004 14:59:18 +0000 (14:59 +0000)
committerJohn Spray <spray@lyx.org>
Fri, 8 Oct 2004 14:59:18 +0000 (14:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9067 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 680bbafaf082d7a38493c6495151d1c06c33f10d..57080160b0ae5833ac750c92e54009a3bcef0fb5 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-08  John Spray  <spray_john@users.sourceforge.net>
+
+       * The ErrorList dialog
+       * Dialogs.C, GErrorList.C, GErrorList.h, Makefile.am
+       * GViewBase.[Ch]: implement setTitle for gtk windows.
+
 2004-10-06  John Spray  <spray_john@users.sourceforge.net>
 
        * The Spellchecker dialog
index 83058457acd4653b1f000709b548a4b98b949882..0ab29bd2bf9e243f0e05c7921eaf1d9aa7356ef6 100644 (file)
@@ -60,7 +60,7 @@
 #include "GCharacter.h"
 #include "FormCitation.h"
 #include "FormDocument.h"
-#include "FormErrorList.h"
+#include "GErrorList.h"
 #include "FormERT.h"
 #include "FormExternal.h"
 #include "FormFloat.h"
@@ -211,8 +211,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
                dialog->setView(new FormDocument(*dialog));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
        } else if (name == "errorlist") {
+               dialog->bc().view(new GBC(dialog->bc()));
                dialog->setController(new ControlErrorList(*dialog));
-               dialog->setView(new FormErrorList(*dialog));
+               dialog->setView(new GErrorList(*dialog));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
        } else if (name == "ert") {
                dialog->setController(new ControlERT(*dialog));
diff --git a/src/frontends/gtk/GErrorList.C b/src/frontends/gtk/GErrorList.C
new file mode 100644 (file)
index 0000000..d642547
--- /dev/null
@@ -0,0 +1,94 @@
+/**
+ * \file GErrorList.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 <config.h>
+
+#include "GErrorList.h"
+#include "ControlErrorList.h"
+
+#include "ghelpers.h"
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+GErrorList::GErrorList(Dialog & parent)
+       : GViewCB<ControlErrorList, GViewGladeB>(parent, _("Errors"), false)
+{}
+
+
+void GErrorList::doBuild()
+{
+       string const gladeName = findGladeFile("errors");
+       xml_ = Gnome::Glade::Xml::create(gladeName);
+
+       Gtk::Button * closebutton;
+       xml_->get_widget("Close", closebutton);
+       setCancel(closebutton);
+
+       xml_->get_widget("ErrorList", errlistview_);
+       listCols_.add(listCol_);
+       listCols_.add(listColIndex_);
+       errliststore_ = Gtk::ListStore::create(listCols_);
+       errlistview_->set_model(errliststore_);
+       errlistview_->append_column("Error", listCol_);
+       errlistsel_ = errlistview_->get_selection();
+
+       xml_->get_widget("ErrorDescription", errdescview_);
+
+       errlistsel_->signal_changed().connect(
+               sigc::mem_fun(*this, &GErrorList::onErrListSelection));
+}
+
+
+void GErrorList::update()
+{
+  setTitle(controller().name());
+       updateContents();
+}
+
+
+void GErrorList::onErrListSelection()
+{
+       int const choice =
+               (*errlistsel_->get_selected())[listColIndex_];
+
+       ErrorList const & errors = controller().errorList();
+       errdescview_->get_buffer()->set_text(errors[choice].description);
+}
+
+
+void GErrorList::updateContents()
+{
+       errliststore_->clear();
+       ErrorList const & errors = controller().errorList();
+       if (errors.empty()) {
+               (*errliststore_->append())[listCol_] = _("*** No Errors ***");
+               errlistview_->set_sensitive(false);
+               return;
+       }
+
+       errlistview_->set_sensitive(true);
+
+       ErrorList::const_iterator cit = errors.begin();
+       ErrorList::const_iterator end = errors.end();
+       for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
+               Gtk::ListStore::Row row = *errliststore_->append();
+               if (rowindex == 0)
+                       errlistsel_->select(*row);
+
+               (*row)[listCol_] = cit->error;
+               (*row)[listColIndex_] = rowindex;
+       }
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/gtk/GErrorList.h b/src/frontends/gtk/GErrorList.h
new file mode 100644 (file)
index 0000000..62f7aab
--- /dev/null
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+/**
+ * \file GErrorList.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 GERRORLIST_H
+#define GERRORLIST_H
+
+#include "GViewBase.h"
+
+namespace lyx {
+namespace frontend {
+
+class ControlErrorList;
+
+/** This class provides a GTK+ implementation of the ErrorList Dialog.
+ */
+class GErrorList : public GViewCB<ControlErrorList, GViewGladeB> {
+public:
+       ///
+       GErrorList(Dialog &);
+private:
+       /// not needed
+       virtual void apply() {}
+       /// Build the dialog
+       virtual void doBuild();
+       /// Update dialog before showing it
+       virtual void update();
+
+       void updateContents();
+       void onErrListSelection();
+
+       Gtk::TreeModelColumn<Glib::ustring> listCol_;
+       Gtk::TreeModelColumn<int> listColIndex_;
+       Gtk::TreeModel::ColumnRecord listCols_;
+
+       Glib::RefPtr<Gtk::ListStore> errliststore_;
+       Glib::RefPtr<Gtk::TreeSelection> errlistsel_;
+       Gtk::TreeView * errlistview_;
+
+       Gtk::TextView * errdescview_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GERRORLIST_H
index 5032ae07104222cf00359d857a471344cc2c86d1..9103e33e8c2c15145e7c958aa8376ec3190f1f7c 100644 (file)
@@ -102,6 +102,13 @@ void GViewBase::setRestore(Gtk::Button * restore)
 }
 
 
+void GViewBase::setTitle(std::string const & title)
+{
+       Dialog::View::setTitle(title);
+       window()->set_title(title);
+}
+
+
 bool GViewBase::readOnly() const
 {
        return kernel().isBufferReadonly();
index fda18c973e8a55ea2221dd9d3bd1029a9ff86fb3..8de32371329be4dcc89ceaa781123418d7a1af91 100644 (file)
@@ -32,6 +32,7 @@ public:
        void setApply(Gtk::Button * apply);
        void setOK(Gtk::Button * ok);
        void setRestore(Gtk::Button * restore);
+       void setTitle(std::string const &);
        bool readOnly() const;
 protected:
        // Build the dialog
index 8b231db32656b3fee4886f3a7b0b6738e6a5d5ea..3d35d0726902f1df33a0727372f4672c668e39da 100644 (file)
@@ -26,6 +26,8 @@ libgtk_la_SOURCES = \
        GBC.h \
        GCharacter.C \
        GCharacter.h \
+       GErrorList.C \
+       GErrorList.h \
        GLyXKeySym.C \
        GLyXKeySym.h \
        GMathDelim.C \
@@ -104,7 +106,6 @@ xforms_objects = \
        ../xforms/FormColorpicker.lo \
        ../xforms/FormDialogView.lo \
        ../xforms/FormDocument.lo \
-       ../xforms/FormErrorList.lo \
        ../xforms/FormERT.lo \
        ../xforms/FormExternal.lo \
        ../xforms/FormFloat.lo \
diff --git a/src/frontends/gtk/glade/errors.glade b/src/frontends/gtk/glade/errors.glade
new file mode 100644 (file)
index 0000000..ccf6ad0
--- /dev/null
@@ -0,0 +1,134 @@
+<?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="border_width">6</property>
+  <property name="title" translatable="yes">dialog1</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="default_width">400</property>
+  <property name="default_height">300</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>
+             <accelerator key="Escape" modifiers="0" signal="clicked"/>
+           </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="GtkVPaned" id="vpaned1">
+         <property name="visible">True</property>
+         <property name="can_focus">True</property>
+
+         <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_AUTOMATIC</property>
+             <property name="shadow_type">GTK_SHADOW_IN</property>
+             <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+             <child>
+               <widget class="GtkTreeView" id="ErrorList">
+                 <property name="width_request">150</property>
+                 <property name="visible">True</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="shrink">True</property>
+             <property name="resize">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkScrolledWindow" id="scrolledwindow2">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+             <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+             <property name="shadow_type">GTK_SHADOW_IN</property>
+             <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+             <child>
+               <widget class="GtkTextView" id="ErrorDescription">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="editable">False</property>
+                 <property name="overwrite">False</property>
+                 <property name="accepts_tab">True</property>
+                 <property name="justification">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap_mode">GTK_WRAP_WORD</property>
+                 <property name="cursor_visible">False</property>
+                 <property name="pixels_above_lines">0</property>
+                 <property name="pixels_below_lines">0</property>
+                 <property name="pixels_inside_wrap">0</property>
+                 <property name="left_margin">0</property>
+                 <property name="right_margin">0</property>
+                 <property name="indent">0</property>
+                 <property name="text" translatable="yes"></property>
+               </widget>
+             </child>
+           </widget>
+           <packing>
+             <property name="shrink">True</property>
+             <property name="resize">True</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>