]> git.lyx.org Git - features.git/commitdiff
Fix two stupid bugs; fix stupidly a more subtile one
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 26 Jul 2000 14:08:09 +0000 (14:08 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 26 Jul 2000 14:08:09 +0000 (14:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@927 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
lib/ui/default.ui
src/MenuBackend.C
src/MenuBackend.h
src/ext_l10n.h
src/frontends/xforms/Menubar_pimpl.C
src/lyx_cb.C
src/lyxfunc.C
src/menus.C

index 44fa8df2d53f17cb3a0e4a3ba3f7234ea03b4e5a..df1ca33690d153c40e5db767be90ba4bddf814ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2000-07-26  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * 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  <jug@sad.it>
 
        * src/buffer.h: added functions setUnnamed(bool) and isUnnamed().
index a81ef0418ea39f4441bb435ab112c3991448b017..0cfb3eceff0770557d37f769a8831e58d8ab3c47 100644 (file)
@@ -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
 
index a5ab17d0a4c2194d2f4ef9d267a160e34dd505f4..1f77a866b03020a16cae0c0566ccbba0ce1c1d9f 100644 (file)
@@ -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();
+}
+
index b434e885f8d10a791fd2455cc3698c0833f4c946..161d9283dfb6c66e97d59c13985d254c01ba7966 100644 (file)
@@ -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(); }
index 59594de1bd9f5b15134bf88674d01005e89b1343..dfc27b8025554d631106eccc3f9d28a7cbec048d 100644 (file)
@@ -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");
index 7e486ad3fe98366328e2e37caca5dc4971fd688b..8aaa4eb270d6dfc4771d98e0fe5a7bdf661a5ecc 100644 (file)
@@ -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;
 } 
 
index c54fbfcfe5a34b1431e0831e0952decf3a932444..4f47c56621a9b923f805aaa315a6a97c16341458 100644 (file)
@@ -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);
index ae6fbaeecec3ed6325e3da06e40be35d59d7313d..9e184257cb159e3ae977625027f5500e07f4fdb9 100644 (file)
@@ -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;
index 6a86739199780f229ced9db7bc5e3dcfd8b256ef..d1b091df9324e96c2455d1103f47bb82df1b0361 100644 (file)
@@ -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;