X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMenuBackend.cpp;h=7865786ff3ff326297b4c0c1e704c8a5aeead262;hb=38a3692a0fce8b0531cef794a08d179e9e33ac33;hp=6250e49d4660d5248435e5d9c7932fbfd748293b;hpb=1d6c4787f9392169b78cac3a924818f2ebe1145d;p=lyx.git diff --git a/src/MenuBackend.cpp b/src/MenuBackend.cpp index 6250e49d46..7865786ff3 100644 --- a/src/MenuBackend.cpp +++ b/src/MenuBackend.cpp @@ -460,7 +460,7 @@ void expandDocuments(Menu & tomenu) Strings const names = theBufferList().getFileNames(); if (names.empty()) { - tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"), + tomenu.add(MenuItem(MenuItem::Command, _("No Document Open!"), FuncRequest(LFUN_NOACTION))); return; } @@ -486,7 +486,7 @@ void expandBookmarks(Menu & tomenu) docstring const label = convert(i) + ". " + makeDisplayPath(bm.bookmark(i).filename.absFilename(), 20) + char_type('|') + convert(i); - tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO, + tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BOOKMARK_GOTO, convert(i)))); } } @@ -497,7 +497,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,13 +569,13 @@ void expandFloatListInsert(Menu & tomenu, Buffer const * buf) { if (!buf) { tomenu.add(MenuItem(MenuItem::Command, - _("No Documents Open!"), + _("No Document Open!"), FuncRequest(LFUN_NOACTION))); return; } FloatList const & floats = - buf->params().getLyXTextClass().floats(); + buf->params().getTextClass().floats(); FloatList::const_iterator cit = floats.begin(); FloatList::const_iterator end = floats.end(); for (; cit != end; ++cit) { @@ -591,13 +591,13 @@ void expandFloatInsert(Menu & tomenu, Buffer const * buf) { if (!buf) { tomenu.add(MenuItem(MenuItem::Command, - _("No Documents Open!"), + _("No Document Open!"), FuncRequest(LFUN_NOACTION))); return; } FloatList const & floats = - buf->params().getLyXTextClass().floats(); + buf->params().getTextClass().floats(); FloatList::const_iterator cit = floats.begin(); FloatList::const_iterator end = floats.end(); for (; cit != end; ++cit) { @@ -614,12 +614,12 @@ void expandCharStyleInsert(Menu & tomenu, Buffer const * buf) { if (!buf) { tomenu.add(MenuItem(MenuItem::Command, - _("No Documents Open!"), + _("No Document Open!"), FuncRequest(LFUN_NOACTION))); return; } CharStyles & charstyles = - buf->params().getLyXTextClass().charstyles(); + buf->params().getTextClass().charstyles(); CharStyles::iterator cit = charstyles.begin(); CharStyles::iterator end = charstyles.end(); for (; cit != end; ++cit) { @@ -700,11 +700,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(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) { @@ -714,7 +718,7 @@ void expandToc(Menu & tomenu, Buffer const * buf) tomenu.add(MenuItem(MenuItem::Command, _("Master Document"), f)); } - FloatList const & floatlist = buf->params().getLyXTextClass().floats(); + FloatList const & floatlist = buf->params().getTextClass().floats(); TocList const & toc_list = buf->tocBackend().tocs(); TocList::const_iterator cit = toc_list.begin(); TocList::const_iterator end = toc_list.end(); @@ -734,7 +738,18 @@ void expandToc(Menu & tomenu, Buffer const * buf) FuncRequest(ccit->action()))); } string const & floatName = floatlist.getType(cit->first).listName(); - MenuItem item(MenuItem::Submenu, _(floatName)); + docstring label; + if (!floatName.empty()) + label = _(floatName); + // BUG3633: listings is not a proper float so its name + // is not shown in floatlist. + else if (cit->first == "listing") + label = _("List of listings"); + // this should not happen now, but if something else like + // listings is added later, this can avoid an empty menu name. + else + label = _("Other floats"); + MenuItem item(MenuItem::Submenu, label); item.submenu(menu.release()); tomenu.add(item); } @@ -778,29 +793,40 @@ 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. - // - // menu is displayed as + // 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 - // and + // and // review (auto) // in the case of auto. 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();