-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuitarApp.cpp
90 lines (67 loc) · 1.93 KB
/
GuitarApp.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
///////////////////////////////////////////////////////////////////
#include "GuitarView.h"
#include <gtkmm/stylecontext.h>
///////////////////////////////////////////////////////////////////
class GuitarApp
{
public:
int main(int argc, char**argv);
private:
void activate();
void shutdown();
private:
Glib::RefPtr<Gtk::Application> m_app;
GuitarView m_guitarView;
};
///////////////////////////////////////////////////////////////////
int
GuitarApp::main(int argc, char**argv)
{
m_app = Gtk::Application::create();
m_app->signal_activate().connect(sigc::mem_fun(*this, &GuitarApp::activate));
m_app->signal_shutdown().connect(sigc::mem_fun(*this, &GuitarApp::shutdown));
int ret = m_app->run();
return ret;
}
///////////////////////////////////////////////////////////////////
void
GuitarApp::activate()
{
// Load the XML file and instantiate its widgets:
auto builder = Gtk::Builder::create();
try
{
builder->add_from_file("GuitarAppUi.ui");
}
catch (const Glib::Error& error)
{
std::cout << "Error loading GuitarAppUi.glade: " << error.what() << std::endl;
return;
}
// Get the GtkBuilder-instantiated window:
auto pWindow = builder->get_widget<Gtk::ApplicationWindow>("main_window");
if (!pWindow)
{
std::cout << "Could not get 'main_window' from the builder." << std::endl;
return;
}
m_app->add_window(*pWindow);
m_guitarView.init(builder, m_app);
auto css = Gtk::CssProvider::create();
css->load_from_path("GuitarView.css");
Gtk::StyleContext::add_provider_for_display(pWindow->get_display(),css,GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
pWindow->show();
}
///////////////////////////////////////////////////////////////////
void
GuitarApp::shutdown()
{
m_guitarView.shutdown();
}
///////////////////////////////////////////////////////////////////
int main(int argc, char**argv)
{
GuitarApp guitarApp;
return(guitarApp.main(argc,argv));
}
///////////////////////////////////////////////////////////////////