From aa5aac89dec42cb52415002f6de9c3532613e527 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 26 Jul 2000 14:08:09 +0000 Subject: [PATCH] Fix two stupid bugs; fix stupidly a more subtile one git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@927 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 21 +++++++++++++ lib/ui/default.ui | 8 +++-- src/MenuBackend.C | 44 ++++++++++++++++++++-------- src/MenuBackend.h | 4 ++- src/ext_l10n.h | 3 +- src/frontends/xforms/Menubar_pimpl.C | 12 +++++++- src/lyx_cb.C | 15 ++++------ src/lyxfunc.C | 16 +++++----- src/menus.C | 8 +---- 9 files changed, 87 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44fa8df2d5..df1ca33690 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2000-07-26 Jean-Marc Lasgouttes + + * src/frontends/xforms/Menubar_pimpl.C (set): fix the disappearing + shortcuts syndrom by redrawing them explicitely (a better solution + would be appreciated). + + * src/lyxfunc.C (getStatus): fix crash when functions are disabled. + + * src/frontends/xforms/Menubar_pimpl.C (set): fix the shortcut of + the button. + + * src/lyx_cb.C (MenuExport): change html export to do the right + thing depending of the document type (instead of having + html-linuxdoc and html-docbook). + * src/lyxfunc.C (getStatus): update for html + * lib/ui/default.ui: simplify due to the above change. + * src/menus.C (ShowFileMenu): update too (in case we need it). + + * src/MenuBackend.C (read): if a menu is defined twice, add the + new entries to the exiting one. + 2000-07-26 Juergen Vigna * src/buffer.h: added functions setUnnamed(bool) and isUnnamed(). diff --git a/lib/ui/default.ui b/lib/ui/default.ui index a81ef0418e..0cfb3eceff 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -16,6 +16,10 @@ Menuset Submenu "Help|H" "help" End +MenuBar "main" + Submenu "File|F" "file" +End + Menubar "main_nobuffer" Submenu "File|F" "file_nobuffer" Submenu "Options|O" "options" @@ -74,9 +78,7 @@ Menuset Item "as DVI|D" "buffer-export dvi" Item "as Postscript|P" "buffer-export postscript" Item "as Ascii|A" "buffer-export ascii" - OptItem "as HTML|H" "buffer-export html" - OptItem "as HTML|H" "buffer-export html-linuxdoc" - OptItem "as HTML|H" "buffer-export html-docbook" + Item "as HTML|H" "buffer-export html" OptItem "Custom...|C" "buffer-export custom" End diff --git a/src/MenuBackend.C b/src/MenuBackend.C index a5ab17d0a4..1f77a866b0 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -64,7 +64,7 @@ Menu & Menu::add(MenuItem const & i) } -void Menu::read(LyXLex & lex) +Menu & Menu::read(LyXLex & lex) { enum Menutags { md_item = 1, @@ -140,6 +140,7 @@ void Menu::read(LyXLex & lex) } } lex.popTable(); + return *this; } @@ -168,23 +169,29 @@ void MenuBackend::read(LyXLex & lex) lex.printTable(lyxerr); bool quit = false; + bool menubar = false; while (lex.IsOK() && !quit) { switch(lex.lex()) { + case md_menubar: + menubar = true; + // fallback to md_menu case md_menu: { lex.next(); string name = lex.GetString(); - Menu menu(name, false); - menu.read(lex); - add(menu); - break; - } - case md_menubar: { - lex.next(); - string name = lex.GetString(); - Menu menubar(name, true); - menubar.read(lex); - add(menubar); + if (hasMenu(name)) { + if (getMenu(name).menubar() == menubar) { + getMenu(name).read(lex); + } else { + lex.printError("Cannot append to menu `$$Token' unless it is of the same type"); + return; + } + } else { + Menu menu(name, menubar); + menu.read(lex); + add(menu); + } + menubar = false; break; } case md_endmenuset: @@ -284,3 +291,16 @@ Menu const & MenuBackend::getMenu(string const & name) const Assert(false); // we actually require the name to exist. return menulist_.front(); } + + +Menu & MenuBackend::getMenu(string const & name) +{ + for (MenuList::iterator cit = menulist_.begin(); + cit != menulist_.end(); ++cit) { + if ((*cit).name() == name) + return (*cit); + } + Assert(false); // we actually require the name to exist. + return menulist_.front(); +} + diff --git a/src/MenuBackend.h b/src/MenuBackend.h index b434e885f8..161d9283df 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -86,7 +86,7 @@ public: /// Menu & add(MenuItem const &); /// - void read(LyXLex &); + Menu & read(LyXLex &); /// bool menubar() const { return menubar_; } /// @@ -128,6 +128,8 @@ public: /// bool hasMenu (string const &) const; /// + Menu & getMenu (string const &); + /// Menu const & getMenu (string const &) const; // bool empty() const { return menulist_.empty(); } diff --git a/src/ext_l10n.h b/src/ext_l10n.h index 59594de1bd..dfc27b8025 100644 --- a/src/ext_l10n.h +++ b/src/ext_l10n.h @@ -7,6 +7,7 @@ _("Options|O"); _("Documents|D"); _("Help|H"); _("File|F"); +_("File|F"); _("Options|O"); _("Help|H"); _("New...|N"); @@ -42,8 +43,6 @@ _("as DVI|D"); _("as Postscript|P"); _("as Ascii|A"); _("as HTML|H"); -_("as HTML|H"); -_("as HTML|H"); _("Custom...|C"); _("Undo|U"); _("Redo|R"); diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 7e486ad3fe..8aaa4eb270 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -158,7 +158,7 @@ void Menubar::Pimpl::set(string const & menu_name) break; } string label = i->label(); - string shortcut = i->shortcut(); + string shortcut = '#' + i->shortcut(); int width = string_width(label); obj = fl_add_button(FL_TOUCH_BUTTON, air + moffset, yloc, @@ -175,6 +175,7 @@ void Menubar::Pimpl::set(string const & menu_name) moffset += obj->w + air; fl_set_object_shortcut(obj, shortcut.c_str(), 1); fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1); + ItemInfo * iteminfo = new ItemInfo(this, new MenuItem(*i), obj); buttonlist_.push_back(iteminfo); @@ -191,6 +192,15 @@ void Menubar::Pimpl::set(string const & menu_name) if (!form_was_open) fl_end_form(); + // Force the redraw of the buttons (probably not the best + // method, but...) + for(ButtonList::const_iterator cit = buttonlist_.begin(); + cit != buttonlist_.end(); ++cit) { + if ((*cit)->obj_) { + fl_redraw_object((*cit)->obj_); + } + } + lyxerr[Debug::GUI] << "Menubar set." << endl; } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c54fbfcfe5..4f47c56621 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -934,15 +934,12 @@ void MenuExport(Buffer * buffer, string const & extyp) } // HTML else if (extyp == "html") { - MenuMakeHTML(buffer); - } - // HTML from linuxdoc - else if (extyp == "html-linuxdoc") { - MenuMakeHTML_LinuxDoc(buffer); - } - // HTML from docbook - else if (extyp == "html-docbook") { - MenuMakeHTML_DocBook(buffer); + if (buffer->isLinuxDoc()) + MenuMakeHTML_LinuxDoc(buffer); + else if (buffer->isDocBook()) + MenuMakeHTML_DocBook(buffer); + else + MenuMakeHTML(buffer); } else { ShowMessage(buffer, _("Unknown export type: ") + extyp); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ae6fbaeece..9e184257cb 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -349,13 +349,13 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const // no setErrorMessage(N_("Document is read-only")); flag |= LyXFunc::Disabled; - return flag; } } else { // no setErrorMessage(N_("Command not allowed with" "out any document open")); flag |= LyXFunc::Disabled; + return flag; } } @@ -396,14 +396,12 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const else if (argument == "dvi" || argument == "postscript") disable = noLaTeX; else if (argument == "html") - disable = (! buf->isLatex() - || lyxrc.html_command == "none"); - else if (argument == "html-linuxdoc") - disable = (! buf->isLinuxDoc() - || lyxrc.linuxdoc_to_html_command == "none"); - else if (argument == "html-docbook") - disable = (! buf->isDocBook() - || lyxrc.docbook_to_html_command == "none"); + disable = (buf->isLinuxDoc() + && lyxrc.linuxdoc_to_html_command == "none") + || (buf->isDocBook() + && lyxrc.docbook_to_html_command == "none") + || (! buf->isLinuxDoc() && ! buf->isDocBook() + && lyxrc.html_command == "none"); else if (argument == "custom") disable = ! buf->isLatex(); break; diff --git a/src/menus.C b/src/menus.C index 6a86739199..d1b091df93 100644 --- a/src/menus.C +++ b/src/menus.C @@ -725,13 +725,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long) break; case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii"); break; - case 44: - if (!LinuxDoc && !DocBook) - tmpfunc->Dispatch(LFUN_EXPORT, "html"); - else if(LinuxDoc) - tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc"); - else - tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook"); + case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html"); break; case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom"); break; -- 2.39.2