~l-admin-3/evnc/automatic-cleanup-branch

« back to all changes in this revision

Viewing changes to src/MainWindow.vala

  • Committer: Marcus Wichelmann
  • Date: 2015-07-09 18:17:05 UTC
  • Revision ID: marcus.wichelmann@hotmail.de-20150709181705-aliu5vv3gvha1p0a
Automatic code cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
*/
18
18
 
19
19
namespace evnc {
20
 
        public class MainWindow : Gtk.Window {
21
 
                // App
22
 
                public evncApp app;
23
 
 
24
 
                // Settings
25
 
                private SettingsManager options;
26
 
 
27
 
                // Container
28
 
                private Gtk.Box box;
29
 
                private Widgets.TitleBar titlebar;
30
 
                private Widgets.Information information;
31
 
                private Widgets.MainView mainview;
32
 
 
33
 
                public MainWindow (evncApp app) {
34
 
                        this.app = app;
35
 
                        this.set_application (app);
36
 
 
37
 
                        options = new SettingsManager ();
38
 
 
39
 
                        // Change the theme
40
 
                        Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = options.use_dark_theme;
41
 
                        options.on_use_dark_theme_changed.connect ((val) => {
42
 
                                Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = val;
43
 
                        });
44
 
 
45
 
                        // Window propterties
46
 
                        this.set_size_request (900, 650);
47
 
                        this.set_has_resize_grip (false);
48
 
                        this.window_position = Gtk.WindowPosition.CENTER;
49
 
 
50
 
                        // Draw UI
51
 
                        setup_ui ();
52
 
                        this.show_all ();
53
 
                }
54
 
 
55
 
                private void setup_ui () {
56
 
                        box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
57
 
 
58
 
                        titlebar = new Widgets.TitleBar (this);
59
 
 
60
 
                        this.set_titlebar (titlebar);
61
 
                        box.pack_start (titlebar, false, true);
62
 
 
63
 
                        information = new Widgets.Information ();
64
 
                        box.pack_start (information, false, true);
65
 
 
66
 
                        mainview = new Widgets.MainView ();
67
 
                        box.pack_start (mainview, true, true);
68
 
 
69
 
                        this.add (box);
70
 
 
71
 
                        titlebar.on_connect_request.connect (mainview.notebook.add_connection);
72
 
                        titlebar.on_take_screenshot_clicked.connect (() => {
73
 
                                (mainview.notebook.current as Widgets.VncConnection).take_screenshot ();
74
 
                        });
75
 
 
76
 
                        mainview.on_show_connect_dialog_request.connect (titlebar.show_connect_dialog);
77
 
                        mainview.on_open_bookmarks_request.connect (() => {
78
 
                                titlebar.bookmarksmenu.popup (null, null, null, 0, Gtk.get_current_event_time ());
79
 
                        });
80
 
                        mainview.notebook.on_connection_message.connect (information.show_text);
81
 
                        mainview.notebook.tab_added.connect (() => {
82
 
                                titlebar.btn_screenshot.set_sensitive (true);
83
 
                        });
84
 
                        mainview.notebook.tab_removed.connect (() => {
85
 
                                if (mainview.notebook.n_tabs == 0) {
86
 
                                        titlebar.btn_screenshot.set_sensitive (false);
87
 
                                }
88
 
                        });
89
 
                }
90
 
        }
 
20
    public class MainWindow : Gtk.Window {
 
21
        // App
 
22
        public evncApp app;
 
23
 
 
24
        // Settings
 
25
        private SettingsManager options;
 
26
 
 
27
        // Container
 
28
        private Gtk.Box box;
 
29
        private Widgets.TitleBar titlebar;
 
30
        private Widgets.Information information;
 
31
        private Widgets.MainView mainview;
 
32
 
 
33
        public MainWindow (evncApp app) {
 
34
            this.app = app;
 
35
            this.set_application (app);
 
36
 
 
37
            options = new SettingsManager ();
 
38
 
 
39
            // Change the theme
 
40
            Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = options.use_dark_theme;
 
41
            options.on_use_dark_theme_changed.connect ((val) => {
 
42
                Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = val;
 
43
            });
 
44
 
 
45
            // Window propterties
 
46
            this.set_size_request (900, 650);
 
47
            this.set_has_resize_grip (false);
 
48
            this.window_position = Gtk.WindowPosition.CENTER;
 
49
 
 
50
            // Draw UI
 
51
            setup_ui ();
 
52
            this.show_all ();
 
53
        }
 
54
 
 
55
        private void setup_ui () {
 
56
            box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
 
57
 
 
58
            titlebar = new Widgets.TitleBar (this);
 
59
 
 
60
            this.set_titlebar (titlebar);
 
61
            box.pack_start (titlebar, false, true);
 
62
 
 
63
            information = new Widgets.Information ();
 
64
            box.pack_start (information, false, true);
 
65
 
 
66
            mainview = new Widgets.MainView ();
 
67
            box.pack_start (mainview, true, true);
 
68
 
 
69
            this.add (box);
 
70
 
 
71
            titlebar.on_connect_request.connect (mainview.notebook.add_connection);
 
72
            titlebar.on_take_screenshot_clicked.connect (() => {
 
73
                (mainview.notebook.current as Widgets.VncConnection).take_screenshot ();
 
74
            });
 
75
 
 
76
            mainview.on_show_connect_dialog_request.connect (titlebar.show_connect_dialog);
 
77
            mainview.on_open_bookmarks_request.connect (() => {
 
78
                titlebar.bookmarksmenu.popup (null, null, null, 0, Gtk.get_current_event_time ());
 
79
            });
 
80
            mainview.notebook.on_connection_message.connect (information.show_text);
 
81
            mainview.notebook.tab_added.connect (() => {
 
82
                titlebar.btn_screenshot.set_sensitive (true);
 
83
            });
 
84
            mainview.notebook.tab_removed.connect (() => {
 
85
                if (mainview.notebook.n_tabs == 0) {
 
86
                    titlebar.btn_screenshot.set_sensitive (false);
 
87
                }
 
88
            });
 
89
        }
 
90
    }
91
91
}
 
 
b'\\ No newline at end of file'