| 1 |
/* exported FlatsealPermissionSwitchRow */ |
| 2 |
|
| 3 |
/* permissionSwitchRow.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 |
const {FlatsealOverrideStatusIcon} = imports.widgets.overrideStatusIcon; |
| 23 |
|
| 24 |
|
| 25 |
var FlatsealPermissionSwitchRow = GObject.registerClass({ |
| 26 |
GTypeName: 'FlatsealPermissionSwitchRow', |
| 27 |
Template: 'resource:///com/github/tchx84/Flatseal/widgets/permissionSwitchRow.ui', |
| 28 |
InternalChildren: ['content', 'statusBox'], |
| 29 |
}, class FlatsealPermissionSwitchRow extends Adw.ActionRow { |
| 30 |
_init(description, permission, content) { |
| 31 |
super._init({}); |
| 32 |
this.set_title(description); |
| 33 |
this.set_subtitle(permission); |
| 34 |
this._content.set_active(content); |
| 35 |
this.connect('notify::sensitive', this._update.bind(this)); |
| 36 |
|
| 37 |
this._statusIcon = new FlatsealOverrideStatusIcon(); |
| 38 |
this._statusBox.append(this._statusIcon); |
| 39 |
} |
| 40 |
|
| 41 |
_update() { |
| 42 |
if (this.sensitive === false) |
| 43 |
this.set_tooltip_text(_('Not supported by the installed version of Flatpak')); |
| 44 |
else |
| 45 |
this.set_tooltip_text(''); |
| 46 |
} |
| 47 |
|
| 48 |
get content() { |
| 49 |
return this._content; |
| 50 |
} |
| 51 |
|
| 52 |
get status() { |
| 53 |
return this._statusIcon; |
| 54 |
} |
| 55 |
|
| 56 |
get supported() { |
| 57 |
return this.sensitive; |
| 58 |
} |
| 59 |
|
| 60 |
set supported(supported) { |
| 61 |
this.sensitive = supported; |
| 62 |
this._update(); |
| 63 |
} |
| 64 |
}); |