forked from Amm1rr/gnome-shell-extension-ddterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-prefs-gtk4.js
92 lines (70 loc) · 2.68 KB
/
test-prefs-gtk4.js
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
/*
Copyright © 2021 Aleksandr Mezin
This file is part of ddterm GNOME Shell extension.
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 <https://www.gnu.org/licenses/>.
*/
'use strict';
imports.gi.versions.Gdk = '4.0';
imports.gi.versions.Gtk = '4.0';
const System = imports.system;
const { GObject, Gio, Gtk } = imports.gi;
const APP_DATA_DIR = Gio.File.new_for_commandline_arg(System.programInvocationName).get_parent();
imports.searchPath.unshift(APP_DATA_DIR.get_path());
const { util } = imports;
util.APP_DATA_DIR = APP_DATA_DIR;
const PrefsWidget = imports.prefs.createPrefsWidgetClass(util.APP_DATA_DIR, util);
var PrefsDialog = GObject.registerClass(
{
Properties: {
settings: GObject.ParamSpec.object('settings', '', '', GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY, Gio.Settings),
},
},
class PrefsDialog extends Gtk.Window {
_init(params) {
super._init(params);
this.set_child(new PrefsWidget({
settings: this.settings,
}));
}
}
);
const Application = GObject.registerClass(
class Application extends Gtk.Application {
_init(params) {
super._init(params);
this.connect('startup', this.startup.bind(this));
this.connect('activate', this.activate.bind(this));
}
startup() {
const settings_source = Gio.SettingsSchemaSource.new_from_directory(
APP_DATA_DIR.get_child('schemas').get_path(),
Gio.SettingsSchemaSource.get_default(),
false
);
this.settings = new Gio.Settings({
settings_schema: settings_source.lookup('com.github.amezin.ddterm', true),
});
}
activate() {
this.preferences();
}
preferences() {
const prefs_dialog = new PrefsDialog({
settings: this.settings,
application: this,
});
prefs_dialog.show();
}
}
);
const app = new Application();
app.run([System.programInvocationName].concat(ARGV));