]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
cleanup and reorder initialisation code of GuiView and GuiToolbars. Move some things...
[lyx.git] / src / LyXFunc.cpp
index 557e7148e6e3b52c565287bc5228f2035e64dfd0..ca9428fc26b070749b5aca48399b1800ce9b8820 100644 (file)
 #include "insets/InsetVSpace.h"
 #include "insets/InsetWrap.h"
 
-#include "frontends/Application.h"
 #include "frontends/alert.h"
-#include "frontends/Dialogs.h"
+#include "frontends/Application.h"
 #include "frontends/FileDialog.h"
 #include "frontends/FontLoader.h"
-#include "frontends/Gui.h"
 #include "frontends/KeySymbol.h"
 #include "frontends/LyXView.h"
 #include "frontends/Selection.h"
@@ -593,7 +591,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        break;
                }
                string const name = cmd.getArg(0);
-               Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
+               Inset * inset = lyx_view_->getOpenInset(name);
                if (inset) {
                        FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
                        FuncStatus fs;
@@ -611,7 +609,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        case LFUN_DIALOG_TOGGLE:
-               flag.setOnOff(lyx_view_->getDialogs().visible(cmd.getArg(0)));
+               flag.setOnOff(lyx_view_?
+                       lyx_view_->isDialogVisible(cmd.getArg(0)) : false);
                // fall through to set "enable"
        case LFUN_DIALOG_SHOW: {
                string const name = cmd.getArg(0);
@@ -697,12 +696,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
 
        case LFUN_TOOLBAR_TOGGLE: {
-               bool const current = lyx_view_->isToolbarVisible(cmd.getArg(0));
+               bool const current = lyx_view_?
+                       lyx_view_->isToolbarVisible(cmd.getArg(0)) : false;
                flag.setOnOff(current);
                break;
        }
        case LFUN_WINDOW_CLOSE: {
-               enable = (theApp()->gui().viewIds().size() > 1);
+               enable = theApp()->viewCount() > 0;
                break;
        }
 
@@ -719,7 +719,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        case LFUN_CALL: {
                FuncRequest func;
-               std::string name(to_utf8(cmd.argument()));
+               std::string name = to_utf8(cmd.argument());
                if (LyX::ref().topLevelCmdDef().lock(name, func)) {
                        func.origin = cmd.origin;
                        flag = getStatus(func);
@@ -1082,7 +1082,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_BUFFER_EXPORT:
                        BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
                        if (argument == "custom")
-                               lyx_view_->showDialog("sendto");
+                               lyx_view_->showDialog("sendto", string());
                        else
                                lyx_view_->buffer()->doExport(argument, false);
                        break;
@@ -1245,7 +1245,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        // (leaving the event loop).
                        lyx_view_->message(from_utf8(N_("Exiting.")));
                        if (theBufferList().quitWriteAll())
-                               theApp()->gui().closeAllViews();
+                               theApp()->closeAllViews();
                        break;
 
                case LFUN_BUFFER_AUTO_SAVE:
@@ -1425,7 +1425,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (name == "character") {
                                data = freefont2string();
                                if (!data.empty())
-                                       lyx_view_->showDialogWithData("character", data);
+                                       lyx_view_->showDialog("character", data);
                        } else if (name == "latexlog") {
                                Buffer::LogType type; 
                                string const logfile = lyx_view_->buffer()->logName(&type);
@@ -1438,13 +1438,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                        break;
                                }
                                data += Lexer::quoteString(logfile);
-                               lyx_view_->showDialogWithData("log", data);
+                               lyx_view_->showDialog("log", data);
                        } else if (name == "vclog") {
                                string const data = "vc " +
                                        Lexer::quoteString(lyx_view_->buffer()->lyxvc().getLogFile());
-                               lyx_view_->showDialogWithData("log", data);
+                               lyx_view_->showDialog("log", data);
                        } else
-                               lyx_view_->showDialogWithData(name, data);
+                               lyx_view_->showDialog(name, data);
                        break;
                }
 
@@ -1541,7 +1541,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                break;
                        } // end switch(code)
                        if (insetCodeOK)
-                               lyx_view_->getDialogs().show(name, data, 0);
+                               lyx_view_->showDialog(name, data, 0);
                        break;
                }
 
@@ -1549,7 +1549,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        string const & name = argument;
                        // Can only update a dialog connected to an existing inset
-                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
                                inset->dispatch(view()->cursor(), fr);
@@ -1562,13 +1562,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_DIALOG_HIDE: {
-                       LyX::cref().hideDialogs(argument, 0);
+                       if (quitting || !use_gui)
+                               break;
+                       theApp()->hideDialogs(argument, 0);
                        break;
                }
 
                case LFUN_DIALOG_TOGGLE: {
                        BOOST_ASSERT(lyx_view_);
-                       if (lyx_view_->getDialogs().visible(cmd.getArg(0)))
+                       if (lyx_view_->isDialogVisible(cmd.getArg(0)))
                                dispatch(FuncRequest(LFUN_DIALOG_HIDE, argument));
                        else
                                dispatch(FuncRequest(LFUN_DIALOG_SHOW, argument));
@@ -1577,7 +1579,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_DIALOG_DISCONNECT_INSET:
                        BOOST_ASSERT(lyx_view_);
-                       lyx_view_->getDialogs().disconnect(argument);
+                       lyx_view_->disconnectDialog(argument);
                        break;
 
 
@@ -1784,7 +1786,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_INSET_APPLY: {
                        BOOST_ASSERT(lyx_view_);
                        string const name = cmd.getArg(0);
-                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_MODIFY, argument);
                                inset->dispatch(view()->cursor(), fr);