]> git.lyx.org Git - lyx.git/commitdiff
Add ShowFile dialog
authorJohn Spray <spray@lyx.org>
Sat, 9 Oct 2004 07:51:37 +0000 (07:51 +0000)
committerJohn Spray <spray@lyx.org>
Sat, 9 Oct 2004 07:51:37 +0000 (07:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9070 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 9131900e61eaa4babe7a32dbb5adca8e2ac70d36..bd052e0b4ca7ff8de872e3a171c064a5b87eebe9 100644 (file)
@@ -1,10 +1,9 @@
 2004-10-08  John Spray  <spray_john@users.sourceforge.net>
 
+       * 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  <spray_john@users.sourceforge.net>
-
        * The ErrorList dialog
        * Dialogs.C, GErrorList.C, GErrorList.h, Makefile.am
        * GViewBase.[Ch]: implement setTitle for gtk windows.
index 7a636c2a6343cfcd379ad037abf211fa32ee4382..acec2d72ca3b5477900ca2efbfa46de3c3a8e0a0 100644 (file)
@@ -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 (file)
index 0000000..fb9a452
--- /dev/null
@@ -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
diff --git a/src/frontends/gtk/GShowFile.h b/src/frontends/gtk/GShowFile.h
new file mode 100644 (file)
index 0000000..9d8a8e4
--- /dev/null
@@ -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 bf7ceeb65eb7a68f102c5cd0366f4dab0c3c1dbf..81f0092ea5301fe47ade411beb1bff26a5dbeaed 100644 (file)
@@ -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 (file)
index 0000000..73c08c1
--- /dev/null
@@ -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>