extensionPrefs: Hook up kill switch to D-Bus property
Now that the org.gnome.Shell.Extensions interface exposes the disable-user-extensions setting on D-Bus, we can use that instead of the shell's GSettings. In a future where we distribute the app separately as flatpak, this will require one less hole in the sandbox. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081
This commit is contained in:
parent
4340260c49
commit
5c031200ce
@ -90,8 +90,9 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="killSwitch">
|
||||
<object class="GtkSwitch">
|
||||
<property name="visible">True</property>
|
||||
<property name="action-name">win.user-extensions-enabled</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack_type">end</property>
|
||||
|
@ -36,6 +36,11 @@ function stripPrefix(string, prefix) {
|
||||
return string;
|
||||
}
|
||||
|
||||
function toggleState(action) {
|
||||
let state = action.get_state();
|
||||
action.change_state(new GLib.Variant('b', !state.get_boolean()));
|
||||
}
|
||||
|
||||
var Application = GObject.registerClass(
|
||||
class Application extends Gtk.Application {
|
||||
_init() {
|
||||
@ -94,7 +99,6 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
InternalChildren: [
|
||||
'userList',
|
||||
'systemList',
|
||||
'killSwitch',
|
||||
'mainBox',
|
||||
'mainStack',
|
||||
'scrolledWindow',
|
||||
@ -121,10 +125,15 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
action.connect('activate', this._logout.bind(this));
|
||||
this.add_action(action);
|
||||
|
||||
this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
|
||||
this._settings.bind('disable-user-extensions',
|
||||
this._killSwitch, 'active',
|
||||
Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN);
|
||||
action = new Gio.SimpleAction({
|
||||
name: 'user-extensions-enabled',
|
||||
state: new GLib.Variant('b', false),
|
||||
});
|
||||
action.connect('activate', toggleState);
|
||||
action.connect('change-state', (a, state) => {
|
||||
this._shellProxy.UserExtensionsEnabled = state.get_boolean();
|
||||
});
|
||||
this.add_action(action);
|
||||
|
||||
this._userList.set_sort_func(this._sortList.bind(this));
|
||||
this._userList.set_header_func(this._updateHeader.bind(this));
|
||||
@ -135,6 +144,10 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
this._shellProxy.connectSignal('ExtensionStateChanged',
|
||||
this._onExtensionStateChanged.bind(this));
|
||||
|
||||
this._shellProxy.connect('g-properties-changed',
|
||||
this._onUserExtensionsEnabledChanged.bind(this));
|
||||
this._onUserExtensionsEnabledChanged();
|
||||
|
||||
this._scanExtensions();
|
||||
}
|
||||
|
||||
@ -388,6 +401,12 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
].find(c => c.uuid === uuid);
|
||||
}
|
||||
|
||||
_onUserExtensionsEnabledChanged() {
|
||||
let action = this.lookup_action('user-extensions-enabled');
|
||||
action.set_state(
|
||||
new GLib.Variant('b', this._shellProxy.UserExtensionsEnabled));
|
||||
}
|
||||
|
||||
_onExtensionStateChanged(proxy, senderName, [uuid, newState]) {
|
||||
let extension = ExtensionUtils.deserializeExtension(newState);
|
||||
let row = this._findExtensionRow(uuid);
|
||||
@ -632,10 +651,7 @@ var ExtensionRow = GObject.registerClass({
|
||||
name: 'enabled',
|
||||
state: new GLib.Variant('b', false),
|
||||
});
|
||||
action.connect('activate', () => {
|
||||
let state = action.get_state();
|
||||
action.change_state(new GLib.Variant('b', !state.get_boolean()));
|
||||
});
|
||||
action.connect('activate', toggleState);
|
||||
action.connect('change-state', (a, state) => {
|
||||
if (state.get_boolean())
|
||||
this._app.shellProxy.EnableExtensionRemote(this.uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user