-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathApplication.vala
More file actions
104 lines (83 loc) · 2.93 KB
/
Application.vala
File metadata and controls
104 lines (83 loc) · 2.93 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2019-2022 elementary, Inc. (https://elementary.io)
*
* 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/
public class Sideload.Application : Gtk.Application {
public Application () {
GLib.Intl.setlocale (LocaleCategory.ALL, "");
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
GLib.Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
GLib.Intl.textdomain (GETTEXT_PACKAGE);
Object (
application_id: "io.elementary.sideload",
flags: ApplicationFlags.HANDLES_OPEN
);
}
protected override void open (File[] files, string hint) {
if (files.length == 0) {
return;
}
var file = files[0];
if (get_windows ().length () > 0) {
get_windows ().data.present ();
return;
}
hold ();
open_file.begin (file);
}
private async void open_file (File file) {
Sideload.MainWindow main_window = null;
main_window = new MainWindow (this, file);
main_window.present ();
var launch_action = new SimpleAction ("launch", null);
add_action (launch_action);
launch_action.activate.connect (() => {
main_window.flatpak_file.launch.begin ((obj, res) => {
main_window.flatpak_file.launch.end (res);
main_window.close ();
});
});
release ();
}
protected override void startup () {
base.startup ();
Granite.init ();
var quit_action = new SimpleAction ("quit", null);
add_action (quit_action);
set_accels_for_action ("app.quit", {"<Control>q"});
quit_action.activate.connect (quit);
}
protected override void activate () {
}
public string get_appstore_name () {
var appinfo = GLib.AppInfo.get_default_for_uri_scheme ("appstream");
if (appinfo != null) {
return appinfo.get_name ();
} else {
return _("your software center");
}
}
public static int main (string[] args) {
if (args.length < 2) {
print ("Usage: %s /path/to/flatpakref or /path/to/flatpak\n", args[0]);
return 1;
}
var app = new Application ();
return app.run (args);
}
}