#include #include #include #include static GApplication* s_the; GApplication& GApplication::the() { ASSERT(s_the); return *s_the; } GApplication::GApplication(int argc, char** argv) { (void)argc; (void)argv; ASSERT(!s_the); s_the = this; m_event_loop = make(); } GApplication::~GApplication() { } int GApplication::exec() { return m_event_loop->exec(); } void GApplication::quit(int exit_code) { m_event_loop->quit(exit_code); } void GApplication::set_menubar(OwnPtr&& menubar) { if (m_menubar) m_menubar->notify_removed_from_application(Badge()); m_menubar = move(menubar); if (m_menubar) m_menubar->notify_added_to_application(Badge()); } void GApplication::register_shortcut_action(Badge, GAction& action) { m_shortcut_actions.set(action.shortcut(), &action); } void GApplication::unregister_shortcut_action(Badge, GAction& action) { m_shortcut_actions.remove(action.shortcut()); } GAction* GApplication::action_for_key_event(const GKeyEvent& event) { auto it = m_shortcut_actions.find(GShortcut(event.modifiers(), (KeyCode)event.key())); if (it == m_shortcut_actions.end()) return nullptr; return (*it).value; }