From 3a79aaab3f02c87fe04aa5db3f40d289aaf1940b Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 7 Dec 2004 00:29:15 +0000 Subject: [PATCH] gtk include dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9353 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 5 + src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GInclude.C | 162 ++++++++ src/frontends/gtk/GInclude.h | 48 +++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/include.glade | 537 ++++++++++++++++++++++++++ 6 files changed, 757 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GInclude.C create mode 100644 src/frontends/gtk/GInclude.h create mode 100644 src/frontends/gtk/glade/include.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index e548186502..3fbfbb1287 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2004-12-07 John Spray + + * The Include Dialog: + Dialogs.C, Makefile.am, GInclude.[Ch], glade/include.glade + 2004-12-05 Lars Gullik Bjønnes * glade/Makefile.am: clean up a bit diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index ffc926049f..0cee527094 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -70,7 +70,7 @@ #include "FormExternal.h" #include "GFloat.h" #include "GGraphics.h" -#include "FormInclude.h" +#include "GInclude.h" #include "GLog.h" #include "GMathPanel.h" #include "FormMathsBitmap.h" @@ -252,8 +252,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GGraphics(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "include") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlInclude(*dialog)); - dialog->setView(new FormInclude(*dialog)); + dialog->setView(new GInclude(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "index") { dialog->bc().view(new GBC(dialog->bc())); diff --git a/src/frontends/gtk/GInclude.C b/src/frontends/gtk/GInclude.C new file mode 100644 index 0000000000..95c89597c9 --- /dev/null +++ b/src/frontends/gtk/GInclude.C @@ -0,0 +1,162 @@ +/** + * \file GInclude.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 + +// Too hard to make concept checks work with this file +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GInclude.h" +#include "ControlInclude.h" +#include "ghelpers.h" + +#include + +using std::string; +using std::vector; + +namespace lyx { +namespace frontend { + +GInclude::GInclude(Dialog & parent) + : GViewCB(parent, _("Child Document"), false) +{} + + +void GInclude::doBuild() +{ + string const gladeName = findGladeFile("include"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * button; + xml_->get_widget("Cancel", button); + setCancel(button); + xml_->get_widget("Ok", button); + setOK(button); + + xml_->get_widget("Browse", button); + button->signal_clicked().connect( + sigc::mem_fun(*this, &GInclude::onBrowseClicked)); + + xml_->get_widget("Open", openbutton_); + openbutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GInclude::onOpenClicked)); + + xml_->get_widget("Include", includeradio_); + xml_->get_widget("Input", inputradio_); + xml_->get_widget("Verbatim", verbatimradio_); + xml_->get_widget("File", fileentry_); + xml_->get_widget("MarkSpaces", markspacescheck_); + xml_->get_widget("Preview", previewcheck_); + + inputradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GInclude::onTypeToggled)); + includeradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GInclude::onTypeToggled)); + verbatimradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GInclude::onTypeToggled)); +} + + +void GInclude::update() +{ + string const filename = controller().params().getContents(); + fileentry_->set_text(filename); + + string const cmdname = controller().params().getCmdName(); + + bool const inputCommand = (cmdname == "input" || cmdname.empty()); + bool const includeCommand = cmdname == "include"; + bool const verbatimStarCommand = cmdname == "verbatiminput*"; + bool const verbatimCommand = cmdname == "verbatiminput"; + + bool const preview = static_cast((controller().params().preview())); + + previewcheck_->set_sensitive(inputCommand); + previewcheck_->set_active(inputCommand ? preview : false); + + if (inputCommand) + inputradio_->set_active(true); + + if (includeCommand) + includeradio_->set_active(true); + + if (verbatimCommand || verbatimStarCommand) { + verbatimradio_->set_active(true); + markspacescheck_->set_active(verbatimStarCommand); + markspacescheck_->set_sensitive(true); + openbutton_->set_sensitive(false); + } else { + markspacescheck_->set_active(false); + markspacescheck_->set_sensitive(false); + openbutton_->set_sensitive(true); + } + + bc().valid(); +} + + +void GInclude::apply() +{ + InsetCommandParams params = controller().params(); + + params.preview(previewcheck_->get_active()); + params.setContents(fileentry_->get_text()); + + if (includeradio_->get_active()) + params.setCmdName("include"); + else if (inputradio_->get_active()) + params.setCmdName("input"); + else + if (markspacescheck_->get_active()) + params.setCmdName("verbatiminput*"); + else + params.setCmdName("verbatiminput"); + + controller().setParams(params); +} + + +void GInclude::onTypeToggled() +{ + previewcheck_->set_sensitive(inputradio_->get_active()); + markspacescheck_->set_sensitive(verbatimradio_->get_active()); + openbutton_->set_sensitive(!verbatimradio_->get_active()); +} + + +void GInclude::onBrowseClicked() +{ + ControlInclude::Type type; + if (includeradio_->get_active()) + type = ControlInclude::INCLUDE; + else if (inputradio_->get_active()) + type = ControlInclude::INPUT; + else + type = ControlInclude::VERBATIM; + + fileentry_->set_text(controller().browse(fileentry_->get_text(), type)); +} + + +void GInclude::onOpenClicked() +{ + string const in_name = fileentry_->get_text(); + if (!in_name.empty() && controller().fileExists(in_name)) { + dialog().OKButton(); + controller().load(in_name); + } +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GInclude.h b/src/frontends/gtk/GInclude.h new file mode 100644 index 0000000000..0c75191830 --- /dev/null +++ b/src/frontends/gtk/GInclude.h @@ -0,0 +1,48 @@ +// -*- C++ -*- +/** + * \file GInclude.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 GINCLUDE_H +#define GINCLUDE_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlInclude; + +/** This class provides a GTK+ implementation of the Include Dialog. + */ +class GInclude : public GViewCB { +public: + GInclude(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + Gtk::RadioButton * includeradio_; + Gtk::RadioButton * inputradio_; + Gtk::RadioButton * verbatimradio_; + Gtk::Entry * fileentry_; + Gtk::Button * openbutton_; + Gtk::CheckButton * markspacescheck_; + Gtk::CheckButton * previewcheck_; + + void onBrowseClicked(); + void onOpenClicked(); + void onTypeToggled(); +}; + +} // namespace frontend +} // namespace lyx + +#endif // GINCLUDE_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 5c4b676b25..8a088141f8 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -39,6 +39,8 @@ libgtk_la_SOURCES = \ GERT.h \ GFloat.C \ GFloat.h \ + GInclude.C \ + GInclude.h \ GGraphics.C \ GGraphics.h \ GLog.C \ @@ -130,7 +132,6 @@ xforms_objects = \ ../xforms/FormDialogView.lo \ ../xforms/FormDocument.lo \ ../xforms/FormExternal.lo \ - ../xforms/FormInclude.lo \ ../xforms/FormMathsBitmap.lo \ ../xforms/FormMathsDelim.lo \ ../xforms/FormMathsSpace.lo \ diff --git a/src/frontends/gtk/glade/include.glade b/src/frontends/gtk/glade/include.glade new file mode 100644 index 0000000000..35e3317847 --- /dev/null +++ b/src/frontends/gtk/glade/include.glade @@ -0,0 +1,537 @@ + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + 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-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + False + 0 + + + + True + <b>File</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + 2 + 3 + False + 6 + 5 + + + + True + _Filename: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + File + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + File name to include + True + True + True + 0 + + True + * + True + + + 1 + 2 + 0 + 1 + + + + + + + True + Browse directories for file name + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Browse + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + Open the file + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + O_pen + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 1 + 2 + fill + + + + + + + + 0 + True + True + + + + + + True + <b>Include Type</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + False + 0 + + + + True + Use LaTeX \input + True + _Input + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + Use LaTeX \include + True + I_nclude + True + GTK_RELIEF_NORMAL + True + False + False + True + Input + + + 0 + False + False + + + + + + True + Use LaTeX \verbatiminput + True + _Verbatim + True + GTK_RELIEF_NORMAL + True + False + False + True + Input + + + 0 + False + False + + + + + + + 0 + True + True + + + + + + True + <b>Options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + False + 0 + + + + True + Underline spaces in generated output + True + _Mark spaces in output + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + Show LaTeX preview + True + _Display preview + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + -- 2.39.2