Hi, Hot on the heels of the previous dialog (these are small ones, and take no time), here's the ShowFile dialog.
John
? tmp Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/ChangeLog,v retrieving revision 1.72 diff -u -p -r1.72 ChangeLog --- ChangeLog 8 Oct 2004 18:21:42 -0000 1.72 +++ ChangeLog 8 Oct 2004 18:27:03 -0000 @@ -1,10 +1,9 @@ 2004-10-08 John Spray <[EMAIL PROTECTED]> + * 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 <[EMAIL PROTECTED]> - * The ErrorList dialog * Dialogs.C, GErrorList.C, GErrorList.h, Makefile.am * GViewBase.[Ch]: implement setTitle for gtk windows. Index: Dialogs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Dialogs.C,v retrieving revision 1.27 diff -u -p -r1.27 Dialogs.C --- Dialogs.C 8 Oct 2004 18:21:42 -0000 1.27 +++ Dialogs.C 8 Oct 2004 18:27:03 -0000 @@ -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 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())); Index: GShowFile.C =================================================================== RCS file: GShowFile.C diff -N GShowFile.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ GShowFile.C 8 Oct 2004 18:27:03 -0000 @@ -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<ControlShowFile, GViewGladeB>(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 Index: GShowFile.h =================================================================== RCS file: GShowFile.h diff -N GShowFile.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ GShowFile.h 8 Oct 2004 18:27:03 -0000 @@ -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<ControlShowFile, GViewGladeB> { +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<Gtk::TextBuffer> contentbuffer_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GFILE_H Index: Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Makefile.am,v retrieving revision 1.25 diff -u -p -r1.25 Makefile.am --- Makefile.am 8 Oct 2004 18:21:42 -0000 1.25 +++ Makefile.am 8 Oct 2004 18:27:03 -0000 @@ -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 \ Index: glade/showfile.glade =================================================================== RCS file: glade/showfile.glade diff -N glade/showfile.glade --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ glade/showfile.glade 8 Oct 2004 18:27:03 -0000 @@ -0,0 +1,94 @@ +<?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">You shouldn't see this</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">550</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="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="GtkTextView" id="ContentView"> + <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_NONE</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="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface>