Debian Codegraph @

src/widgets/permissionEntryRow.js

raw
1 /* exported FlatsealPermissionEntryRow */
2
3 /* permissionEntryRow.js
4 *
5 * Copyright 2020 Martin Abente Lahaye
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 const {GObject, Adw} = imports.gi;
22
23 const {FlatsealPathsViewer} = imports.widgets.pathsViewer;
24
25
26 var FlatsealPermissionEntryRow = GObject.registerClass({
27 GTypeName: 'FlatsealPermissionEntryRow',
28 Template: 'resource:///com/github/tchx84/Flatseal/widgets/permissionEntryRow.ui',
29 InternalChildren: [
30 'description',
31 'permission',
32 'box',
33 'button',
34 ],
35 }, class FlatsealpermissionEntryRow extends Adw.PreferencesRow {
36 _init(description, permission, content, serializeFunc, deserializeFunc, rowClass, iconName) {
37 super._init({});
38 this._description.set_text(description);
39 this._permission.set_text(permission);
40
41 this._content = new FlatsealPathsViewer(serializeFunc, deserializeFunc, rowClass);
42 this._content.text = content;
43 this._box.append(this._content);
44 this._content.bind_property('visible', this._box, 'visible', GObject.BindingFlags.SYNC_CREATE);
45
46 this._button.icon_name = iconName;
47
48 this._button.connect('clicked', this._add.bind(this));
49 this.connect('notify::sensitive', this._update.bind(this));
50 }
51
52 _add() {
53 this._content.add('');
54 }
55
56 _update() {
57 if (this.sensitive === false)
58 this.set_tooltip_text(_('Not supported by the installed version of Flatpak'));
59 else
60 this.set_tooltip_text('');
61 }
62
63 get content() {
64 return this._content;
65 }
66
67 get status() {
68 return this._content;
69 }
70
71 get supported() {
72 return this.sensitive;
73 }
74
75 set supported(supported) {
76 this.sensitive = supported;
77 this._update();
78 }
79 });