-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
52 lines (45 loc) · 1.15 KB
/
main.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
#include <iostream>
#include <string>
#include <glibmm/fileutils.h>
#include <glibmm/markup.h>
#include <libconfig.h++>
#include "MainWindow.h"
using namespace std;
using namespace libconfig;
int main(int argc, char **argv)
{
if (!Glib::thread_supported())
{
Glib::thread_init();
}
srand(time(0));
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.huxley.carputer");
Glib::RefPtr<Gtk::Builder> builder;
Config cfg;
cfg.readFile("/etc/carputer/carputer.cfg");
string assetsPath = cfg.lookup("assetspath");
try
{
// The interface is built using an XML file from Glade
builder = Gtk::Builder::create_from_file(assetsPath + "/carputer.glade");
}
catch (const Glib::FileError &ex)
{
cerr << "File Error: " << ex.what() << endl;
return 1;
}
catch (const Glib::MarkupError &ex)
{
cerr << "Markup Error: " << ex.what() << endl;
return 1;
}
catch (const Gtk::BuilderError &ex)
{
cerr << "Builder Error: " << ex.what() << endl;
return 1;
}
// Get the main window from the Glade file and enter the main Gtk loop
MainWindow* win = 0;
builder->get_widget_derived("MainWindow", win);
return app->run(*win);
}