1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibGUI+WindowServer: Add support for enabled/disabled actions.

The enabled state of a GAction now propagates both to any toolbar buttons
and any menu items linked to the action. Toolbar buttons are painted in
a grayed out style when disabled. Menu items are gray when disabled. :^)
This commit is contained in:
Andreas Kling 2019-04-12 02:53:27 +02:00
parent 32e5c8c689
commit 054c982181
20 changed files with 308 additions and 53 deletions

View file

@ -22,7 +22,6 @@
//#define GEVENTLOOP_DEBUG
//#define COALESCING_DEBUG
static HashMap<GShortcut, GAction*>* g_actions;
int GEventLoop::s_event_fd = -1;
pid_t GEventLoop::s_server_pid = -1;
@ -71,9 +70,6 @@ GEventLoop::GEventLoop()
connected = true;
}
if (!g_actions)
g_actions = new HashMap<GShortcut, GAction*>;
#ifdef GEVENTLOOP_DEBUG
dbgprintf("(%u) GEventLoop constructed :)\n", getpid());
#endif
@ -125,8 +121,10 @@ void GEventLoop::handle_key_event(const WSAPI_ServerMessage& event, GWindow& win
if (event.type == WSAPI_ServerMessage::Type::KeyDown) {
if (auto* action = GApplication::the().action_for_key_event(*key_event)) {
action->activate();
return;
if (action->is_enabled()) {
action->activate();
return;
}
}
}
post_event(window, move(key_event));