]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / MenuBackend.C
index 543ba73c78076c9692ea3312a15bbce6c3ec270e..294599d1cf3e0042c23799418b6aea525c7b3c9b 100644 (file)
@@ -105,7 +105,9 @@ MenuItem::MenuItem(Kind kind, string const & label,
 MenuItem::MenuItem(Kind kind, string const & label,
                   FuncRequest const & func, bool optional)
        : kind_(kind), label_(label), func_(func), optional_(optional)
-{}
+{
+       func_.origin = FuncRequest::UI;
+}
 
 
 MenuItem::~MenuItem()
@@ -357,6 +359,20 @@ Menu & Menu::read(LyXLex & lex)
 }
 
 
+MenuItem const & Menu::operator[](size_type i) const
+{
+       return items_[i];
+}
+
+
+bool Menu::hasFunc(FuncRequest const & func) const
+{
+       return find_if(begin(), end(),
+                      bind(std::equal_to<FuncRequest>(),
+                           bind(&MenuItem::func, _1),
+                           func)) != end();
+}
+
 void Menu::checkShortcuts() const
 {
        // This is a quadratic algorithm, but we do not care because
@@ -383,6 +399,13 @@ void Menu::checkShortcuts() const
 }
 
 
+void MenuBackend::specialMenu(string const &name)
+{
+       if (hasMenu(name))
+               specialmenu_ = &getMenu(name);
+}
+
+
 namespace {
 
 class compare_format {
@@ -775,8 +798,14 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                }
                break;
 
-               default:
+               case MenuItem::Separator:
                        tomenu.add(*cit, view);
+                       break;
+
+               case MenuItem::Command:
+                       if (!specialmenu_
+                           || !specialmenu_->hasFunc(cit->func()))
+                               tomenu.add(*cit, view);
                }
        }
 
@@ -790,27 +819,6 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
 }
 
 
-bool Menu::hasSubmenu(string const & name) const
-{
-#if 1
-       return find_if(begin(), end(),
-                      bind(std::equal_to<string>(),
-                           bind(&MenuItem::submenuname, _1),
-                           name)) != end();
-#else
-       // I would have prefered this, but I am not sure if it
-       // makes a difference. (Lgb)
-       return find_if(
-               make_transform_iterator(begin(),
-                                       bind(&MenuItem::submenuname, _1)),
-               make_transform_iterator(end(),
-                                       bind(&MenuItem::submenuname, _1)),
-               name
-               ).base() != end();
-#endif
-}
-
-
 void MenuBackend::read(LyXLex & lex)
 {
        enum Menutags {