summaryrefslogtreecommitdiff
path: root/LibGUI/GApplication.cpp
blob: f212bbf2028f8eb14a69e662cbde1c46b7e756ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <LibGUI/GApplication.h>
#include <LibGUI/GEventLoop.h>
#include <LibGUI/GMenuBar.h>

static GApplication* s_the;

GApplication& GApplication::the()
{
    ASSERT(s_the);
    return *s_the;
}

GApplication::GApplication(int argc, char** argv)
{
    ASSERT(!s_the);
    s_the = this;
    m_event_loop = make<GEventLoop>();
}

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<GMenuBar>&& menubar)
{
    if (m_menubar)
        m_menubar->notify_removed_from_application(Badge<GApplication>());
    m_menubar = move(menubar);
    if (m_menubar)
        m_menubar->notify_added_to_application(Badge<GApplication>());
}