summaryrefslogtreecommitdiff
path: root/src/application.vala
blob: b4f543cf00be00f8a9df5a1562e4d701e160961c (plain) (blame)
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
/* application.vala

 *
 * Copyright 2023 Mubashshir

 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace JadupcSupport
{
	public class Application : Gtk.Application
	{
			public Application ()
			{
				Object (application_id: "com.jadupc.support", flags: ApplicationFlags.FLAGS_NONE);
			}

			construct {
				{var _ = Vte.get_major_version();} // This is useless, but removing this breaks linking with vte
				ActionEntry[] action_entries = {
					{ "about", this.on_about_action },
					{ "preferences", this.on_preferences_action },
					{ "quit", this.quit }
				};
				this.add_action_entries (action_entries, this);
			}

			public override void activate ()
			{
				base.activate ();
				var win = this.active_window;
				if (win == null) {
					// Fix vte issues
					win = new JadupcSupport.Window (this);

					this.set_accels_for_action ("app.quit", {"<primary>q"});
					this.set_accels_for_action ("app.about", {"<primary>question"});
					this.set_accels_for_action ("app.preferences", {"<primary>p"});
					var settings = Gtk.Settings.get_default();
					if (settings != null)
						settings.gtk_dialogs_use_header = true;
				}
				win.present ();
			}

			private void on_about_action ()
			{
				var info = new Config.Info();
				Gtk.show_about_dialog (this.active_window,
				                       program_name: _("JaduPc Remote Support Console"),
				                       copyright: string.joinv("\n", info.copyright),
				                       license_type: Gtk.License.GPL_2_0,
				                       logo_icon_name: "com.jadupc.support",
				                       authors: info.authors,
				                       artists: info.artists,
				                       website: "https://jadupc.com",
				                       website_label: _("JaduPc Ltd."),
				                       version: Config.VERSION);
			}

			private void on_preferences_action ()
			{
				message ("app.preferences action activated");
			}
	}
}