From 7e2062974178bd0e20288f21cdb054b11edf4060 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 14 Nov 2004 18:26:16 +0000 Subject: [PATCH] GTK ERT dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9240 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 2 + src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GERT.C | 93 ++++++++++++++++ src/frontends/gtk/GERT.h | 43 ++++++++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/glade/ERT.glade | 172 ++++++++++++++++++++++++++++++ 6 files changed, 315 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GERT.C create mode 100644 src/frontends/gtk/GERT.h create mode 100644 src/frontends/gtk/glade/ERT.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 7844882a65..8d9721f039 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,5 +1,7 @@ 2004-11-14 John Spray + * The ERT dialog: + Dialogs.C, Makefile.am, GERT.C, GERT.h * The Box dialog: Dialogs.C, Makefile.am, GBox.C, GBox.h * ghelpers.[Ch], GGraphics.[Ch]: new functions unitsComboFromLength diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 3636288878..7d7460d112 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -61,7 +61,7 @@ #include "FormCitation.h" #include "FormDocument.h" #include "GErrorList.h" -#include "FormERT.h" +#include "GERT.h" #include "FormExternal.h" #include "FormFloat.h" #include "GGraphics.h" @@ -218,8 +218,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GErrorList(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "ert") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlERT(*dialog)); - dialog->setView(new FormERT(*dialog)); + dialog->setView(new GERT(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "external") { dialog->setController(new ControlExternal(*dialog)); diff --git a/src/frontends/gtk/GERT.C b/src/frontends/gtk/GERT.C new file mode 100644 index 0000000000..2b558db8ac --- /dev/null +++ b/src/frontends/gtk/GERT.C @@ -0,0 +1,93 @@ +/** + * \file GERT.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 + +#include "GERT.h" +#include "ControlERT.h" +#include "ghelpers.h" + +#include + +using std::string; + +namespace lyx { +namespace frontend { + +GERT::GERT(Dialog & parent) + : GViewCB(parent, _("TeX Settings"), false) +{} + + +void GERT::doBuild() +{ + string const gladeName = findGladeFile("ERT"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * cancelbutton; + xml_->get_widget("Close", cancelbutton); + setCancel(cancelbutton); + + xml_->get_widget("Inline", inlineradio_); + xml_->get_widget("Open", openradio_); + xml_->get_widget("Collapsed", collapsedradio_); + + inlineradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GERT::apply)); + openradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GERT::apply)); + collapsedradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GERT::apply)); + + bcview().addReadOnly(inlineradio_); + bcview().addReadOnly(openradio_); + bcview().addReadOnly(collapsedradio_); +} + + +void GERT::update() +{ + applylock_ = true; + + bc().refreshReadOnly(); + + switch (controller().status()) { + case InsetERT::Open: + openradio_->set_active(true); + break; + case InsetERT::Collapsed: + collapsedradio_->set_active(true); + break; + case InsetERT::Inlined: + inlineradio_->set_active(true); + break; + } + + applylock_ = false; +} + + +void GERT::apply() +{ + if (applylock_) + return; + + if (openradio_->get_active()) + controller().setStatus(InsetERT::Open); + else if (collapsedradio_->get_active()) + controller().setStatus(InsetERT::Collapsed); + else + controller().setStatus(InsetERT::Inlined); + + controller().dispatchParams(); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GERT.h b/src/frontends/gtk/GERT.h new file mode 100644 index 0000000000..7c7f3b7cdb --- /dev/null +++ b/src/frontends/gtk/GERT.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +/** + * \file GERT.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 GERT_H +#define GERT_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlERT; + +/** This class provides a GTK+ implementation of the ERT Dialog. + */ +class GERT : public GViewCB { +public: + GERT(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + // apply() won't act when this is true + bool applylock_; + + Gtk::RadioButton * inlineradio_; + Gtk::RadioButton * openradio_; + Gtk::RadioButton * collapsedradio_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GERT_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 331fdcfa40..a5274cf42c 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -32,6 +32,8 @@ libgtk_la_SOURCES = \ GCharacter.h \ GErrorList.C \ GErrorList.h \ + GERT.C \ + GERT.h \ GGraphics.C \ GGraphics.h \ GLog.C \ @@ -116,7 +118,6 @@ xforms_objects = \ ../xforms/FormColorpicker.lo \ ../xforms/FormDialogView.lo \ ../xforms/FormDocument.lo \ - ../xforms/FormERT.lo \ ../xforms/FormExternal.lo \ ../xforms/FormFloat.lo \ ../xforms/FormInclude.lo \ diff --git a/src/frontends/gtk/glade/ERT.glade b/src/frontends/gtk/glade/ERT.glade new file mode 100644 index 0000000000..a9d06524a4 --- /dev/null +++ b/src/frontends/gtk/glade/ERT.glade @@ -0,0 +1,172 @@ + + + + + + + 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-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + True + _Open + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Collapsed + True + GTK_RELIEF_NORMAL + True + False + False + True + Open + + + 0 + False + False + + + + + + True + True + _Inline + True + GTK_RELIEF_NORMAL + True + False + False + True + Open + + + 0 + False + False + + + + + + + + + + True + <b>Display</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + +