From c9ab63f32ece2861cac3273b87ab1db26f976f2e Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 8 Oct 2004 14:59:18 +0000 Subject: [PATCH] add ErrorList dialog, implement GViewBase::setTitle git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9067 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 6 ++ src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GErrorList.C | 94 +++++++++++++++++++ src/frontends/gtk/GErrorList.h | 53 +++++++++++ src/frontends/gtk/GViewBase.C | 7 ++ src/frontends/gtk/GViewBase.h | 1 + src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/errors.glade | 134 +++++++++++++++++++++++++++ 8 files changed, 300 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GErrorList.C create mode 100644 src/frontends/gtk/GErrorList.h create mode 100644 src/frontends/gtk/glade/errors.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 680bbafaf0..57080160b0 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,9 @@ +2004-10-08 John Spray + + * The ErrorList dialog + * Dialogs.C, GErrorList.C, GErrorList.h, Makefile.am + * GViewBase.[Ch]: implement setTitle for gtk windows. + 2004-10-06 John Spray * The Spellchecker dialog diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 83058457ac..0ab29bd2bf 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -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 index 0000000000..d642547529 --- /dev/null +++ b/src/frontends/gtk/GErrorList.C @@ -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 + +#include "GErrorList.h" +#include "ControlErrorList.h" + +#include "ghelpers.h" + +using std::string; + +namespace lyx { +namespace frontend { + +GErrorList::GErrorList(Dialog & parent) + : GViewCB(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 index 0000000000..62f7aabf60 --- /dev/null +++ b/src/frontends/gtk/GErrorList.h @@ -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 { +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 listCol_; + Gtk::TreeModelColumn listColIndex_; + Gtk::TreeModel::ColumnRecord listCols_; + + Glib::RefPtr errliststore_; + Glib::RefPtr errlistsel_; + Gtk::TreeView * errlistview_; + + Gtk::TextView * errdescview_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GERRORLIST_H diff --git a/src/frontends/gtk/GViewBase.C b/src/frontends/gtk/GViewBase.C index 5032ae0710..9103e33e8c 100644 --- a/src/frontends/gtk/GViewBase.C +++ b/src/frontends/gtk/GViewBase.C @@ -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(); diff --git a/src/frontends/gtk/GViewBase.h b/src/frontends/gtk/GViewBase.h index fda18c973e..8de3237132 100644 --- a/src/frontends/gtk/GViewBase.h +++ b/src/frontends/gtk/GViewBase.h @@ -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 diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 8b231db326..3d35d07269 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -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 index 0000000000..ccf6ad072a --- /dev/null +++ b/src/frontends/gtk/glade/errors.glade @@ -0,0 +1,134 @@ + + + + + + + 6 + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 400 + 300 + 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 + + + + + + True + True + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + 150 + True + True + False + False + False + True + + + + + True + False + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + True + True + + + + + 0 + True + True + GTK_PACK_END + + + + + + + -- 2.39.2