bool enable = true;
switch (cmd.action) {
- // FIXME: these cases should be hidden in GuiApplication::getStatus().
- case LFUN_WINDOW_CLOSE:
- if (theApp())
- return theApp()->getStatus(cmd);
- enable = false;
- break;
-
// FIXME optimally this should be in Text::getStatus. In such a case the flags
// are not passed when using context menu. This way it works.
case LFUN_SET_GRAPHICS_GROUP: {
break;
}
- case LFUN_BUFFER_NEW:
- case LFUN_BUFFER_NEW_TEMPLATE:
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD:
case LFUN_COMMAND_PREFIX:
case LFUN_BUFFER_AUTO_SAVE:
case LFUN_RECONFIGURE:
case LFUN_HELP_OPEN:
- case LFUN_FILE_OPEN:
case LFUN_DROP_LAYOUTS_CHOICE:
case LFUN_MENU_OPEN:
case LFUN_SERVER_GET_NAME:
case LFUN_BUFFER_EXPORT_CUSTOM:
case LFUN_BUFFER_PRINT:
case LFUN_PREFERENCES_SAVE:
- case LFUN_SCREEN_FONT_UPDATE:
- case LFUN_SET_COLOR:
case LFUN_MESSAGE:
case LFUN_INSET_EDIT:
case LFUN_ALL_INSETS_TOGGLE:
case LFUN_LYXRC_APPLY:
case LFUN_BUFFER_NEXT:
case LFUN_BUFFER_PREVIOUS:
- case LFUN_WINDOW_NEW:
- case LFUN_LYX_QUIT:
// these are handled in our dispatch()
break;
default:
+ if (!theApp()) {
+ enable = false;
+ break;
+ }
+ if (theApp()->getStatus(cmd, flag))
+ break;
+
// Does the view know something?
if (!lyx_view_) {
enable = false;
break;
}
- case LFUN_SET_COLOR: {
- string lyx_name;
- string const x11_name = split(argument, lyx_name, ' ');
- if (lyx_name.empty() || x11_name.empty()) {
- setErrorMessage(from_ascii(N_(
- "Syntax: set-color <lyx_name>"
- " <x11_name>")));
- break;
- }
-
- bool const graphicsbg_changed =
- (lyx_name == lcolor.getLyXName(Color_graphicsbg) &&
- x11_name != lcolor.getX11Name(Color_graphicsbg));
-
- if (!lcolor.setColor(lyx_name, x11_name)) {
- setErrorMessage(
- bformat(_("Set-color \"%1$s\" failed "
- "- color is undefined or "
- "may not be redefined"),
- from_utf8(lyx_name)));
- break;
- }
-
- theApp()->updateColor(lcolor.getFromLyXName(lyx_name));
-
- if (graphicsbg_changed) {
- // FIXME: The graphics cache no longer has a changeDisplay method.
-#if 0
- graphics::GCache::get().changeDisplay(true);
-#endif
- }
- break;
- }
-
case LFUN_MESSAGE:
LASSERT(lyx_view_, /**/);
lyx_view_->message(from_utf8(argument));
virtual ~Application() {}
///
- virtual FuncStatus getStatus(FuncRequest const & cmd) = 0;
+ virtual bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const = 0;
/// dispatch command.
/// \return true if the \c FuncRequest has been dispatched.
virtual bool dispatch(FuncRequest const & cmd) = 0;
*/
virtual std::string const hexName(ColorCode col) = 0;
- /**
- * update an altered GUI color
- */
- virtual void updateColor(ColorCode col) = 0;
-
/**
* read and create the menu structure
*/
#include "Buffer.h"
#include "BufferList.h"
#include "BufferView.h"
+#include "Color.h"
#include "Font.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
}
-FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
+bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const
{
- FuncStatus flag;
bool enable = true;
switch(cmd.action) {
enable = d->view_ids_.size() > 0;
break;
+ case LFUN_BUFFER_NEW:
+ case LFUN_BUFFER_NEW_TEMPLATE:
+ case LFUN_FILE_OPEN:
+ case LFUN_SCREEN_FONT_UPDATE:
+ case LFUN_SET_COLOR:
+ case LFUN_WINDOW_NEW:
+ case LFUN_LYX_QUIT:
+ enable = true;
+ break;
+
default:
- if (!current_view_) {
- enable = false;
- break;
- }
+ return false;
}
if (!enable)
flag.enabled(false);
- return flag;
+ return true;
}
current_view_->openDocument(to_utf8(cmd.argument()));
break;
+ case LFUN_SET_COLOR: {
+ string lyx_name;
+ string const x11_name = split(to_utf8(cmd.argument()), lyx_name, ' ');
+ if (lyx_name.empty() || x11_name.empty()) {
+ current_view_->message(
+ _("Syntax: set-color <lyx_name> <x11_name>"));
+ break;
+ }
+
+ string const graphicsbg = lcolor.getLyXName(Color_graphicsbg);
+ bool const graphicsbg_changed = lyx_name == graphicsbg
+ && x11_name != graphicsbg;
+ if (graphicsbg_changed) {
+ // FIXME: The graphics cache no longer has a changeDisplay method.
+#if 0
+ graphics::GCache::get().changeDisplay(true);
+#endif
+ }
+
+ if (!lcolor.setColor(lyx_name, x11_name)) {
+ current_view_->message(
+ bformat(_("Set-color \"%1$s\" failed "
+ "- color is undefined or "
+ "may not be redefined"),
+ from_utf8(lyx_name)));
+ break;
+ }
+ // Make sure we don't keep old colors in cache.
+ d->color_cache_.clear();
+ break;
+ }
+
default:
// Notify the caller that the action has not been dispatched.
return false;
}
-void GuiApplication::updateColor(ColorCode)
-{
- // FIXME: Bleh, can't we just clear them all at once ?
- d->color_cache_.clear();
-}
-
-
void GuiApplication::registerSocketCallback(int fd, SocketCallback func)
{
SocketNotifier * sn = new SocketNotifier(this, fd, func);
/// Method inherited from \c Application class
//@{
- FuncStatus getStatus(FuncRequest const &);
+ bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
bool dispatch(FuncRequest const &);
void resetGui();
void restoreGuiSession();
bool event(QEvent * e);
bool getRgbColor(ColorCode col, RGBColor & rgbcol);
std::string const hexName(ColorCode col);
- void updateColor(ColorCode col);
void readMenus(Lexer & lex);
void registerSocketCallback(int fd, SocketCallback func);
void unregisterSocketCallback(int fd);