-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
71 lines (55 loc) · 1.67 KB
/
main.cc
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
#include <gtkmm.h>
#include "MainWindow.h"
#include "Configuration.h"
#include "config.h"
bool GLOBAL_ERROR_OCCURED;
Glib::ustring global_error_msg;
void saveDefaults() {
Configuration conf;
if (conf.getValue("GUI", "width percentage") <= 0) {
conf.setValue("GUI", "width percentage", 70);
}
if (conf.getValue("GUI", "height percentage") <= 0) {
conf.setValue("GUI", "height percentage", 80);
}
if (conf.getValue("GUI", "Left pane percentage") <= 0) {
conf.setValue("GUI", "Left pane percentage", 82);
}
if (conf.getValue("GUI", "default window x-position") <= 0) {
conf.setValue("GUI", "default window x-position", 1);
conf.setValue("GUI", "default window y-position", 1);
}
}
int main(int argc, char **argv) {
GLOBAL_ERROR_OCCURED=false;
bindtextdomain(PACKAGE, GETTEXT_PATH);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
Glib::set_application_name(PROGRAM_NAME);
Glib::OptionContext context(_("<some_file.po>"));
context.set_translation_domain(PACKAGE);
context.parse(argc, argv);
Gtk::Main app(argc, argv);
saveDefaults();
Glib::RefPtr<Gdk::Screen> scr = Gdk::Screen::get_default();
int width = scr->get_width();
int height = scr->get_height();
int x, y;
{
Configuration conf;
width = width*conf.getValue("GUI", "width percentage")/100.0;
height = height*conf.getValue("GUI", "height percentage")/100.0;
x = conf.getValue("GUI", "default window x-position");
y = conf.getValue("GUI", "default window y-position");
}
MainWindow okno(width, height);
okno.move(x, y);
okno.show_all();
if (argc>1) {
if (Glib::file_test(argv[1], Glib::FILE_TEST_EXISTS)) {
okno.onFileOpened(argv[1]);
}
}
app.run(okno);
return 0;
}