inhibitShortcutsDialog: Don't override resource

PermissionStore's Set() method takes a complete permission
table, so when setting an app's permission, we are implicitly
removing all previously set entries for other apps.

Switch to the SetPermission() method which sets the permission
for a single app.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5937

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2504>
This commit is contained in:
Florian Müllner 2022-10-06 14:30:20 +02:00
parent 0ce2bc343b
commit 8590e33501
2 changed files with 11 additions and 8 deletions

View File

@ -13,6 +13,13 @@
<arg name="app_permissions" type="a{sas}" direction="in"/>
<arg name="data" type="v" direction="in"/>
</method>
<method name="SetPermission">
<arg name='table' type='s' direction='in'/>
<arg name='create' type='b' direction='in'/>
<arg name='id' type='s' direction='in'/>
<arg name='app' type='s' direction='in'/>
<arg name='permissions' type='as' direction='in'/>
</method>
<signal name="Changed">
<arg name="table" type="s" direction="out"/>
<arg name="id" type="s" direction="out"/>

View File

@ -1,5 +1,5 @@
/* exported InhibitShortcutsDialog */
const { Clutter, Gio, GLib, GObject, Gtk, Meta, Pango, Shell, St } = imports.gi;
const {Clutter, Gio, GObject, Gtk, Meta, Pango, Shell, St} = imports.gi;
const Dialog = imports.ui.dialog;
const ModalDialog = imports.ui.modalDialog;
@ -57,16 +57,12 @@ var InhibitShortcutsDialog = GObject.registerClass({
if (!this._shouldUsePermStore() || this._permStore == null)
return;
let permissions = {};
permissions[this._app.get_id()] = [grant];
let data = GLib.Variant.new('av', {});
try {
await this._permStore.SetAsync(APP_PERMISSIONS_TABLE,
await this._permStore.SetPermissionAsync(APP_PERMISSIONS_TABLE,
true,
APP_PERMISSIONS_ID,
permissions,
data);
this._app.get_id(),
[grant]);
} catch (error) {
log(error.message);
}