From 0e976314ed38639270daa24e5215e038cdb98af3 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 9 Oct 2004 07:51:37 +0000 Subject: [PATCH] Add ShowFile dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9070 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 +- src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GShowFile.C | 57 ++++++++++++++++ src/frontends/gtk/GShowFile.h | 45 ++++++++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/showfile.glade | 94 ++++++++++++++++++++++++++ 6 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 src/frontends/gtk/GShowFile.C create mode 100644 src/frontends/gtk/GShowFile.h create mode 100644 src/frontends/gtk/glade/showfile.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 9131900e61..bd052e0b4c 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,10 +1,9 @@ 2004-10-08 John Spray + * The ShowFile dialog + * Dialogs.C, GShowFile.C, GShowFile.h, Makefile.am * The Texinfo dialog * Dialogs.C, GTexinfo.C, GTexinfo.h, Makefile.am - -2004-10-08 John Spray - * The ErrorList dialog * Dialogs.C, GErrorList.C, GErrorList.h, Makefile.am * GViewBase.[Ch]: implement setTitle for gtk windows. diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 7a636c2a63..acec2d72ca 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -82,7 +82,7 @@ #include "FormSendto.h" #include "FormTabular.h" #include "GTexinfo.h" -#include "FormShowFile.h" +#include "GShowFile.h" #include "GSpellchecker.h" #include "GTableCreate.h" #include "GToc.h" @@ -224,8 +224,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormExternal(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "file") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlShowFile(*dialog)); - dialog->setView(new FormShowFile(*dialog)); + dialog->setView(new GShowFile(*dialog)); dialog->bc().bp(new OkCancelPolicy); } else if (name == "findreplace") { dialog->bc().view(new GBC(dialog->bc())); diff --git a/src/frontends/gtk/GShowFile.C b/src/frontends/gtk/GShowFile.C new file mode 100644 index 0000000000..fb9a452f59 --- /dev/null +++ b/src/frontends/gtk/GShowFile.C @@ -0,0 +1,57 @@ +/** + * \file GShowFile.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 "GShowFile.h" +#include "ControlShowFile.h" + +#include "ghelpers.h" + +using std::string; + +namespace lyx { +namespace frontend { + +GShowFile::GShowFile(Dialog & parent) + : GViewCB(parent, _("Show File"), false) +{} + + +void GShowFile::doBuild() +{ + string const gladeName = findGladeFile("showfile"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * closebutton; + xml_->get_widget("Close", closebutton); + setCancel(closebutton); + + Gtk::TextView * contentview; + xml_->get_widget("ContentView", contentview); + contentbuffer_ = contentview->get_buffer(); +} + + +void GShowFile::update() +{ + string const title = controller().getFileName(); + + if (!title.empty()) + setTitle(title); + + string const contents = controller().getFileContents(); + + if (!contents.empty()) + contentbuffer_->set_text(contents); + else + contentbuffer_->set_text(_("Error reading file!")); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GShowFile.h b/src/frontends/gtk/GShowFile.h new file mode 100644 index 0000000000..9d8a8e4b40 --- /dev/null +++ b/src/frontends/gtk/GShowFile.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +/** + * \file GShowFile.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 GSHOWFILE_H +#define GSHOWFILE_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlShowFile; + +/** + * This class provides a GTK+ implementation of a dialog to browse through a + * text file. + */ +class GShowFile : public GViewCB { +public: + /// + GShowFile(Dialog &); + + // Functions accessible to the Controller. + + virtual void doBuild(); + /// Set the Params variable for the Controller. + virtual void apply() {} + /// Update dialog before/whilst showing it. + virtual void update(); + + Glib::RefPtr contentbuffer_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GFILE_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index bf7ceeb65e..81f0092ea5 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -50,6 +50,8 @@ libgtk_la_SOURCES = \ GScreen.h \ GSearch.C \ GSearch.h \ + GShowFile.C \ + GShowFile.h \ GSpellchecker.C \ GSpellchecker.h \ GTableCreate.C \ @@ -124,7 +126,6 @@ xforms_objects = \ ../xforms/FormRef.lo \ ../xforms/FormSendto.lo \ ../xforms/forms_gettext.lo \ - ../xforms/FormShowFile.lo \ ../xforms/FormTabular.lo \ ../xforms/FormText.lo \ ../xforms/FormThesaurus.lo \ diff --git a/src/frontends/gtk/glade/showfile.glade b/src/frontends/gtk/glade/showfile.glade new file mode 100644 index 0000000000..73c08c1fd5 --- /dev/null +++ b/src/frontends/gtk/glade/showfile.glade @@ -0,0 +1,94 @@ + + + + + + + 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-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