>>>>> "Bennett" == Bennett Helm <[EMAIL PROTECTED]> writes:
Bennett> On Oct 14, 2006, at 11:46 AM, Jean-Marc Lasgouttes wrote: >> This patch (against 1.4) should >> >> 1/ reimplement the OSX feature that greys-out unavailable actions >> when a dialog is active Bennett> This mostly works, though with a few oddities. The following Bennett> menu options remain active when a dialog is frontmost: Here is an updated patch for 1.4. Bennett, could you check that it still works and that it disables correctly the navigation entries? There is also the corresponding 1.5 patch, that is straightforward enough to go in right now. Abdel, agreed? What is missing in the 1.5 version is use of add vs. addWithStatusCheck. Abdel, do you agree that all code in expandFoo should use the later? Alternatively, menus could have a checkstatus bool telling whether entries added to them should be checked. JMarc
Index: src/ChangeLog =================================================================== --- src/ChangeLog (revision 15576) +++ src/ChangeLog (working copy) @@ -1,3 +1,18 @@ +2006-10-27 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * MenuBackend.C (expandToc2, expandToc): add a view argument in + order to disable correclty the entries when needed. + + * lyxfunc.C (dispatch): update menus and toolbars here + (getStatus): only honor LyXView::hasFocus when command originates + from a menu (bug 2877) + + * funcrequest.h: split the UI enum value into TOOLBAR and MENU. + + * lyxfunc.C (sendDispatchMessage): + * MenuBackend.C (MenuItem): + * ToolbarBackend.C (add): adapt to the change above. + 2006-10-26 Enrico Forestieri <[EMAIL PROTECTED]> * lfuns.h (enum kb_action): New lfun LFUN_MATH_BIGDELIM Index: src/lyxfunc.C =================================================================== --- src/lyxfunc.C (revision 15576) +++ src/lyxfunc.C (working copy) @@ -345,7 +345,7 @@ FuncStatus LyXFunc::getStatus(FuncReques http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4 */ Buffer * buf; - if (cmd.origin == FuncRequest::UI && !owner->hasFocus()) + if (cmd.origin == FuncRequest::MENU && !owner->hasFocus()) buf = 0; else buf = owner->buffer(); @@ -1609,23 +1609,16 @@ void LyXFunc::dispatch(FuncRequest const view()->owner()->updateLayoutChoice(); } } + owner->updateMenubar(); + owner->updateToolbars(); sendDispatchMessage(_(getMessage()), cmd); } void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd) { - /* When an action did not originate from the UI/kbd, it makes - * sense to avoid updating the GUI. It turns out that this - * fixes bug 1941, for reasons that are described here: - * http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4 - */ - if (cmd.origin != FuncRequest::INTERNAL) { - owner->updateMenubar(); - owner->updateToolbars(); - } - - const bool verbose = (cmd.origin == FuncRequest::UI + const bool verbose = (cmd.origin == FuncRequest::MENU + || cmd.origin == FuncRequest::TOOLBAR || cmd.origin == FuncRequest::COMMANDBUFFER); if (cmd.action == LFUN_SELFINSERT || !verbose) { Index: src/frontends/Toolbars.C =================================================================== --- src/frontends/Toolbars.C (revision 15576) +++ src/frontends/Toolbars.C (working copy) @@ -168,7 +168,7 @@ void layoutSelected(LyXView & lv, string // Yes, the _() is correct if (_(itname) == name) { FuncRequest const func(LFUN_LAYOUT, itname, - FuncRequest::UI); + FuncRequest::TOOLBAR); lv.getLyXFunc().dispatch(func); return; } Index: src/frontends/qt2/ChangeLog =================================================================== --- src/frontends/qt2/ChangeLog (revision 15576) +++ src/frontends/qt2/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2006-10-27 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * QtView.C (hasFocus): return a correct value now (and fix bug 1720). + 2006-10-26 Enrico Forestieri <[EMAIL PROTECTED]> * QDelimiterDialog.[Ch] (fix_name, QDelimiterDialog, insertClicked, Index: src/frontends/qt2/QtView.C =================================================================== --- src/frontends/qt2/QtView.C (revision 15576) +++ src/frontends/qt2/QtView.C (working copy) @@ -149,11 +149,7 @@ void QtView::activated(FuncRequest const bool QtView::hasFocus() const { -#if 0 return qApp->activeWindow() == this; -#else - return true; -#endif } Index: src/frontends/ChangeLog =================================================================== --- src/frontends/ChangeLog (revision 15576) +++ src/frontends/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2006-10-27 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * Toolbars.C (layoutSelected): adapt to FuncRequest changes. + 2006-09-19 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * WorkArea.h: revert patch to bug 2423. Index: src/funcrequest.h =================================================================== --- src/funcrequest.h (revision 15576) +++ src/funcrequest.h (working copy) @@ -28,7 +28,8 @@ public: /// Where the request came from enum Origin { INTERNAL, - UI, // The menu or the toolbar + MENU, // A menu entry + TOOLBAR, // A toolbar icon KEYBOARD, // a keyboard binding COMMANDBUFFER }; Index: src/MenuBackend.C =================================================================== --- src/MenuBackend.C (revision 15576) +++ src/MenuBackend.C (working copy) @@ -106,7 +106,7 @@ MenuItem::MenuItem(Kind kind, string con FuncRequest const & func, bool optional) : kind_(kind), label_(label), func_(func), optional_(optional) { - func_.origin = FuncRequest::UI; + func_.origin = FuncRequest::MENU; } @@ -606,7 +606,7 @@ void expandCharStyleInsert(Menu & tomenu Menu::size_type const max_number_of_items = 25; -void expandToc2(Menu & tomenu, +void expandToc2(Menu & tomenu, LyXView const * view, lyx::toc::Toc const & toc_list, lyx::toc::Toc::size_type from, lyx::toc::Toc::size_type to, int depth) @@ -654,7 +654,7 @@ void expandToc2(Menu & tomenu, } else { MenuItem item(MenuItem::Submenu, label); item.submenu(new Menu); - expandToc2(*item.submenu(), + expandToc2(*item.submenu(), view, toc_list, pos, new_pos, depth + 1); tomenu.add(item); } @@ -666,12 +666,6 @@ void expandToc2(Menu & tomenu, void expandToc(Menu & tomenu, LyXView const * view) { - // To make things very cleanly, we would have to pass view to - // all MenuItem constructors and to expandToc2. However, we - // know that all the entries in a TOC will be have status_ == - // OK, so we avoid this unnecessary overhead (JMarc) - - Buffer const * buf = view->buffer(); if (!buf) { tomenu.add(MenuItem(MenuItem::Command, @@ -698,12 +692,12 @@ void expandToc(Menu & tomenu, LyXView co string const label = limit_string_length(ccit->str); menu->add(MenuItem(MenuItem::Command, label, - FuncRequest(ccit->action()))); + FuncRequest(ccit->action())), view); } string const & floatName = floatlist.getType(cit->first).listName(); MenuItem item(MenuItem::Submenu, _(floatName)); item.submenu(menu.release()); - tomenu.add(item); + tomenu.add(item, view); } // Handle normal TOC @@ -714,7 +708,7 @@ void expandToc(Menu & tomenu, LyXView co FuncRequest()), view); } else { - expandToc2(tomenu, cit->second, 0, cit->second.size(), 0); + expandToc2(tomenu, view, cit->second, 0, cit->second.size(), 0); } } Index: src/ToolbarBackend.C =================================================================== --- src/ToolbarBackend.C (revision 15576) +++ src/ToolbarBackend.C (working copy) @@ -207,7 +207,7 @@ void ToolbarBackend::add(Toolbar & tb, FuncRequest const & func, string const & tooltip) { tb.items.push_back(make_pair(func, tooltip)); - tb.items.back().first.origin = FuncRequest::UI; + tb.items.back().first.origin = FuncRequest::TOOLBAR; }
Index: src/lyxfunc.C =================================================================== --- src/lyxfunc.C (revision 15573) +++ src/lyxfunc.C (working copy) @@ -365,7 +365,7 @@ FuncStatus LyXFunc::getStatus(FuncReques http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4 */ Buffer * buf; - if (cmd.origin == FuncRequest::UI && !lyx_view_->hasFocus()) + if (cmd.origin == FuncRequest::MENU && !lyx_view_->hasFocus()) buf = 0; else buf = lyx_view_->buffer(); @@ -1697,26 +1697,20 @@ void LyXFunc::dispatch(FuncRequest const } } } - if (!quitting) + if (!quitting) { + lyx_view_->updateMenubar(); + lyx_view_->updateToolbars(); // FIXME UNICODE: _() does not support anything but ascii. // Do we need a to_ascii() method? sendDispatchMessage(getMessage(), cmd); + } } void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd) { - /* When an action did not originate from the UI/kbd, it makes - * sense to avoid updating the GUI. It turns out that this - * fixes bug 1941, for reasons that are described here: - * http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4 - */ - if (cmd.origin != FuncRequest::INTERNAL) { - lyx_view_->updateMenubar(); - lyx_view_->updateToolbars(); - } - - const bool verbose = (cmd.origin == FuncRequest::UI + const bool verbose = (cmd.origin == FuncRequest::MENU + || cmd.origin == FuncRequest::TOOLBAR || cmd.origin == FuncRequest::COMMANDBUFFER); if (cmd.action == LFUN_SELF_INSERT || !verbose) { Index: src/frontends/Toolbars.C =================================================================== --- src/frontends/Toolbars.C (revision 15573) +++ src/frontends/Toolbars.C (working copy) @@ -171,7 +171,7 @@ void layoutSelected(LyXView & lv, string // Yes, the lyx::to_utf8(_()) is correct if (lyx::to_utf8(_(itname)) == name) { FuncRequest const func(LFUN_LAYOUT, itname, - FuncRequest::UI); + FuncRequest::TOOLBAR); lv.dispatch(func); return; } Index: src/funcrequest.h =================================================================== --- src/funcrequest.h (revision 15573) +++ src/funcrequest.h (working copy) @@ -32,7 +32,8 @@ public: /// Where the request came from enum Origin { INTERNAL, - UI, // The menu or the toolbar + MENU, // A menu entry + TOOLBAR, // A toolbar icon KEYBOARD, // a keyboard binding COMMANDBUFFER }; Index: src/MenuBackend.C =================================================================== --- src/MenuBackend.C (revision 15573) +++ src/MenuBackend.C (working copy) @@ -105,7 +105,7 @@ MenuItem::MenuItem(Kind kind, docstring FuncRequest const & func, bool optional) : kind_(kind), label_(label), func_(func), optional_(optional) { - func_.origin = FuncRequest::UI; + func_.origin = FuncRequest::MENU; } Index: src/ToolbarBackend.C =================================================================== --- src/ToolbarBackend.C (revision 15573) +++ src/ToolbarBackend.C (working copy) @@ -210,7 +210,7 @@ void ToolbarBackend::add(Toolbar & tb, FuncRequest const & func, docstring const & tooltip) { tb.items.push_back(make_pair(func, tooltip)); - tb.items.back().first.origin = FuncRequest::UI; + tb.items.back().first.origin = FuncRequest::TOOLBAR; }