]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.C
Fix bug 2485 and crash on middle mouse paste on math
[lyx.git] / src / MenuBackend.C
index b2eb7ba10d3972215c88bac93894a1a0a8eb3bc4..22ea282f910918cf7243d20fa06a33f0f19e4cda 100644 (file)
@@ -30,7 +30,7 @@
 #include "gettext.h"
 #include "importer.h"
 #include "kbmap.h"
-#include "lastfiles.h"
+#include "session.h"
 #include "LyXAction.h"
 #include "lyx_main.h" // for lastfiles
 #include "lyxfunc.h"
@@ -49,7 +49,7 @@
 
 using lyx::support::compare_ascii_no_case;
 using lyx::support::contains;
-using lyx::support::MakeDisplayPath;
+using lyx::support::makeDisplayPath;
 using lyx::support::token;
 
 using boost::bind;
@@ -428,15 +428,14 @@ string const limit_string_length(string const & str)
 
 void expandLastfiles(Menu & tomenu, LyXView const * view)
 {
-       LastFiles const & lastfiles = LyX::cref().lastfiles();
+       lyx::Session::LastFiles const & lf = LyX::cref().session().lastFiles();
+       lyx::Session::LastFiles::const_iterator lfit = lf.begin();
 
        int ii = 1;
-       LastFiles::const_iterator lfit = lastfiles.begin();
-       LastFiles::const_iterator end = lastfiles.end();
 
-       for (; lfit != end && ii < 10; ++lfit, ++ii) {
+       for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
                string const label = convert<string>(ii) + ". "
-                       + MakeDisplayPath((*lfit), 30)
+                       + makeDisplayPath((*lfit), 30)
                        + '|' + convert<string>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view);
        }
@@ -458,7 +457,7 @@ void expandDocuments(Menu & tomenu, LyXView const * view)
        Strings::const_iterator docit = names.begin();
        Strings::const_iterator end = names.end();
        for (; docit != end; ++docit, ++ii) {
-               string label = MakeDisplayPath(*docit, 20);
+               string label = makeDisplayPath(*docit, 20);
                if (ii < 10)
                        label = convert<string>(ii) + ". " + label + '|' + convert<string>(ii);
                tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_SWITCHBUFFER, *docit)), view);
@@ -486,15 +485,15 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, LyXView const * view)
                action = LFUN_IMPORT;
                break;
        case MenuItem::ViewFormats:
-               formats = Exporter::GetExportableFormats(*view->buffer(), true);
+               formats = Exporter::getExportableFormats(*view->buffer(), true);
                action = LFUN_PREVIEW;
                break;
        case MenuItem::UpdateFormats:
-               formats = Exporter::GetExportableFormats(*view->buffer(), true);
+               formats = Exporter::getExportableFormats(*view->buffer(), true);
                action = LFUN_UPDATE;
                break;
        default:
-               formats = Exporter::GetExportableFormats(*view->buffer(), false);
+               formats = Exporter::getExportableFormats(*view->buffer(), false);
                action = LFUN_EXPORT;
        }
        sort(formats.begin(), formats.end(), compare_format());
@@ -517,6 +516,11 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, LyXView const * view)
                        else if ((*fit)->name() == "textparagraph")
                                label = _("Plain Text as Paragraphs");
                        label += "...";
+               } else if (kind == MenuItem::ExportFormats) {
+                       // exporting to LyX does not make sense
+                       // FIXME: Introduce noexport flag
+                       if ((*fit)->name() == "lyx")
+                               continue;
                }
                if (!(*fit)->shortcut().empty())
                        label += '|' + (*fit)->shortcut();
@@ -737,10 +741,10 @@ void expandBranches(Menu & tomenu, LyXView const * view)
        if (!view || !view->buffer())
                return;
 
-       BufferParams const & params = view->buffer()->params();
+       BufferParams const & params = view->buffer()->getMasterBuffer()->params();
 
-       std::list<Branch>::const_iterator cit = params.branchlist().begin();
-       std::list<Branch>::const_iterator end = params.branchlist().end();
+       BranchList::const_iterator cit = params.branchlist().begin();
+       BranchList::const_iterator end = params.branchlist().end();
 
        for (int ii = 1; cit != end; ++cit, ++ii) {
                string label = cit->getBranch();
@@ -759,6 +763,9 @@ void expandBranches(Menu & tomenu, LyXView const * view)
 void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                         LyXView const * view) const
 {
+       if (!tomenu.empty())
+               tomenu.clear();
+
        for (Menu::const_iterator cit = frommenu.begin();
             cit != frommenu.end() ; ++cit) {
                switch (cit->kind()) {