From 2c7c49ad8b135e3feed488bc5646acd7b7e888a5 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 9 Oct 2004 13:51:05 +0000 Subject: [PATCH] Add GTK Log view dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9071 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 ++ src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GLog.C | 64 ++++++++++++++++++ src/frontends/gtk/GLog.h | 43 ++++++++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/log.glade | 107 ++++++++++++++++++++++++++++++ 6 files changed, 224 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GLog.C create mode 100644 src/frontends/gtk/GLog.h create mode 100644 src/frontends/gtk/glade/log.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index bd052e0b4c..46a03b456e 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2004-10-09 John Spray + + * The Log dialog + * Dialogs.C, GLog.C, GLog.h, Makefile.am, glade/log.glade + 2004-10-08 John Spray * The ShowFile dialog diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index acec2d72ca..ee877a9364 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -66,7 +66,7 @@ #include "FormFloat.h" #include "FormGraphics.h" #include "FormInclude.h" -#include "FormLog.h" +#include "GLog.h" #include "GMathPanel.h" #include "FormMathsBitmap.h" #include "GMathsMatrix.h" @@ -258,8 +258,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) _("Label"), _("Label:|#L"))); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "log") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlLog(*dialog)); - dialog->setView(new FormLog(*dialog)); + dialog->setView(new GLog(*dialog)); dialog->bc().bp(new OkCancelPolicy); } else if (name == "mathpanel") { diff --git a/src/frontends/gtk/GLog.C b/src/frontends/gtk/GLog.C new file mode 100644 index 0000000000..7fb0cf6b81 --- /dev/null +++ b/src/frontends/gtk/GLog.C @@ -0,0 +1,64 @@ +/** + * \file GLog.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 "GLog.h" +#include "ControlLog.h" + +#include "ghelpers.h" + +#include + +using std::string; + +namespace lyx { +namespace frontend { + +GLog::GLog(Dialog & parent) + : GViewCB(parent, _("Log Viewer"), false) +{} + + +void GLog::doBuild() +{ + string const gladeName = findGladeFile("log"); + 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, &GLog::update)); + + Gtk::TextView * contentview; + xml_->get_widget("ContentView", contentview); + contentbuffer_ = contentview->get_buffer(); +} + + +void GLog::update() +{ + string const title = controller().title(); + + if (!title.empty()) + setTitle(title); + + std::ostringstream contents; + controller().getContents(contents); + + if (!contents.str().empty()) + contentbuffer_->set_text(contents.str()); + else + contentbuffer_->set_text(_("Error reading file!")); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GLog.h b/src/frontends/gtk/GLog.h new file mode 100644 index 0000000000..c4b96967f5 --- /dev/null +++ b/src/frontends/gtk/GLog.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +/** + * \file GLog.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 GLOG_H +#define GLOG_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlLog; + +/** + * This class provides a GTK+ implementation of a dialog to browse through a + * log file. + */ +class GLog : public GViewCB { +public: + GLog(Dialog &); + + // Create the dialog + virtual void doBuild(); + // Set the Params variable for the Controller. + virtual void apply() {} + // Update dialog (load log into textbuffer) + virtual void update(); + + Glib::RefPtr contentbuffer_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GLOG_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 81f0092ea5..456c586cf6 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -28,6 +28,8 @@ libgtk_la_SOURCES = \ GCharacter.h \ GErrorList.C \ GErrorList.h \ + GLog.C \ + GLog.h \ GLyXKeySym.C \ GLyXKeySym.h \ GMathDelim.C \ @@ -115,7 +117,6 @@ xforms_objects = \ ../xforms/FormFloat.lo \ ../xforms/FormGraphics.lo \ ../xforms/FormInclude.lo \ - ../xforms/FormLog.lo \ ../xforms/FormMathsBitmap.lo \ ../xforms/FormMathsDelim.lo \ ../xforms/FormMathsSpace.lo \ diff --git a/src/frontends/gtk/glade/log.glade b/src/frontends/gtk/glade/log.glade new file mode 100644 index 0000000000..dcb952523c --- /dev/null +++ b/src/frontends/gtk/glade/log.glade @@ -0,0 +1,107 @@ + + + + + + + 6 + You shouldn't see this + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 550 + 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-refresh + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + + + -- 2.39.2