]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Juergen's compiler warning fixes
[lyx.git] / src / lyxfunc.C
index bbff9e1f5ae0b54fb67c2c8e0c893b4a8a7627b0..b5c3ad161bf90a3a99a692beb678cb354d1738b3 100644 (file)
@@ -272,9 +272,19 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 {
        //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
        FuncStatus flag;
-       Buffer * buf = owner->buffer();
        LCursor & cur = view()->cursor();
 
+       /* In LyX/Mac, when a dialog is open, the menus of the
+          application can still be accessed without giving focus to
+          the main window. In this case, we want to disable the menu
+          entries that are buffer-related.
+       */
+       Buffer * buf;
+       if (cmd.origin == FuncRequest::UI && !owner->hasFocus())
+               buf = 0;
+       else
+               buf = owner->buffer();
+
        if (cmd.action == LFUN_NOACTION) {
                setStatusMessage(N_("Nothing to do"));
                flag.enabled(false);
@@ -447,7 +457,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_SEQUENCE: {
                // argument contains ';'-terminated commands
                string const firstcmd = token(cmd.argument, ';', 0);
-               flag = getStatus(lyxaction.lookupFunc(firstcmd));
+               FuncRequest func(lyxaction.lookupFunc(firstcmd));
+               func.origin = cmd.origin;
+               flag = getStatus(func);
        }
 
        case LFUN_MENUNEW:
@@ -588,7 +600,7 @@ void loadTextclass(string const & name)
 } //namespace anon
 
 
-void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
+void LyXFunc::dispatch(FuncRequest const & cmd)
 {
        string const argument = cmd.argument;
        kb_action const action = cmd.action;
@@ -1219,7 +1231,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
                        while (!arg.empty()) {
                                string first;
                                arg = split(arg, first, ';');
-                               dispatch(lyxaction.lookupFunc(first));
+                               FuncRequest func(lyxaction.lookupFunc(first));
+                               func.origin = cmd.origin;
+                               dispatch(func);
                        }
                        break;
                }
@@ -1463,18 +1477,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
 
                if (view()->cursor().inTexted()) {
                        view()->owner()->updateLayoutChoice();
-                       sendDispatchMessage(getMessage(), cmd, verbose);
+                       sendDispatchMessage(getMessage(), cmd);
                }
        }
 }
 
 
-void LyXFunc::sendDispatchMessage(string const & msg,
-                                 FuncRequest const & cmd, bool verbose)
+void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd)
 {
        owner->updateMenubar();
        owner->updateToolbars();
 
+       const bool verbose = (cmd.origin == FuncRequest::UI
+                             || cmd.origin == FuncRequest::COMMANDBUFFER);
+
        if (cmd.action == LFUN_SELFINSERT || !verbose) {
                lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
                if (!msg.empty())