]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.cpp
Embedding: saving inzip name to .lyx file so that embedded files can always be found...
[lyx.git] / src / MenuBackend.cpp
index 2e4f4532f2bb7e4bfc8fb2c6c4eb5c90c0496360..8d269f3e02e5761d1baff98aa1fc7ec22acade8b 100644 (file)
@@ -39,6 +39,8 @@
 #include "TocBackend.h"
 #include "ToolbarBackend.h"
 
+#include "frontends/Application.h"
+
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/convert.h"
@@ -70,10 +72,6 @@ private:
 } // namespace anon
 
 
-// This is the global menu definition
-MenuBackend menubackend;
-
-
 MenuItem::MenuItem(Kind kind)
        : kind_(kind), optional_(false)
 {}
@@ -118,7 +116,7 @@ docstring const MenuItem::shortcut() const
 }
 
 
-docstring const MenuItem::binding(bool forgui) const
+docstring const MenuItem::binding() const
 {
        if (kind_ != Command)
                return docstring();
@@ -406,7 +404,7 @@ void Menu::checkShortcuts() const
 }
 
 
-bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names)
+bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names) const
 {
        const_iterator m = begin();
        const_iterator m_end = end();
@@ -416,7 +414,7 @@ bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names)
                        return true;
                } else if (m->kind() == MenuItem::Submenu) {
                        names.push(m->label());
-                       Menu submenu = menubackend.getMenu(m->submenuname());
+                       Menu submenu = theApp()->menuBackend().getMenu(m->submenuname());
                        if (submenu.searchFunc(func, names))
                                return true;
                        else
@@ -551,6 +549,7 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
                if ((*fit)->dummy())
                        continue;
                docstring label = from_utf8((*fit)->prettyname());
+               docstring const shortcut = from_utf8((*fit)->shortcut());
 
                switch (kind) {
                case MenuItem::ImportFormats:
@@ -572,8 +571,13 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
                        BOOST_ASSERT(false);
                        break;
                }
-               if (!(*fit)->shortcut().empty())
-                       label += char_type('|') + from_utf8((*fit)->shortcut());
+               // FIXME: if we had proper support for translating the
+               // format names defined in configure.py, there would
+               // not be a need to check whether the shortcut is
+               // correct. If we add it uncondiitonally, it would
+               // create useless warnings on bad shortcuts
+               if (!shortcut.empty() && contains(label, shortcut))
+                       label += char_type('|') + shortcut;
 
                if (buf)
                        tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,