]> 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 b1aa3fb2990d953fe582adfe41182e49681a65ba..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)
@@ -220,7 +219,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
                c = 0;
        }
 
-       owner->getIntl().getTransManager()
+       owner->view()->getIntl().getTransManager()
                .deadkey(c, get_accent(action).accent, view()->getLyXText());
        // Need to clear, in case the minibuffer calls these
        // actions
@@ -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"
@@ -778,7 +773,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (view()->buffer())
                                // cancel any selection
                                dispatch(FuncRequest(LFUN_MARK_OFF));
-                       setMessage(lyx::from_utf8(N_("Cancel")));
+                       setMessage(_("Cancel"));
                        break;
 
                case LFUN_META_PREFIX:
@@ -1026,7 +1021,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_HELP_OPEN: {
                        string const arg = argument;
                        if (arg.empty()) {
-                               setErrorMessage(lyx::from_utf8(N_("Missing argument")));
+                               setErrorMessage(_("Missing argument"));
                                break;
                        }
                        string const fname = i18nLibFileSearch("doc", arg, "lyx");
@@ -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);
                                }
@@ -1283,12 +1278,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_BUFFER_CHILD_OPEN: {
                        string const filename =
                                makeAbsPath(argument, owner->buffer()->filePath());
-                       setMessage(lyx::from_utf8(N_("Opening child document ")) +
+                       // FIXME Should use bformat
+                       setMessage(_("Opening child document ") +
                                         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.
@@ -1303,19 +1299,19 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
 
                case LFUN_KEYMAP_OFF:
-                       owner->getIntl().keyMapOn(false);
+                       owner->view()->getIntl().keyMapOn(false);
                        break;
 
                case LFUN_KEYMAP_PRIMARY:
-                       owner->getIntl().keyMapPrim();
+                       owner->view()->getIntl().keyMapPrim();
                        break;
 
                case LFUN_KEYMAP_SECONDARY:
-                       owner->getIntl().keyMapSec();
+                       owner->view()->getIntl().keyMapSec();
                        break;
 
                case LFUN_KEYMAP_TOGGLE:
-                       owner->getIntl().toggleKeyMap();
+                       owner->view()->getIntl().toggleKeyMap();
                        break;
 
                case LFUN_REPEAT: {
@@ -1353,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;
@@ -1362,8 +1358,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        string lyx_name;
                        string const x11_name = split(argument, lyx_name, ' ');
                        if (lyx_name.empty() || x11_name.empty()) {
-                               setErrorMessage(lyx::from_utf8(N_("Syntax: set-color <lyx_name>"
-                                                       " <x11_name>")));
+                               setErrorMessage(_("Syntax: set-color <lyx_name>"
+                                                       " <x11_name>"));
                                break;
                        }
 
@@ -1397,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);
@@ -1487,6 +1479,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
 
                        if (defaults.writeFile(defaults.fileName()))
+                               // FIXME Should use bformat
                                setMessage(_("Document defaults saved in ")
                                           + makeDisplayPath(fname));
                        else
@@ -1609,14 +1602,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                view()->buffer()->markDirty();
 
                        if (view()->cursor().inTexted()) {
-                               view()->owner()->updateLayoutChoice();
+                               owner->updateLayoutChoice();
                        }
                }
        }
        if (!quitting)
                // FIXME UNICODE: _() does not support anything but ascii.
                // Do we need a lyx::to_ascii() method?
-               sendDispatchMessage(_(lyx::to_utf8(getMessage())), cmd);
+               sendDispatchMessage(getMessage(), cmd);
 }
 
 
@@ -1669,7 +1662,7 @@ void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd
                dispatch_msg += lyx::from_utf8('(' + rtrim(comname) + ')');
        }
 
-       lyxerr[Debug::ACTION] << "verbose dispatch msg " 
+       lyxerr[Debug::ACTION] << "verbose dispatch msg "
                << lyx::to_utf8(dispatch_msg) << endl;
        if (!dispatch_msg.empty())
                owner->message(dispatch_msg);
@@ -1702,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) +
@@ -1863,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;
                }
@@ -1897,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());
                }
        }
 }