]> git.lyx.org Git - features.git/commitdiff
port the graphics dialog to the new scheme and get rid of the ControlInset
authorAngus Leeming <leeming@lyx.org>
Fri, 7 Mar 2003 18:44:57 +0000 (18:44 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 7 Mar 2003 18:44:57 +0000 (18:44 +0000)
template.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6382 a592a061-630c-0410-9148-cb99ea01b6c8

37 files changed:
lib/ChangeLog
lib/ui/default.ui
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/ToolbarDefaults.C
src/commandtags.h
src/factory.C
src/frontends/ChangeLog
src/frontends/Dialogs.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlGraphics.h
src/frontends/controllers/ControlInset.h [deleted file]
src/frontends/controllers/ControlInset.tmpl [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/guiapi.C
src/frontends/guiapi.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/Dialogs2.C
src/frontends/qt2/Dialogs3.C
src/frontends/qt2/Dialogs_impl.h
src/frontends/qt2/QGraphics.C
src/frontends/qt2/QGraphics.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/Dialogs2.C
src/frontends/xforms/Dialogs3.C
src/frontends/xforms/Dialogs_impl.h
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/forms/form_graphics.fd
src/insets/ChangeLog
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/lyxfunc.C

index d33faa1ec4edb983a8c12b3db4a62b30981fe6d0..11c8a93ce2f49046a7e90f4947e9ca72444e6a7e 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * ui/default.ui: use 'dialog-show-new-inset "graphics"' instead
+       of graphics-insert'.
+
 2003-03-06  Serge Winitzki  <serge@cosmos.phy.tufts.edu>
 
        * bind/sciword.bind: update for 1.3.x 
index bca98fcebc052e10065a9fe45f0c2b218a9782a1..0b732bc561ceb827db5d38bd17783df619d63a2a 100644 (file)
@@ -209,7 +209,7 @@ Menuset
        Separator
        Item "TeX|T" "ert-insert"
        Item "Minipage|p" "minipage-insert"
-       Item "Graphics...|G" "graphics-insert"
+       Item "Graphics...|G" "dialog-show-new-inset graphics"
        Item "Tabular Material...|b" "tabular-insert"
        Submenu "Floats|a" "insert_floats"
        Separator
@@ -433,6 +433,6 @@ Toolbar
     Icon "marginalnote-insert"
     Icon "depth-increment"
     Separator
-    Icon "graphics-insert"
+    Icon "dialog-show-new-inset graphics"
     Icon "tabular-insert"
 End
index 21e40f877ee3dd188113e599537ca468f30c1f45..26a65e87ffd90fdffe50a9cc91483b130061f5dd 100644 (file)
@@ -988,19 +988,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                // a tabular-inset
                break;
 
-       case LFUN_INSET_GRAPHICS:
-       {
-               Inset * new_inset = new InsetGraphics;
-               if (!insertInset(new_inset)) {
-                       delete new_inset;
-               } else {
-                       // this is need because you don't use a inset->Edit()
-                       updateInset(new_inset, true);
-                       new_inset->edit(bv_);
-               }
-               break;
-       }
-
        case LFUN_LAYOUT_COPY:
                bv_->copyEnvironment();
                break;
index a823730dfde87906c20c330f890ebb2302891cfd..30398d7b5c99369848259966d265487ead7660bf 100644 (file)
@@ -1,4 +1,15 @@
-2003-03-05  Angus Leeming  <leeming@lyx.org>
+2003-03-07  Angus Leeming  <leeming@lyx.org>
+
+       * BufferView_pimpl.C (dispatch):
+       * LyXAction.C (init):
+       * ToolbarDefaults.C (init):
+       * commandtags.h:
+       * lyxfunc.C (getStatus):
+       remove LFUN_INSET_GRAPHICS.
+
+       * factory.C (createInset): add "graphics" to LFUN_INSET_APPLY.
+       
+2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * commandtags.h:
        * LyXAction.C (init):
index 1db9faa68de9d4329d4881df91ae2f24b0680e33..c15a482846785485c4d524d308fd315039196e02 100644 (file)
@@ -174,8 +174,6 @@ void LyXAction::init()
                  N_("Remove all error boxes"), ReadOnly },
                { LFUN_INSET_ERT, "ert-insert",
                  N_("Insert a new ERT Inset"), Noop },
-               { LFUN_INSET_GRAPHICS, "graphics-insert",
-                 N_("Insert Graphics"), Noop },
                { LFUN_FILE_INSERT, "file-insert", "", Noop },
                { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
                { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
index 224457e2bed5f6af2ee60aaeb61c80301d3a6cd9..86c5c151bbd89415c2659352f1e627238063cf45 100644 (file)
@@ -85,7 +85,7 @@ void ToolbarDefaults::init()
        add(LFUN_MATH_MODE);
        add(SEPARATOR);
 
-       add(LFUN_INSET_GRAPHICS);
+//     add(LFUN_INSET_GRAPHICS);
        add(LFUN_TABULAR_INSERT);
 }
 
index b64d711132ac9bce3712f5b39265c0a0e7c05a20..3b1969dcf6b987226fd288358a9c37166543dcb0 100644 (file)
@@ -233,7 +233,6 @@ enum kb_action {
        LFUN_DATE_INSERT,                     // jdblair 20000131
        LFUN_LANGUAGE,                  // Dekel 20000203
        LFUN_INSET_ERT,                 // Jug 20000218
-       LFUN_INSET_GRAPHICS,            // Lgb 20000226
        LFUN_INSET_FOOTNOTE,            // Jug 20000307
        LFUN_PARAGRAPH_SPACING,         // Lgb 20000411
        LFUN_TABULAR_INSERT,            // Jug 20000412
index 57e30700933bb317ae84e5ea665cdd1ee4270719..5e127756c387d119c606a9da833f7ebf30632d9e 100644 (file)
@@ -26,6 +26,7 @@
 #include "insets/insetexternal.h"
 #include "insets/insetfloat.h"
 #include "insets/insetfoot.h"
+#include "insets/insetgraphics.h"
 #include "insets/insetinclude.h"
 #include "insets/insetindex.h"
 #include "insets/insetlabel.h"
@@ -192,6 +193,14 @@ Inset * createInset(FuncRequest const & cmd)
                        inset->setFromParams(iep);
                        return inset;
 
+               } else if (name == "graphics") {
+                       InsetGraphicsParams igp;                        
+                       InsetGraphicsMailer::string2params(cmd.argument, igp);
+                       InsetGraphics * inset = new InsetGraphics;
+                       string const fpath = cmd.view()->buffer()->filePath();
+                       inset->setParams(igp, fpath);
+                       return inset;
+
                } else if (name == "include") {
                        InsetInclude::Params iip;
                        InsetIncludeMailer::string2params(cmd.argument, iip);
index 29f3bb135714b487267a9e1dc238f424b72fa3e4..20e43e7198af0d39f0cf72130d9825a6c6b74259 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-07  Angus Leeming  <leeming@lyx.org>
+
+       * Dialogs.h: remove showGraphics.
+       * guiapi.[Ch]: remove gui_showGraphics.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.h: remove showMinipage, updateMinipage.
index 745bdc13a78bd9e7a2731c4546a0f62fc35b30fa..73e90d5c1908fa9b3b530accf8eea214d1037489 100644 (file)
@@ -23,7 +23,6 @@ class Dialog;
 class InsetBase;
 class LyXView;
 
-class InsetGraphics;
 class InsetInfo;
 class Paragraph;
 class InsetTabular;
@@ -86,8 +85,6 @@ public:
        void showFile(string const &);
        /// show all forked child processes
        void showForks();
-       ///
-       void showGraphics(InsetGraphics *);
        /// show the LaTeX log or build file
        void showLogFile();
        /// display the top-level maths panel
index ce6179f0bd8b2b0910457b3ec2b8fc1207a5c21c..acc4c900525a5f3253df9bfb1a3379b116f39d87 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-07  Angus Leeming  <leeming@lyx.org>
+
+       * ControlGraphics.[Ch]: rewrite to use the Dialog-based scheme.
+
+       * ControlInset.{h, tmpl}: remove.
+       * Makefile.am: remove files.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * ControlBibitem.[Ch]:
index 5daacdea2fa367393dbb791049a73ffaf2b82f42..e87b57479dca6c9ea9218497f1ab0a1a4c3a81fd 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "buffer.h"
 #include "BufferView.h"
+#include "funcrequest.h"
 #include "gettext.h"
 #include "lyxrc.h"
 
@@ -41,40 +42,32 @@ extern string system_lyxdir;
 extern string user_lyxdir;
 
 
-ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
-       : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
+ControlGraphics::ControlGraphics(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-InsetGraphicsParams const ControlGraphics::getParams(string const &)
+void ControlGraphics::initialiseParams(string const & data)
 {
-       return InsetGraphicsParams();
+       InsetGraphicsParams params;
+       InsetGraphicsMailer::string2params(data, params);
+       params_.reset(new InsetGraphicsParams(params));
 }
 
 
-InsetGraphicsParams const
-ControlGraphics::getParams(InsetGraphics const & inset)
+void ControlGraphics::clearParams()
 {
-       return inset.params();
+       params_.reset();
 }
 
 
-void ControlGraphics::applyParamsToInset()
+void ControlGraphics::dispatchParams()
 {
-       // Set the parameters in the inset, it also returns true if the new
-       // parameters are different from what was in the inset already.
-       bool changed = inset()->setParams(params(), buffer()->filePath());
-
-       // Tell LyX we've got a change, and mark the document dirty,
-       // if it changed.
-       bufferview()->updateInset(inset(), changed);
+       string const lfun = InsetGraphicsMailer::params2string(params());
+       kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
 }
 
 
-void ControlGraphics::applyParamsNoInset()
-{}
-
-
 string const ControlGraphics::Browse(string const & in_name)
 {
        string const title = _("Select graphics file");
@@ -88,14 +81,15 @@ string const ControlGraphics::Browse(string const & in_name)
        pair<string, string> dir1(_("Clipart|#C#c"), clipdir);
        pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
        // Show the file browser dialog
-       return browseRelFile(in_name, buffer()->filePath(),
+       return browseRelFile(in_name, kernel().buffer()->filePath(),
                             title, "*.*", false, dir1, dir2);
 }
 
 
 string const ControlGraphics::readBB(string const & file)
 {
-       string const abs_file = MakeAbsPath(file, buffer()->filePath());
+       string const abs_file =
+               MakeAbsPath(file, kernel().buffer()->filePath());
 
        // try to get it from the file, if possible. Zipped files are
        // unzipped in the readBB_from_PSFile-Function
@@ -124,7 +118,7 @@ string const ControlGraphics::readBB(string const & file)
 bool ControlGraphics::isFilenameValid(string const & fname) const
 {
        // It may be that the filename is relative.
-       string const name = MakeAbsPath(fname, buffer()->filePath());
+       string const name = MakeAbsPath(fname, kernel().buffer()->filePath());
        return IsFileReadable(name);
 }
 
index 279262c9c359c1de56e4edcda579e40f1cfce17a..4f632fa91f9e4ed06ac9cebd4405023a9ae00dfa 100644 (file)
 #define CONTROLGRAPHICS_H
 
 
-#include "ControlInset.h"
-
-// needed to instatiate inset->hideDialog in ControlInset
-#include "insets/insetgraphics.h"
-
+#include "Dialog.h"
 #include <utility>
 #include <vector>
 
@@ -30,11 +26,22 @@ class LyXView;
 /** A controller for Graphics dialogs.
  */
 
-class ControlGraphics
-       : public ControlInset<InsetGraphics, InsetGraphicsParams> {
+class ControlGraphics : public Dialog::Controller {
 public:
        ///
-       ControlGraphics(LyXView &, Dialogs &);
+       ControlGraphics(Dialog &);
+       ///
+       virtual void initialiseParams(string const & data);
+       /// clean-up on hide.
+       virtual void clearParams();
+       /// clean-up on hide.
+       virtual void dispatchParams();
+       ///
+       virtual bool isBufferDependent() const { return true; }
+       ///
+       InsetGraphicsParams & params() { return *params_.get(); }
+       ///
+       InsetGraphicsParams const & params() const { return *params_.get(); }
 
        /// Browse for a file
        string const Browse(string const &);
@@ -46,14 +53,8 @@ public:
        bool isFilenameValid(string const & fname) const;
 
 private:
-       /// Dispatch the changed parameters to the kernel.
-       virtual void applyParamsToInset();
        ///
-       virtual void applyParamsNoInset();
-       /// get the parameters from the string passed to createInset.
-       virtual InsetGraphicsParams const getParams(string const &);
-       /// get the parameters from the inset passed to showInset.
-       virtual InsetGraphicsParams const getParams(InsetGraphics const &);
+       boost::scoped_ptr<InsetGraphicsParams> params_;
 };
 
 namespace frnt {
diff --git a/src/frontends/controllers/ControlInset.h b/src/frontends/controllers/ControlInset.h
deleted file mode 100644 (file)
index 99236cd..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlInset.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS
- *
- * ControlInset is to be used as a parent class for dialogs that display and
- * can perhaps modify the contents of an individual inset. An example being the
- * ubiquitous Citation dialog.
- */
-
-#ifndef CONTROLINSET_H
-#define CONTROLINSET_H
-
-#include "ControlConnections.h"
-#include "LString.h"
-
-#include <boost/signals/connection.hpp>
-
-class Inset;
-
-template <class Inset, class Params>
-class ControlInset : public ControlConnectBD {
-public:
-       ///
-       ControlInset(LyXView &, Dialogs &);
-       /// Allow the View access to the local copy.
-       Params & params();
-       ///
-       Params const & params() const;
-
-       /// Slots connected in the daughter classes c-tor.
-       /// Slot launching dialog to (possibly) create a new inset.
-       void createInset(string const &);
-       /// Slot launching dialog to an existing inset.
-       void showInset(Inset *);
-protected:
-       /// Allow the daughter methods to access the inset.
-       Inset * inset() const;
-private:
-       /** These 7 methods are all that the individual daughter classes
-           should need to instantiate. */
-
-       /// if the inset exists then do this...
-       virtual void applyParamsToInset() = 0;
-       /// else this...
-       virtual void applyParamsNoInset() = 0;
-
-       /// get the parameters from the string passed to createInset.
-       virtual Params const getParams(string const &) = 0;
-       /// get the parameters from the inset passed to showInset.
-       virtual Params const getParams(Inset const &) = 0;
-
-       /** Most derived classes won't need these two, so they default to empty.
-        */
-
-       /// set any daughter class-particular data on show().
-       virtual void setDaughterParams() {}
-       /// clean-up any daughter class-particular data on hide().
-       virtual void clearDaughterParams() {}
-
-       /** Some dialogs may find it beneficial to disconnect from the inset
-        when the Apply button is pressed. E.g., doing this with the citation
-        dialog allows multiple citiations to be inserted easily. */
-       virtual bool disconnectOnApply() { return false; }
-
-       /// Instantiation of ControlButtons virtual methods.
-
-       /// Get changed parameters and Dispatch them to the kernel.
-       virtual void apply();
-       /// Disconnect signals and hide View.
-       virtual void hide();
-       /// Update the dialog.
-       virtual void update();
-
-       /** Instantiation of ControlConnectBD private virtual method.
-           Slot connected to update signal. */
-       virtual void updateSlot(bool);
-
-       /// Show the dialog.
-       void show(Params const &);
-       /// Connect signals
-       void connectInset(Inset * = 0);
-
-       /// pointer to the inset passed through connectInset
-       Inset * inset_;
-       /// inset::hide connection.
-       boost::signals::connection ih_;
-       /** A local copy of the inset's params.
-           Memory is allocated only whilst the dialog is visible.
-       */
-       Params * params_;
-
-       /// is the dialog built ?
-       bool dialog_built_;
-};
-
-#include "ControlInset.tmpl"
-
-#endif // CONTROLINSET_H
diff --git a/src/frontends/controllers/ControlInset.tmpl b/src/frontends/controllers/ControlInset.tmpl
deleted file mode 100644 (file)
index 1918957..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ControlInset.tmpl
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS
- *
- * ControlInset is a base class and so these templatised methods will be
- * instantiated if this file is #included in the derived classes' .C file.
- */
-
-#include "ControlInset.h"
-
-#include "ButtonControllerBase.h"
-#include "ViewBase.h"
-#include "support/LAssert.h"
-
-#include <boost/bind.hpp>
-
-template <class Inset, class Params>
-ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d),
-         inset_(0), params_(0), dialog_built_(false)
-{}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::showInset(Inset * inset)
-{
-       if (inset == 0) return;  // maybe we should Assert this?
-
-       connectInset(inset);
-       show(getParams(*inset));
-
-       // The widgets may not be valid, so refresh the button controller
-       bc().refresh();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::createInset(string const & arg)
-{
-       connectInset();
-
-       if (!arg.empty())
-               bc().valid(); // so that the user can press Ok
-
-       show(getParams(arg));
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::show(Params const & params)
-{
-       // paranoia check
-       if (params_) delete params_;
-
-       params_ = new Params(params);
-       setDaughterParams();
-
-       if (emergency_exit_) {
-               hide();
-               return;
-       }
-
-       if (!dialog_built_) {
-               view().build();
-               dialog_built_ = true;
-       }
-
-       bc().readOnly(bufferIsReadonly());
-       view().show();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::update()
-{
-       // paranoia check
-       if (params_) delete params_;
-
-       if (inset_)
-               params_ = new Params(getParams(*inset_));
-       else
-               params_ = new Params();
-
-       if (emergency_exit_) {
-               hide();
-               return;
-       }
-
-       bc().readOnly(bufferIsReadonly());
-       view().update();
-
-       // The widgets may not be valid, so refresh the button controller
-       bc().refresh();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::hide()
-{
-       emergency_exit_ = false;
-       if (params_) {
-               delete params_;
-               params_ = 0;
-       }
-       inset_ = 0;
-
-       clearDaughterParams();
-
-       ih_.disconnect();
-       disconnect();
-       view().hide();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::apply()
-{
-       if (bufferIsReadonly())
-               return;
-
-       view().apply();
-
-       if (inset_) {
-               if (params() != getParams(*inset_)) {
-                       applyParamsToInset();
-               }
-       } else {
-               applyParamsNoInset();
-       }
-
-       if (disconnectOnApply() && !isClosing()) {
-               *params_ = getParams(string());
-               inset_ = 0;
-               ih_.disconnect();
-
-               view().update();
-       }
-}
-
-
-template <class Inset, class Params>
-Params & ControlInset<Inset, Params>::params()
-{
-       lyx::Assert(params_);
-       return *params_;
-}
-
-
-template <class Inset, class Params>
-Params  const & ControlInset<Inset, Params>::params() const
-{
-       lyx::Assert(params_);
-       return *params_;
-}
-
-
-template <class Inset, class Params>
-Inset * ControlInset<Inset, Params>::inset() const
-{
-       lyx::Assert(inset_);
-       return inset_;
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::connectInset(Inset * inset)
-{
-       // If connected to another inset, disconnect from it.
-       if (inset_) {
-               ih_.disconnect();
-               inset_ = 0;
-       }
-
-       if (inset) {
-               inset_ = inset;
-               ih_ = inset->hideDialog.connect(
-                       boost::bind(&ControlInset::hide, this));
-       }
-       connect();
-}
index 6751859cddf3f1861f22faccd30e4c11329c8651..fee313842da3755c17b5b68f449d13fa092cba00 100644 (file)
@@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libcontrollers.la
 INCLUDES = -I$(top_srcdir)/src \
        $(BOOST_INCLUDES)
 
-EXTRA_DIST = ButtonController.tmpl ControlDialog.tmpl ControlInset.tmpl
+EXTRA_DIST = ButtonController.tmpl ControlDialog.tmpl
 
 libcontrollers_la_SOURCES= \
        Dialog.C \
@@ -62,7 +62,6 @@ libcontrollers_la_SOURCES= \
        ControlGraphics.h \
        ControlInclude.C \
        ControlInclude.h \
-       ControlInset.h \
        ControlLog.C \
        ControlLog.h \
        ControlMath.C \
index de4d6491201eb3a7e0eb409b71c224681f4f4a40..0c1e8d9bee45db55596c70f0f65c75c6b663c6ce 100644 (file)
@@ -57,12 +57,6 @@ void gui_ShowForks(Dialogs & d)
 }
 
 
-void gui_ShowGraphics(InsetGraphics * ig, Dialogs & d)
-{
-       d.showGraphics(ig);
-}
-
-
 void gui_ShowLogFile(Dialogs & d)
 {
        d.showLogFile();
index 6e7a522f741377637536919adf76e40945e3c003..71049dda340a4f4aadbd68b030560cfafee93b9f 100644 (file)
@@ -16,7 +16,6 @@
 #include "LString.h"
 
 class Dialogs;
-class InsetGraphics;
 class InsetTabular;
 
 extern "C" {
@@ -29,7 +28,6 @@ void gui_SetUserFreeFont(Dialogs &);
 void gui_ShowDocument(Dialogs &);
 void gui_ShowFile(string const &, Dialogs &);
 void gui_ShowForks(Dialogs &);
-void gui_ShowGraphics(InsetGraphics *, Dialogs &);
 void gui_ShowLogFile(Dialogs &);
 void gui_ShowMathPanel(Dialogs &);
 void gui_ShowParagraph(Dialogs &);
index 689b03bf9b1bff7591ea8d0423f2dbd5be9bba4f..16639aeb426b8b7edcf754043da25591f81557fb 100644 (file)
@@ -3,6 +3,16 @@
        * QPrefs.C:
        * QPrefSpellcheckerModule.ui: Add 'hspell' option.
 
+2003-03-07  Angus Leeming  <leeming@lyx.org>
+
+       * Dialogs.C:
+       * Dialogs2.C:
+       * Dialogs_impl.h: remove graphics dialog.
+
+       * Dialogs3.C: add graphics dialog.
+
+       * QGraphics.[Ch]: changes to use the new Dialog-based scheme.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.C:
index 58f3987104c1368ebf6e222039d1232af8b3ee7f..05caf4c106c4e2ed9a55b399958c55f4ca310d8b 100644 (file)
@@ -31,7 +31,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
          character(lv, d),
          document(lv, d),
          file(lv, d),
-         graphics(lv, d),
          logfile(lv, d),
          paragraph(lv, d),
          prefs(lv, d),
index 45ad0bdee45a34cc080a63bf0a4471800f577782..dfcab7707b8dbfbbd6b5259019398f98ef3d1699 100644 (file)
@@ -55,12 +55,6 @@ void Dialogs::showForks()
 {}
 
 
-void Dialogs::showGraphics(InsetGraphics * ig)
-{
-       pimpl_->graphics.controller().showInset(ig);
-}
-
-
 void Dialogs::showLogFile()
 {
        pimpl_->logfile.controller().show();
index a919a669458577efff76b47b009b667af78a08d2..8c5445ee338fbb77a9d96817dbc1cd5500e4ae05 100644 (file)
@@ -19,6 +19,7 @@
 #include "ControlERT.h"
 #include "ControlExternal.h"
 #include "ControlFloat.h"
+#include "ControlGraphics.h"
 #include "ControlInclude.h"
 #include "ControlMinipage.h"
 #include "ControlRef.h"
@@ -43,6 +44,8 @@
 // of the Qt headers, those most fucked up of disgusting ratholes.
 // But I won't.
 #undef signals
+#include "QGraphics.h"
+#include "QGraphicsDialog.h"
 #include "QInclude.h"
 #include "QIncludeDialog.h"
 #include "QIndex.h"
@@ -79,8 +82,8 @@ namespace {
 
 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
                                     "error", "ert", "external", "float",
-                                    "include", "index", "label", "minipage",
-                                    "ref", "toc", "url", "wrap" };
+                                    "graphics", "include", "index", "label",
+                                    "minipage", "ref", "toc", "url", "wrap" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -140,6 +143,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlFloat(*dialog));
                dialog->setView(new QFloat(*dialog));
                dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+       } else if (name == "graphics") {
+               dialog->setController(new ControlGraphics(*dialog));
+               dialog->setView(new QGraphics(*dialog));
+               dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
        } else if (name == "include") {
                dialog->setController(new ControlInclude(*dialog));
                dialog->setView(new QInclude(*dialog));
index ad6339edbd8b26e7a82ae22a692e85e13ec4564a..3cc47d5ce7ebf5fa6635dd17535aaaa1651d4a00 100644 (file)
@@ -19,8 +19,6 @@
 #include "ControlCharacter.h"
 #include "ControlDocument.h"
 #include "ControlForks.h"
-#include "ControlGraphics.h"
-#include "insets/insetgraphicsParams.h"
 #include "ControlLog.h"
 #include "ControlParagraph.h"
 #include "ControlPrefs.h"
@@ -47,8 +45,6 @@
 // of the Qt headers, those most fucked up of disgusting ratholes.
 // But I won't.
 #undef signals
-#include "QGraphics.h"
-#include "QGraphicsDialog.h"
 #include "QLog.h"
 #include "QLogDialog.h"
 #include "QParagraph.h"
@@ -100,9 +96,6 @@ DocumentDialog;
 typedef GUI<ControlShowFile, QShowFile, OkCancelPolicy, Qt2BC>
 FileDialog;
 
-typedef GUI<ControlGraphics, QGraphics, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-GraphicsDialog;
-
 typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
 LogFileDialog;
 
@@ -150,7 +143,6 @@ struct Dialogs::Impl {
        CharacterDialog     character;
        DocumentDialog      document;
        FileDialog          file;
-       GraphicsDialog      graphics;
        LogFileDialog       logfile;
        ParagraphDialog     paragraph;
        PrefsDialog         prefs;
index 105583e550fcf0df140aa6619eb960e156935785..f644acb7feca063e557cc81e422ef5d24259b017 100644 (file)
 using std::vector;
 using std::endl;
 
-typedef Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> > base_class;
+typedef QController<ControlGraphics, QView<QGraphicsDialog> > base_class;
 
 
-QGraphics::QGraphics()
-       : base_class(qt_("LyX: Insert Graphics"))
+QGraphics::QGraphics(Dialog & parent)
+       : base_class(parent, qt_("LyX: Insert Graphics"))
 {
 }
 
index 12a781d4ab60a1bf182326625751f473f37f2e6b..5b2ba98941b5dd2142b5a179794a832733f4ec85 100644 (file)
 #define QGRAPHICS_H
 
 
-#include "insets/insetgraphics.h"
-#include "Qt2Base.h"
+#include "QDialogView.h"
+
 
 class ControlGraphics;
 class QGraphicsDialog;
 
 ///
 class QGraphics
-       : public Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> >
+       : public QController<ControlGraphics, QView<QGraphicsDialog> >
 {
 public:
        ///
        friend class QGraphicsDialog;
        ///
-       QGraphics();
+       QGraphics(Dialog &);
 protected:
        virtual bool isValid();
 private:
index 85e6838cc58f095e691c49498ae244852fd24702..3cc072a820f6e3347a0ff549aa0924314ea41d23 100644 (file)
@@ -1,3 +1,14 @@
+2003-03-07  Angus Leeming  <leeming@lyx.org>
+
+       * Dialogs.C:
+       * Dialogs2.C:
+       * Dialogs_impl.h: remove graphics dialog.
+
+       * Dialogs3.C: add graphics dialog.
+
+       * FormGraphics.[Ch]:
+       * forms/form_graphics.fd: changes to use the new Dialog-based scheme.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.C:
index 7c900ac5b0ca7494395ee3252f7cbbd56702b79c..8ed62635b24a4111a32d6c8940ae82ab45143713 100644 (file)
@@ -32,7 +32,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
          document(lv, d),
          file(lv, d),
          forks(lv, d),
-         graphics(lv, d),
          logfile(lv, d),
          mathpanel(lv, d),
          paragraph(lv, d),
index 2b0913266a61d4d06cdbc4984d2ce33c6720a838..b54b6ec09a4115eef052f69bf9b078a57f4472e1 100644 (file)
@@ -57,12 +57,6 @@ void Dialogs::showForks()
 }
 
 
-void Dialogs::showGraphics(InsetGraphics * ig)
-{
-       pimpl_->graphics.controller().showInset(ig);
-}
-
-
 void Dialogs::showLogFile()
 {
        pimpl_->logfile.controller().show();
index d77daafb03475d365b60396f04afc43f4acf2657..aa46ffec7ffaa62cb4fd65bb6859695bc913784c 100644 (file)
@@ -22,6 +22,7 @@
 #include "ControlERT.h"
 #include "ControlExternal.h"
 #include "ControlFloat.h"
+#include "ControlGraphics.h"
 #include "ControlInclude.h"
 #include "ControlMinipage.h"
 #include "ControlRef.h"
@@ -42,6 +43,8 @@
 #include "forms/form_external.h"
 #include "FormFloat.h"
 #include "forms/form_float.h"
+#include "FormGraphics.h"
+#include "forms/form_graphics.h"
 #include "FormInclude.h"
 #include "forms/form_include.h"
 #include "FormMinipage.h"
@@ -76,15 +79,11 @@ typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
 
 namespace {
 
-// char const * const dialognames[] = { "bibitem", "bibtex", "citation",
-//                                  "error", "ert", "external", "float",
-//                                  "graphics", "include", "index",
-//                                  "minipage", "ref", "tabular", "toc",
-//                                  "url", "wrap" };
 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
                                     "error", "ert", "external", "float",
-                                    "include", "index", "label", "minipage",
-                                    "ref", "toc", "url", "wrap" };
+                                    "graphics", "include", "index", "label",
+                                    "minipage", "ref", "toc", "url", "wrap" };
+
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -144,6 +143,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlFloat(*dialog));
                dialog->setView(new FormFloat(*dialog));
                dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+       } else if (name == "graphics") {
+               dialog->setController(new ControlGraphics(*dialog));
+               dialog->setView(new FormGraphics(*dialog));
+               dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
        } else if (name == "include") {
                dialog->setController(new ControlInclude(*dialog));
                dialog->setView(new FormInclude(*dialog));
index 553a04ab3c2240e3893b5def16906e3b90b5bebc..2dc7c7a851b69824355ad0f6cb69f1b5673e864d 100644 (file)
 #include "FormForks.h"
 #include "forms/form_forks.h"
 
-#include "ControlGraphics.h"
-#include "FormGraphics.h"
-#include "forms/form_graphics.h"
-
 #include "ControlLog.h"
 #include "FormLog.h"
 
@@ -122,9 +118,6 @@ FileDialog;
 typedef GUI<ControlForks, FormForks, OkApplyCancelPolicy, xformsBC>
 ForksDialog;
 
-typedef GUI<ControlGraphics, FormGraphics, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-GraphicsDialog;
-
 typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC>
 LogFileDialog;
 
@@ -178,7 +171,6 @@ struct Dialogs::Impl {
        DocumentDialog      document;
        FileDialog          file;
        ForksDialog         forks;
-       GraphicsDialog      graphics;
        LogFileDialog       logfile;
        MathPanelDialog     mathpanel;
        ParagraphDialog     paragraph;
index 7a1791d062a0939ee508dfe2e227f76ecdb84ef6..f5a29a1c8904502a063dcec2fb88b75e79d857a7 100644 (file)
@@ -55,10 +55,10 @@ string defaultUnit("cm");
 } // namespace anon
 
 
-typedef FormCB<ControlGraphics, FormDB<FD_graphics> > base_class;
+typedef FormController<ControlGraphics, FormView<FD_graphics> > base_class;
 
-FormGraphics::FormGraphics()
-       : base_class(_("Graphics"), false)
+FormGraphics::FormGraphics(Dialog & parent)
+       : base_class(parent, _("Graphics"), false)
 {}
 
 
index 49f3222e4fc1eda131daf2691d2ed68cbb4583d1..06a3f7201fa9c224182e01bd3dcf9bdd5cdf06b8 100644 (file)
@@ -14,7 +14,7 @@
 #define FORMGRAPHICS_H
 
 
-#include "FormBase.h"
+#include "FormDialogView.h"
 
 #include <boost/scoped_ptr.hpp>
 
@@ -28,10 +28,11 @@ struct FD_graphics_extra;
 
 /** This class provides an XForms implementation of the Graphics Dialog.
  */
-class FormGraphics : public FormCB<ControlGraphics, FormDB<FD_graphics> > {
+class FormGraphics
+       : public FormController<ControlGraphics, FormView<FD_graphics> > {
 public:
        ///
-       FormGraphics();
+       FormGraphics(Dialog &);
 private:
 
        /** Redraw the form (on receipt of a Signal indicating, for example,
index 1e99a19b87af38fca8949792ad9d87ed1bb6059b..97d467a24b3d80c58713edd709aea155bbc289ce 100644 (file)
@@ -64,7 +64,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthWest FL_SouthWest
 name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
 argument: 0
 
 --------------------
@@ -82,7 +82,7 @@ shortcut: ^M
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
 argument: 0
 
 --------------------
@@ -100,7 +100,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
 argument: 0
 
 --------------------
@@ -118,7 +118,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
 argument: 0
 
 =============== FORM ===============
@@ -178,7 +178,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_NorthEast
 name: input_filename
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -196,7 +196,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthEast FL_NorthEast
 name: button_browse
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -232,7 +232,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_East FL_East
 name: check_draft
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -250,7 +250,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_East FL_East
 name: check_nounzip
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -268,7 +268,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_West FL_East
 name: input_lyxscale
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -286,7 +286,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_West FL_East
 name: input_width
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -304,7 +304,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_East FL_East
 name: choice_width
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -322,7 +322,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_East FL_East
 name: choice_height
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -340,7 +340,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_West FL_West
 name: check_aspectratio
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -358,7 +358,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_West FL_East
 name: input_height
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -394,7 +394,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_East FL_East
 name: choice_display
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 =============== FORM ===============
@@ -436,7 +436,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: input_bb_x1
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -454,7 +454,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: input_bb_y1
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -472,7 +472,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: input_bb_x0
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -490,7 +490,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: input_bb_y0
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -544,7 +544,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_North FL_North
 name: choice_bb_units
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -562,7 +562,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_NorthWest
 name: check_clip
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -580,7 +580,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_NorthWest
 name: button_getBB
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 =============== FORM ===============
@@ -640,7 +640,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_West FL_East
 name: input_special
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -676,7 +676,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: choice_origin
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -694,7 +694,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_West FL_West
 name: check_subcaption
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -712,7 +712,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_North FL_North
 name: input_rotate_angle
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -730,7 +730,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_West FL_East
 name: input_subcaption
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 ==============================
index d48758053e1b901affcc555ac4c4b72402262010..c026d21c6d92e7317d7deaee92cbbf664cddcc5b 100644 (file)
@@ -1,5 +1,10 @@
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
+       * insetgraphics.[Ch]: define a new class InsetGraphicsMailer and use
+       it to communicate with the frontend dialogs.
+
+cd src2003-03-07  Angus Leeming  <leeming@lyx.org>
+
        * insetexternal.C: remove operator== and operator!= for
        InsetExternal::Params. They were used only by the old controller
        scheme.
index fede136172db1409ffd0e093e219d194d6562f98..932ac0af4e99c33e9334b6783f264c5452b27328 100644 (file)
@@ -64,20 +64,19 @@ TODO
 #include "buffer.h"
 #include "BufferView.h"
 #include "converter.h"
-#include "format.h"
-#include "frontends/Painter.h"
-#include "lyxrc.h"
-#include "frontends/font_metrics.h"
 #include "debug.h"
+#include "format.h"
+#include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "lyxlex.h"
+#include "lyxrc.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
+#include "frontends/font_metrics.h"
 #include "frontends/LyXView.h"
-
-#include "frontends/controllers/helper_funcs.h" // getVectorFromString
+#include "frontends/Painter.h"
 
 #include "support/LAssert.h"
 #include "support/filetools.h"
@@ -213,8 +212,41 @@ Inset * InsetGraphics::clone(Buffer const & buffer, bool same_id) const
 
 InsetGraphics::~InsetGraphics()
 {
-       // Emits the hide signal to the dialog connected (if any)
-       hideDialog();
+       InsetGraphicsMailer mailer(*this);
+       mailer.hideDialog();
+}
+
+
+dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
+{
+       dispatch_result result = UNDISPATCHED;
+
+       switch (cmd.action) {
+       case LFUN_INSET_MODIFY: {
+               InsetGraphicsParams p;
+               InsetGraphicsMailer::string2params(cmd.argument, p);
+               if (p.filename.empty())
+                       break;
+
+               string const filepath = cmd.view()->buffer()->filePath();
+               setParams(p, filepath);
+               cmd.view()->updateInset(this, true);
+               result = DISPATCHED;
+       }
+       break;
+
+       case LFUN_INSET_DIALOG_UPDATE: {
+               InsetGraphicsMailer mailer(*this);
+               mailer.updateDialog();
+       }
+       break;
+
+       default:
+               result = DISPATCHED;
+               break;
+       }
+
+       return result;
 }
 
 
@@ -301,6 +333,12 @@ int InsetGraphics::width(BufferView *, LyXFont const & font) const
 }
 
 
+BufferView * InsetGraphics::view() const
+{
+       return cache_->view.lock().get();
+}
+
+
 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                         int baseline, float & x, bool) const
 {
@@ -394,9 +432,10 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
 }
 
 
-void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state)
+void InsetGraphics::edit(BufferView *, int, int, mouse_button::state)
 {
-       bv->owner()->getDialogs().showGraphics(this);
+       InsetGraphicsMailer mailer(*this);
+       mailer.showDialog();
 }
 
 
@@ -833,3 +872,50 @@ InsetGraphicsParams const & InsetGraphics::params() const
 {
        return params_;
 }
+
+
+string const InsetGraphicsMailer::name_("graphics");
+
+InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
+       : inset_(inset)
+{}
+
+
+string const InsetGraphicsMailer::inset2string() const
+{
+       return params2string(inset_.params());
+}
+
+
+void InsetGraphicsMailer::string2params(string const & in,
+                                       InsetGraphicsParams & params)
+{
+       params = InsetGraphicsParams();
+
+       istringstream data(in);
+       LyXLex lex(0,0);
+       lex.setStream(data);
+
+       if (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+               if (token != name_)
+                       return;
+       }
+
+       InsetGraphics inset;    
+       inset.readInsetGraphics(lex);
+       params = inset.params();
+}
+
+
+string const
+InsetGraphicsMailer::params2string(InsetGraphicsParams const & params)
+{
+       ostringstream data;
+       data << name_ << ' ';
+       params.Write(data);
+       data << "\\end_inset\n";
+
+       return data.str();
+}
index 412c1dcafc99c2fb5528d2061bfe5e9093407fc2..ac13376ae9c0a39c7506a3932095bdf9d7d69b72 100644 (file)
@@ -18,8 +18,6 @@
 #include "insets/inset.h"
 #include "insets/insetgraphicsParams.h"
 
-// We need a signal here to hide an active dialog when we are deleted.
-#include <boost/signals/signal0.hpp>
 #include <boost/signals/trackable.hpp>
 #include <boost/scoped_ptr.hpp>
 
@@ -37,6 +35,8 @@ public:
        ///
        ~InsetGraphics();
        ///
+       virtual dispatch_result localDispatch(FuncRequest const & cmd); 
+       ///
        int ascent(BufferView *, LyXFont const &) const;
        ///
        int descent(BufferView *, LyXFont const &) const;
@@ -88,12 +88,13 @@ public:
        /// Get the inset parameters, used by the GUIndependent dialog.
        InsetGraphicsParams const & params() const;
 
-       /** This signal is connected by our dialog and called when the inset
-           is deleted.
-       */
-       boost::signal0<void> hideDialog;
-
 private:
+       /// Returns the cached BufferView.
+       BufferView * view() const;
+
+       ///
+       friend class InsetGraphicsMailer;
+
        /// Is the image ready to draw, or should we display a message instead?
        bool imageIsDrawable() const;
 
@@ -125,4 +126,28 @@ private:
        boost::scoped_ptr<Cache> const cache_;
 };
 
+
+#include "mailinset.h"
+
+class InsetGraphicsMailer : public MailInset {
+public:
+       ///
+       InsetGraphicsMailer(InsetGraphics & inset);
+       ///
+       virtual Inset & inset() const { return inset_; }
+       ///
+       virtual string const & name() const { return name_; }
+       ///
+       virtual string const inset2string() const;
+       ///
+       static void string2params(string const &, InsetGraphicsParams &);
+       ///
+       static string const params2string(InsetGraphicsParams const &);
+private:
+       ///
+       static string const name_;
+       ///
+       InsetGraphics & inset_;
+};
+
 #endif
index 29cf3efc76ca0be61cfb08532a3e929286aaf8bc..64b89f17850f1c32eb3550e233d9ad8af280049b 100644 (file)
@@ -543,9 +543,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_INSET_ERT:
                code = Inset::ERT_CODE;
                break;
-       case LFUN_INSET_GRAPHICS:
-               code = Inset::GRAPHICS_CODE;
-               break;
        case LFUN_INSET_FOOTNOTE:
                code = Inset::FOOT_CODE;
                break;