]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
more code in the menu backend == less code in the menu frontends; add support for...
[lyx.git] / src / lyxfunc.C
index a1b316d092db1365152c35f5bc238c33e02f9a6f..b74ad0e369fee3580d5d2dcd0d38b8762fa5a2a8 100644 (file)
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "lyxfunc.h"
 #include "version.h"
 #include "kbmap.h"
@@ -124,7 +120,7 @@ void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
 {
        if (selecting || TEXT(flag)->selection.mark()) {
                TEXT(flag)->setSelection(view());
-               if (TEXT(flag)->bv_owner)
+               if (TEXT(flag)->isTopLevel())
                    view()->toggleToggle();
        }
        view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
@@ -221,7 +217,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                owner->message(keyseq.print());
        }
 
+
        // Maybe user can only reach the key via holding down shift.
        // Let's see. But only if shift is the only modifier
        if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
@@ -229,7 +225,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                action = keyseq.addkey(keysym, key_modifier::none);
                lyxerr[Debug::KEY] << "Action now " << action << endl;
        }
+
        if (action == LFUN_UNKNOWN_ACTION) {
                // Hmm, we didn't match any of the keysequences. See
                // if it's normal insertable text not already covered
@@ -286,7 +282,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        default:
                flag |= lyx_gui::getStatus(ev);
        }
-       
+
        if (flag.unknown()) {
                setStatusMessage(N_("Unknown action"));
                return flag;
@@ -327,8 +323,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        || lyxrc.print_command == "none";
                break;
        case LFUN_EXPORT:
-               disable = ev.argument == "fax" &&
-                       !Exporter::IsExportable(buf, ev.argument);
+               disable = ev.argument != "custom"
+                       && !Exporter::IsExportable(buf, ev.argument);
                break;
        case LFUN_UNDO:
                disable = buf->undostack.empty();
@@ -338,9 +334,12 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                break;
        case LFUN_CUT:
        case LFUN_COPY:
-               if (tli && tli->lyxCode() == Inset::TABULAR_CODE) {
-                       InsetTabular * t(static_cast<InsetTabular*>(tli));
-                       if (t->hasSelection()) {
+               if (tli) {
+                       UpdatableInset * in = tli;
+                       if (in->lyxCode() != Inset::TABULAR_CODE) {
+                               in = tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
+                       }
+                       if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
                                disable = false;
                                break;
                        }
@@ -459,6 +458,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                disable =  !view()->
                        isSavedPosition(strToUnsignedInt(ev.argument));
                break;
+       case LFUN_MERGE_CHANGES:
+       case LFUN_ACCEPT_CHANGE:
+       case LFUN_REJECT_CHANGE:
+       case LFUN_ACCEPT_ALL_CHANGES:
+       case LFUN_REJECT_ALL_CHANGES:
+               disable = !buf->params.tracking_changes;
+               break;
        case LFUN_INSET_TOGGLE: {
                LyXText * lt = view()->getLyXText();
                disable = !(isEditableInset(lt->getInset())
@@ -621,6 +627,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                if (ev.argument == buf->fileName())
                        flag.setOnOff(true);
                break;
+       case LFUN_TRACK_CHANGES:
+               flag.setOnOff(buf->params.tracking_changes);
+               break;
        default:
                break;
        }
@@ -1130,12 +1139,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                        setErrorMessage(N_("Missing argument"));
                        break;
                }
-               owner->prohibitInput();
                string const fname = i18nLibFileSearch("doc", arg, "lyx");
                if (fname.empty()) {
                        lyxerr << "LyX: unable to find documentation file `"
                               << arg << "'. Bad installation?" << endl;
-                       owner->allowInput();
                        break;
                }
                ostringstream str;
@@ -1148,7 +1155,6 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
 #endif
                owner->message(STRCONV(str.str()));
                view()->buffer(bufferlist.loadLyXFile(fname, false));
-               owner->allowInput();
                break;
        }
 
@@ -1644,7 +1650,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
 
                FileDialog::Result result =
                        fileDlg.open(lyxrc.template_path,
-                                      _("*.lyx|LyX Documents (*.lyx)"));
+                                      _("*.lyx| LyX Documents (*.lyx)"));
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1683,7 +1689,7 @@ void LyXFunc::open(string const & fname)
 
                FileDialog::Result result =
                        fileDlg.open(initpath,
-                                      "*.lyx|LyX Documents (*.lyx)");
+                                      _("*.lyx| LyX Documents (*.lyx)"));
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1712,7 +1718,7 @@ void LyXFunc::open(string const & fname)
        if (!f.exist()) {
                if (!Alert::askQuestion(_("No such file"), disp_fn,
                        _("Start a new document with this filename ?"))) {
-                       owner->message(_("Canceled"));
+                       owner->message(_("Canceled."));
                        return;
                }
                // the user specifically chose this name. Believe them.
@@ -1837,7 +1843,7 @@ void LyXFunc::doImport(string const & argument)
        if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
                if (!Alert::askQuestion(_("A document by the name"),
                        MakeDisplayPath(lyxfile), _("already exists. Overwrite?"))) {
-                       owner->message(_("Canceled"));
+                       owner->message(_("Canceled."));
                        return;
                }
        }