]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
remove LFUN_TOOLTIPS_TOGGLE and associated Dialog::tooltipsEnabled() method.
[lyx.git] / src / lyxfunc.C
index a861048e66262123a5d47837340d967146eb1c07..44855227549b8c53c85657df3ca6e50cd58d2bfd 100644 (file)
 #include "insets/insetvspace.h"
 #include "insets/insetwrap.h"
 
+#include "frontends/Application.h"
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
 #include "frontends/FileDialog.h"
+#include "frontends/FontLoader.h"
 #include "frontends/lyx_gui.h"
 #include "frontends/LyXKeySym.h"
 #include "frontends/LyXView.h"
@@ -138,9 +140,6 @@ namespace biblio = lyx::biblio;
 namespace fs = boost::filesystem;
 
 
-extern BufferList bufferlist;
-extern LyXServer * lyxserver;
-
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 
 // (alkis)
@@ -369,8 +368,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                flag.unknown(true);
                flag.enabled(false);
                break;
+
        default:
-               flag |= lyx_gui::getStatus(cmd);
+               break;
        }
 
        if (flag.unknown()) {
@@ -399,10 +399,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        // to handle (Andre')
        bool enable = true;
        switch (cmd.action) {
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.setOnOff(owner->getDialogs().tooltipsEnabled());
-               break;
-
        case LFUN_BUFFER_TOGGLE_READ_ONLY:
                flag.setOnOff(buf->isReadonly());
                break;
@@ -420,7 +416,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
 
        case LFUN_BUFFER_CHKTEX:
-               enable = buf->isLatex() && lyxrc.chktex_command != "none";
+               enable = buf->isLatex() && !lyxrc.chktex_command.empty();
                break;
 
        case LFUN_BUILD_PROGRAM:
@@ -635,8 +631,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        // Are we in a DELETED change-tracking region?
-       if (buf && buf->params().tracking_changes
-           && lookupChangeType(cur, true) == Change::DELETED
+       if (buf && lookupChangeType(cur, true) == Change::DELETED
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
                flag.message(lyx::from_utf8(N_("This portion of the document is deleted.")));
@@ -651,9 +646,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 }
 
 
-namespace {
-
-bool ensureBufferClean(BufferView * bv)
+bool LyXFunc::ensureBufferClean(BufferView * bv)
 {
        Buffer & buf = *bv->buffer();
        if (buf.isClean())
@@ -668,12 +661,14 @@ bool ensureBufferClean(BufferView * bv)
                                      _("&Cancel"));
 
        if (ret == 0)
-               bv->owner()->dispatch(FuncRequest(LFUN_BUFFER_WRITE));
+               dispatch(FuncRequest(LFUN_BUFFER_WRITE));
 
        return buf.isClean();
 }
 
 
+namespace {
+
 void showPrintError(string const & name)
 {
        docstring str = bformat(_("Could not print the document %1$s.\n"
@@ -1083,15 +1078,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                // --- buffers ----------------------------------------
                case LFUN_BUFFER_SWITCH:
-                       owner->setBuffer(bufferlist.getBuffer(argument));
+                       owner->setBuffer(theApp->bufferList().getBuffer(argument));
                        break;
 
                case LFUN_BUFFER_NEXT:
-                       owner->setBuffer(bufferlist.next(view()->buffer()));
+                       owner->setBuffer(theApp->bufferList().next(view()->buffer()));
                        break;
 
                case LFUN_BUFFER_PREVIOUS:
-                       owner->setBuffer(bufferlist.previous(view()->buffer()));
+                       owner->setBuffer(theApp->bufferList().previous(view()->buffer()));
                        break;
 
                case LFUN_FILE_NEW:
@@ -1120,7 +1115,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_SERVER_NOTIFY:
                        dispatch_buffer = lyx::from_utf8(keyseq.print());
-                       lyxserver->notifyClient(lyx::to_utf8(dispatch_buffer));
+                       theApp->server().notifyClient(lyx::to_utf8(dispatch_buffer));
                        break;
 
                case LFUN_SERVER_GOTO_FILE_ROW: {
@@ -1131,14 +1126,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (prefixIs(file_name, package().temp_dir())) {
                                // Needed by inverse dvi search. If it is a file
                                // in tmpdir, call the apropriated function
-                               owner->setBuffer(bufferlist.getBufferFromTmp(file_name));
+                               owner->setBuffer(theApp->bufferList().getBufferFromTmp(file_name));
                        } else {
                                // Must replace extension of the file to be .lyx
                                // and get full path
                                string const s = changeExtension(file_name, ".lyx");
                                // Either change buffer or load the file
-                               if (bufferlist.exists(s)) {
-                                       owner->setBuffer(bufferlist.getBuffer(s));
+                               if (theApp->bufferList().exists(s)) {
+                                       owner->setBuffer(theApp->bufferList().getBuffer(s));
                                } else {
                                        owner->loadLyXFile(s);
                                }
@@ -1288,8 +1283,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                         makeDisplayPath(filename) + lyx::from_ascii("..."));
                        view()->savePosition(0);
                        string const parentfilename = owner->buffer()->fileName();
-                       if (bufferlist.exists(filename))
-                               owner->setBuffer(bufferlist.getBuffer(filename));
+                       if (theApp->bufferList().exists(filename))
+                               owner->setBuffer(theApp->bufferList().getBuffer(filename));
                        else
                                owner->loadLyXFile(filename);
                        // Set the parent name of the child document.
@@ -1354,7 +1349,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_SCREEN_FONT_UPDATE:
                        // handle the screen font changes.
                        lyxrc.set_font_norm_type();
-                       lyx_gui::update_fonts();
+                       theApp->fontLoader().update();
                        // All visible buffers will need resize
                        view()->resize();
                        break;
@@ -1398,10 +1393,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        owner->message(lyx::from_utf8(argument));
                        break;
 
-               case LFUN_TOOLTIPS_TOGGLE:
-                       owner->getDialogs().toggleTooltips();
-                       break;
-
                case LFUN_EXTERNAL_EDIT: {
                        FuncRequest fr(action, argument);
                        InsetExternal().dispatch(view()->cursor(), fr);
@@ -1611,7 +1602,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                view()->buffer()->markDirty();
 
                        if (view()->cursor().inTexted()) {
-                               view()->owner()->updateLayoutChoice();
+                               owner->updateLayoutChoice();
                        }
                }
        }
@@ -1704,7 +1695,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
        if (filename.empty()) {
                filename = addName(lyxrc.document_path,
                            "newfile" + convert<string>(++newfile_number) + ".lyx");
-               while (bufferlist.exists(filename) || fs::is_readable(filename)) {
+               while (theApp->bufferList().exists(filename) || fs::is_readable(filename)) {
                        ++newfile_number;
                        filename = addName(lyxrc.document_path,
                                           "newfile" +  convert<string>(newfile_number) +
@@ -1865,8 +1856,8 @@ void LyXFunc::doImport(string const & argument)
        string const lyxfile = changeExtension(filename, ".lyx");
 
        // Check if the document already is open
-       if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
-               if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
+       if (lyx_gui::use_gui && theApp->bufferList().exists(lyxfile)) {
+               if (!theApp->bufferList().close(theApp->bufferList().getBuffer(lyxfile), true)) {
                        owner->message(_("Canceled."));
                        return;
                }
@@ -1899,14 +1890,14 @@ void LyXFunc::closeBuffer()
        // save current cursor position
        LyX::ref().session().saveFilePosition(owner->buffer()->fileName(),
                boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
-       if (bufferlist.close(owner->buffer(), true) && !quitting) {
-               if (bufferlist.empty()) {
+       if (theApp->bufferList().close(owner->buffer(), true) && !quitting) {
+               if (theApp->bufferList().empty()) {
                        // need this otherwise SEGV may occur while
                        // trying to set variables that don't exist
                        // since there's no current buffer
                        owner->getDialogs().hideBufferDependent();
                } else {
-                       owner->setBuffer(bufferlist.first());
+                       owner->setBuffer(theApp->bufferList().first());
                }
        }
 }