]> git.lyx.org Git - lyx.git/blobdiff - src/MenuBackend.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / MenuBackend.cpp
index bde9cc0a7b3262aa76bf9e933696476876c9995c..0180e42271ec6bad779be2e6bef346effdad627a 100644 (file)
@@ -456,24 +456,27 @@ void expandLastfiles(Menu & tomenu)
 
 void expandDocuments(Menu & tomenu)
 {
-       typedef vector<string> Strings;
-       Strings const names = theBufferList().getFileNames();
-
-       if (names.empty()) {
+       Buffer * first = theBufferList().first();
+       if (first) {
+               Buffer * b = first;
+               int ii = 1;
+               
+               // We cannot use a for loop as the buffer list cycles.
+               do {
+                       docstring label = makeDisplayPath(b->fileName(), 20);
+                       if (!b->isClean()) label = label + "*";
+                       if (ii < 10)
+                               label = convert<docstring>(ii) + ". " + label + '|' + convert<docstring>(ii);
+                       tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, b->fileName())));
+                       
+                       b = theBufferList().next(b);
+                       ++ii;
+               } while (b != first); 
+       } else {
                tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"),
-                                   FuncRequest(LFUN_NOACTION)));
+                          FuncRequest(LFUN_NOACTION)));
                return;
        }
-
-       int ii = 1;
-       Strings::const_iterator docit = names.begin();
-       Strings::const_iterator end = names.end();
-       for (; docit != end; ++docit, ++ii) {
-               docstring label = makeDisplayPath(*docit, 20);
-               if (ii < 10)
-                       label = convert<docstring>(ii) + ". " + label + char_type('|') + convert<docstring>(ii);
-               tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit)));
-       }
 }
 
 
@@ -497,7 +500,7 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
 {
        if (!buf && kind != MenuItem::ImportFormats) {
                tomenu.add(MenuItem(MenuItem::Command,
-                                   _("No Documents Open!"),
+                                   _("No Document Open!"),
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
@@ -569,7 +572,7 @@ void expandFloatListInsert(Menu & tomenu, Buffer const * buf)
 {
        if (!buf) {
                tomenu.add(MenuItem(MenuItem::Command,
-                                   _("No Documents Open!"),
+                                   _("No Document Open!"),
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
@@ -591,7 +594,7 @@ void expandFloatInsert(Menu & tomenu, Buffer const * buf)
 {
        if (!buf) {
                tomenu.add(MenuItem(MenuItem::Command,
-                                   _("No Documents Open!"),
+                                   _("No Document Open!"),
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
@@ -614,7 +617,7 @@ void expandCharStyleInsert(Menu & tomenu, Buffer const * buf)
 {
        if (!buf) {
                tomenu.add(MenuItem(MenuItem::Command,
-                                   _("No Documents Open!"),
+                                   _("No Document Open!"),
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
@@ -700,11 +703,15 @@ void expandToc(Menu & tomenu, Buffer const * buf)
 
        if (!buf) {
                tomenu.add(MenuItem(MenuItem::Command,
-                                   _("No Documents Open!"),
+                                   _("No Document Open!"),
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
 
+       Buffer* cbuf = const_cast<Buffer*>(buf);
+       cbuf->tocBackend().update();
+       cbuf->structureChanged();
+
        // Add an entry for the master doc if this is a child doc
        Buffer const * const master = buf->getMasterBuffer();
        if (buf != master) {
@@ -789,9 +796,10 @@ void expandToolbars(Menu & tomenu)
 
        for (; cit != end; ++cit) {
                docstring label = _(cit->gui_name);
-               // frontends are not supposed to turn on/off toolbars, if they cannot
-               // update ToolbarBackend::flags. That is to say, ToolbarsBackend::flags
-               // should reflect the true state of toolbars.
+               // frontends are not supposed to turn on/off toolbars,
+               // if they cannot update ToolbarBackend::flags. That
+               // is to say, ToolbarsBackend::flags should reflect
+               // the true state of toolbars.
                //
                // menu is displayed as
                //       on/off review
@@ -801,17 +809,27 @@ void expandToolbars(Menu & tomenu)
                if (cit->flags & ToolbarInfo::AUTO)
                        label += _(" (auto)");
                tomenu.add(MenuItem(MenuItem::Command, label,
-                                   FuncRequest(LFUN_TOOLBAR_TOGGLE_STATE, cit->name)));
+                                   FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name + " allowauto")));
        }
 }
 
 
 void expandBranches(Menu & tomenu, Buffer const * buf)
 {
-       if (!buf)
+       if (!buf) {
+               tomenu.add(MenuItem(MenuItem::Command,
+                                   _("No Document Open!"),
+                                   FuncRequest(LFUN_NOACTION)));
                return;
+       }
 
        BufferParams const & params = buf->getMasterBuffer()->params();
+       if (params.branchlist().empty()) {
+               tomenu.add(MenuItem(MenuItem::Command,
+                                   _("No Branch in Document!"),
+                                   FuncRequest(LFUN_NOACTION)));
+               return;
+       }
 
        BranchList::const_iterator cit = params.branchlist().begin();
        BranchList::const_iterator end = params.branchlist().end();