correctly disable buffer-related menu entries when a dialog has focus (bug 1720)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9258 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-11-16 10:46:23 +00:00
parent 59cd5ec173
commit 3c6f968676
15 changed files with 86 additions and 25 deletions

View File

@ -35,14 +35,18 @@ src/frontends/gnome/GLog.C
src/frontends/gnome/support.c
src/frontends/gtk/Dialogs.C
src/frontends/gtk/GBC.h
src/frontends/gtk/GBox.C
src/frontends/gtk/GChanges.C
src/frontends/gtk/GCharacter.C
src/frontends/gtk/GERT.C
src/frontends/gtk/GErrorList.C
src/frontends/gtk/GFloat.C
src/frontends/gtk/GGraphics.C
src/frontends/gtk/GLog.C
src/frontends/gtk/GMathDelim.C
src/frontends/gtk/GMathPanel.C
src/frontends/gtk/GMathsMatrix.C
src/frontends/gtk/GNote.C
src/frontends/gtk/GParagraph.C
src/frontends/gtk/GSearch.C
src/frontends/gtk/GShowFile.C
@ -51,6 +55,7 @@ src/frontends/gtk/GTableCreate.C
src/frontends/gtk/GTexinfo.C
src/frontends/gtk/GToc.C
src/frontends/gtk/GUrl.C
src/frontends/gtk/GVSpace.C
src/frontends/qt2/Alert_pimpl.C
src/frontends/qt2/BulletsModule.C
src/frontends/qt2/Dialogs.C

View File

@ -1,7 +1,17 @@
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lyxfunc.C (getStatus): when the origin of the request is menu or
toolbar, and the LyXView does not have focus, do as if there was
no buffer (bug 1720)
* lyxfunc.C (getStatus, dispatch): propagate the origin of a
FuncRequest to individual entries of LFUN_SEQUENCE
2004-11-10 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* output_latex.C (TeXOnePar): override runparams.moving_arg
according to the needprotect value of the current paragraph (bug 1739)
according to the needprotect value of the current paragraph (bug
1739)
* paragraph.C (simpleTeXOnePar): no need to override
runparams.moving_args here

View File

@ -1,3 +1,7 @@
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* LyXView.h (hasFocus): new abstract virtual function
2004-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* Toolbars.C (layoutSelected): new method, which was triplicated

View File

@ -142,6 +142,9 @@ public:
*/
Buffer const * const updateInset(InsetBase const *) const;
// returns true if this view has the focus.
virtual bool hasFocus() const = 0;
protected:
/// view of a buffer. Eventually there will be several.
boost::shared_ptr<BufferView> bufferview_;

View File

@ -1,3 +1,7 @@
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* GView.C (hasFocus): new method, always returns true for now
2004-11-15 John Spray <spray_john@users.sourceforge.net>
* The VSpace Dialog:

View File

@ -171,5 +171,13 @@ void GView::clearMessage()
message(getLyXFunc().viewStatusMessage());
}
bool GView::hasFocus() const
{
// No real implementation needed for now
return true;
}
} // namespace frontend
} // namespace lyx

View File

@ -51,6 +51,10 @@ public:
virtual void busy(bool) const;
/// clear any temporary message and replace with current status
virtual void clearMessage();
// returns true if this view has the focus.
virtual bool hasFocus() const;
private:
void showViewState();
bool onFocusIn(GdkEventFocus * event);

View File

@ -1,3 +1,10 @@
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QtView.C (hasFocus): new method
* QLPopupMenu.C (populate): remove a Qt/Mac hack to disable some
menu entries when the main window does not have focus
2004-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QLToolbar.C (selected): use layoutSelected

View File

@ -24,7 +24,6 @@
#ifdef Q_WS_MACX
#include "kbmap.h"
#include "LyXAction.h"
#include "QLyXKeySym.h"
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
#endif
@ -122,26 +121,6 @@ void QLPopupMenu::populate(Menu * menu)
QString label = toqstr(getLabel(*m));
#ifdef Q_WS_MACX
/* In LyX/Mac, when a dialog is open, the
menus of the application can still be
accessed without giving focus to the main
window. In this case, we want to disable the
menu entries that are buffer-related.
*/
/* This test is actually not adequate,
for example "dialog-show document" is not
correctly disabled. What should be done
(but is maybe hackish) define a version of
LyXFunc::getStatus that takes a Buffer* as
argument, so that we can call it with buf=0
(JMarc)
*/
if (status.enabled()
&& qApp->activeWindow() != qApp->mainWidget()
&& !lyxaction.funcHasFlag(m->func().action,
LyXAction::NoBuffer))
status.enabled(false);
/* There are two constraints on Qt/Mac: (1)
the bindings require a unicode string to be
represented meaningfully and std::string

View File

@ -144,6 +144,12 @@ void QtView::activated(FuncRequest const & func)
}
bool QtView::hasFocus() const
{
return qApp->activeWindow() == this;
}
void QtView::closeEvent(QCloseEvent *)
{
QuitLyX();

View File

@ -59,6 +59,9 @@ public:
/// menu item has been selected
void activated(FuncRequest const &);
// returns true if this view has the focus.
virtual bool hasFocus() const;
public slots:
/// idle timeout
void update_view_state_qt();

View File

@ -1,3 +1,7 @@
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XFormsView.C (hasFocus): new method, always returns true for now
2004-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XFormsToolbar.C (selected): use layoutSelected

View File

@ -218,6 +218,13 @@ void XFormsView::updateMetrics(bool resize_form)
}
bool XFormsView::hasFocus() const
{
// No real implementation needed for now
return true;
}
void XFormsView::setWindowTitle(string const & title, string const & icon_title)
{
fl_set_form_title(getForm(), title.c_str());

View File

@ -79,6 +79,9 @@ public:
///
boost::signal<void()> metricsUpdated;
// returns true if this view has the focus.
virtual bool hasFocus() const;
private:
/**
* setWindowTitle - set title of window

View File

@ -272,9 +272,19 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
{
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
FuncStatus flag;
Buffer * buf = owner->buffer();
LCursor & cur = view()->cursor();
/* In LyX/Mac, when a dialog is open, the menus of the
application can still be accessed without giving focus to
the main window. In this case, we want to disable the menu
entries that are buffer-related.
*/
Buffer * buf;
if (cmd.origin == FuncRequest::UI && !owner->hasFocus())
buf = 0;
else
buf = owner->buffer();
if (cmd.action == LFUN_NOACTION) {
setStatusMessage(N_("Nothing to do"));
flag.enabled(false);
@ -447,7 +457,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
case LFUN_SEQUENCE: {
// argument contains ';'-terminated commands
string const firstcmd = token(cmd.argument, ';', 0);
flag = getStatus(lyxaction.lookupFunc(firstcmd));
FuncRequest func(lyxaction.lookupFunc(firstcmd));
func.origin = cmd.origin;
flag = getStatus(func);
}
case LFUN_MENUNEW:
@ -1219,7 +1231,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
while (!arg.empty()) {
string first;
arg = split(arg, first, ';');
dispatch(lyxaction.lookupFunc(first));
FuncRequest func(lyxaction.lookupFunc(first));
func.origin = cmd.origin;
dispatch(func);
}
break;
}