]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Compilation fix
[lyx.git] / src / lyxfunc.C
index 9cdd982fab168cd1bbe1b17b3f894ccfa7f40d21..f14984b7f1c134715f3d5c54a4632b1a0a13b1d3 100644 (file)
@@ -34,7 +34,7 @@
 #include "frontends/lyx_gui.h"
 #include "vspace.h"
 #include "FloatList.h"
-#include "converter.h"
+#include "format.h"
 #include "exporter.h"
 #include "importer.h"
 #include "TextCache.h"
@@ -43,6 +43,8 @@
 #include "ParagraphParameters.h"
 
 #include "insets/insetcommand.h"
+#include "insets/inseterror.h"
+#include "insets/insetert.h"
 #include "insets/insettabular.h"
 
 #include "mathed/formulamacro.h"
@@ -559,13 +561,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_REF_INSERT:
                code = Inset::REF_CODE;
                break;
-       case LFUN_CITATION_CREATE:
-       case LFUN_CITATION_INSERT:
-               code = Inset::CITE_CODE;
-               break;
-       case LFUN_INSERT_BIBTEX:
-               code = Inset::BIBTEX_CODE;
-               break;
        case LFUN_INDEX_INSERT:
                code = Inset::INDEX_CODE;
                break;
@@ -1047,27 +1042,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                break;
 
        case LFUN_TOCVIEW:
-#if 0
-       case LFUN_LOFVIEW:
-       case LFUN_LOTVIEW:
-       case LFUN_LOAVIEW:
-#endif
        {
-               InsetCommandParams p;
-
-#if 0
-               if (action == LFUN_TOCVIEW)
-#endif
-                       p.setCmdName("tableofcontents");
-#if 0
-               else if (action == LFUN_LOAVIEW)
-                       p.setCmdName("listof{algorithm}{List of Algorithms}");
-               else if (action == LFUN_LOFVIEW)
-                       p.setCmdName("listoffigures");
-               else
-                       p.setCmdName("listoftables");
-#endif
-               owner->getDialogs().createTOC(p.getAsString());
+               InsetCommandParams p("tableofcontents");
+               string const data = InsetCommandMailer::params2string("toc", p);
+               owner->getDialogs().show("toc", data, 0);
                break;
        }
 
@@ -1374,27 +1352,80 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                owner->getDialogs().showMathPanel();
                break;
 
-       case LFUN_CITATION_CREATE:
-       {
-               InsetCommandParams p("cite");
+       case LFUN_DIALOG_SHOW_NEW_INSET: {
+               string const & name = argument;
+               string data;
+               if (name == "bibitem" ||
+                   name == "bibtex" ||
+                   name == "index" ||
+                   name == "ref" ||
+                   name == "toc" ||
+                   name == "url") {
+                       InsetCommandParams p(name);
+                       data = InsetCommandMailer::params2string(name, p);
+               } else if (name == "citation") {
+                       InsetCommandParams p("cite");
+                       data = InsetCommandMailer::params2string(name, p);
+               } else if (name == "ert") {
+                       data = InsetERTMailer::params2string(name,
+                                                            InsetERT::Open);
+               }
+                owner->getDialogs().show(name, data, 0);
+       }
+       break;
 
-               if (!argument.empty()) {
-                       // This should be set at source, ie when typing
-                       // "citation-insert foo" in the minibuffer.
-                       // Question: would pybibliographer also need to be
-                       // changed. Suspect so. Leave as-is therefore.
-                       if (contains(argument, "|")) {
-                               p.setContents(token(argument, '|', 0));
-                               p.setOptions(token(argument, '|', 1));
-                       } else {
-                               p.setContents(argument);
-                       }
-                       dispatch(FuncRequest(view(), LFUN_CITATION_INSERT, p.getAsString()));
-               } else
-                       owner->getDialogs().createCitation(p.getAsString());
+       case LFUN_DIALOG_SHOW_NEXT_INSET: {
        }
        break;
 
+       case LFUN_DIALOG_UPDATE: {
+               string const & name = argument;
+               // Can only update a dialog connected to an existing inset
+               InsetBase * i = owner->getDialogs().getOpenInset(name);
+               if (!i)
+                       break;
+
+               if (name == "bibitem" ||
+                   name == "bibtex" ||
+                   name == "citation" ||
+                   name == "index" ||
+                   name == "ref" ||
+                   name == "toc" ||
+                   name == "url") {
+                       InsetCommand * inset = dynamic_cast<InsetCommand *>(i);
+                       if (!inset)
+                               break;
+
+                       InsetCommandMailer mailer(name, *inset);
+                       mailer.updateDialog();
+
+               } else if (name == "error") {
+                       InsetError * inset = dynamic_cast<InsetError *>(i);
+                       if (!inset)
+                               break;
+
+                       owner->getDialogs().update("error",
+                                                  inset->getContents());
+
+               } else if (name == "ert") {
+                       InsetERT * inset = dynamic_cast<InsetERT *>(i);
+                       if (!inset)
+                               break;
+
+                       InsetERTMailer mailer(*inset);
+                       mailer.updateDialog();
+               }
+       }
+       break;
+
+       case LFUN_DIALOG_HIDE:
+               owner ->getDialogs().hide(argument);
+               break;
+
+       case LFUN_DIALOG_DISCONNECT_INSET:
+                owner->getDialogs().disconnect(argument);
+               break;
+
        case LFUN_CHILDOPEN:
        {
                string const filename =
@@ -1644,7 +1675,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
        // The template stuff
        string templname;
        if (fromTemplate) {
-               FileDialog fileDlg(owner, _("Select template file"),
+               FileDialog fileDlg(_("Select template file"),
                        LFUN_SELECT_FILE_SYNC,
                        make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
@@ -1683,7 +1714,7 @@ void LyXFunc::open(string const & fname)
        string filename;
 
        if (fname.empty()) {
-               FileDialog fileDlg(owner, _("Select document to open"),
+               FileDialog fileDlg(_("Select document to open"),
                        LFUN_FILE_OPEN,
                        make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
@@ -1788,7 +1819,7 @@ void LyXFunc::doImport(string const & argument)
                        + _(" file to import");;
 #endif
 
-               FileDialog fileDlg(owner, text,
+               FileDialog fileDlg(text,
                        LFUN_IMPORT,
                        make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),