From b0362945f4404fe270ad3aabe9282c5100066b26 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Dec 2019 23:10:54 -0500 Subject: [PATCH] data: Stop providing an Access portal backend A portal review by the design team has concluded that it is better to have all portals as application-modal GTK dialogs, instead of mixing them with some system-modal shell dialogs. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1994 --- .../org.freedesktop.impl.portal.Access.xml | 15 -- .../gnome-shell-dbus-interfaces.gresource.xml | 1 - data/gnome-shell.portal | 4 - data/meson.build | 1 - js/js-resources.gresource.xml | 1 - js/ui/accessDialog.js | 156 ------------------ js/ui/main.js | 5 +- meson.build | 1 - po/POTFILES.in | 1 - 9 files changed, 1 insertion(+), 184 deletions(-) delete mode 100644 data/dbus-interfaces/org.freedesktop.impl.portal.Access.xml delete mode 100644 data/gnome-shell.portal delete mode 100644 js/ui/accessDialog.js diff --git a/data/dbus-interfaces/org.freedesktop.impl.portal.Access.xml b/data/dbus-interfaces/org.freedesktop.impl.portal.Access.xml deleted file mode 100644 index 802a2c15d..000000000 --- a/data/dbus-interfaces/org.freedesktop.impl.portal.Access.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml index db3ef4ac2..92a8d3d27 100644 --- a/data/gnome-shell-dbus-interfaces.gresource.xml +++ b/data/gnome-shell-dbus-interfaces.gresource.xml @@ -9,7 +9,6 @@ org.freedesktop.DBus.xml org.freedesktop.GeoClue2.Agent.xml org.freedesktop.GeoClue2.Manager.xml - org.freedesktop.impl.portal.Access.xml org.freedesktop.impl.portal.PermissionStore.xml org.freedesktop.impl.portal.Request.xml org.freedesktop.login1.Manager.xml diff --git a/data/gnome-shell.portal b/data/gnome-shell.portal deleted file mode 100644 index b70463777..000000000 --- a/data/gnome-shell.portal +++ /dev/null @@ -1,4 +0,0 @@ -[portal] -DBusName=org.freedesktop.impl.portal.desktop.gnome -Interfaces=org.freedesktop.impl.portal.Access -UseIn=gnome diff --git a/data/meson.build b/data/meson.build index ee4b1abbf..553c5c956 100644 --- a/data/meson.build +++ b/data/meson.build @@ -72,7 +72,6 @@ configure_file( ) -install_data('gnome-shell.portal', install_dir: portaldir) install_data('50-gnome-shell-system.xml', install_dir: keysdir) diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml index aec3427e0..5f8be8fac 100644 --- a/js/js-resources.gresource.xml +++ b/js/js-resources.gresource.xml @@ -32,7 +32,6 @@ perf/core.js perf/hwtest.js - ui/accessDialog.js ui/altTab.js ui/animation.js ui/appDisplay.js diff --git a/js/ui/accessDialog.js b/js/ui/accessDialog.js deleted file mode 100644 index 6d3ede01e..000000000 --- a/js/ui/accessDialog.js +++ /dev/null @@ -1,156 +0,0 @@ -/* exported AccessDialogDBus */ -const { Clutter, Gio, GLib, GObject, Shell, St } = imports.gi; - -const CheckBox = imports.ui.checkBox; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; - -const { loadInterfaceXML } = imports.misc.fileUtils; - -const RequestIface = loadInterfaceXML('org.freedesktop.impl.portal.Request'); -const AccessIface = loadInterfaceXML('org.freedesktop.impl.portal.Access'); - -var DialogResponse = { - OK: 0, - CANCEL: 1, - CLOSED: 2, -}; - -var AccessDialog = GObject.registerClass( -class AccessDialog extends ModalDialog.ModalDialog { - _init(invocation, handle, title, description, body, options) { - super._init({ styleClass: 'access-dialog' }); - - this._invocation = invocation; - this._handle = handle; - - this._requestExported = false; - this._request = Gio.DBusExportedObject.wrapJSObject(RequestIface, this); - - for (let option in options) - options[option] = options[option].deep_unpack(); - - this._buildLayout(title, description, body, options); - } - - _buildLayout(title, description, body, options) { - // No support for non-modal system dialogs, so ignore the option - // let modal = options['modal'] || true; - let denyLabel = options['deny_label'] || _("Deny Access"); - let grantLabel = options['grant_label'] || _("Grant Access"); - let choices = options['choices'] || []; - - let content = new Dialog.MessageDialogContent({ title, description }); - this.contentLayout.add_actor(content); - - this._choices = new Map(); - - for (let i = 0; i < choices.length; i++) { - let [id, name, opts, selected] = choices[i]; - if (opts.length > 0) - continue; // radio buttons, not implemented - - let check = new CheckBox.CheckBox(); - check.getLabelActor().text = name; - check.checked = selected == "true"; - content.add_child(check); - - this._choices.set(id, check); - } - - let bodyLabel = new St.Label({ - text: body, - x_align: Clutter.ActorAlign.CENTER, - }); - content.add_child(bodyLabel); - - this.addButton({ label: denyLabel, - action: () => { - this._sendResponse(DialogResponse.CANCEL); - }, - key: Clutter.KEY_Escape }); - this.addButton({ label: grantLabel, - action: () => { - this._sendResponse(DialogResponse.OK); - } }); - } - - open() { - super.open(); - - let connection = this._invocation.get_connection(); - this._requestExported = this._request.export(connection, this._handle); - } - - CloseAsync(invocation, _params) { - if (this._invocation.get_sender() != invocation.get_sender()) { - invocation.return_error_literal(Gio.DBusError, - Gio.DBusError.ACCESS_DENIED, - ''); - return; - } - - this._sendResponse(DialogResponse.CLOSED); - } - - _sendResponse(response) { - if (this._requestExported) - this._request.unexport(); - this._requestExported = false; - - let results = {}; - if (response == DialogResponse.OK) { - for (let [id, check] of this._choices) { - let checked = check.checked ? 'true' : 'false'; - results[id] = new GLib.Variant('s', checked); - } - } - - // Delay actual response until the end of the close animation (if any) - this.connect('closed', () => { - this._invocation.return_value(new GLib.Variant('(ua{sv})', - [response, results])); - }); - this.close(); - } -}); - -var AccessDialogDBus = class { - constructor() { - this._accessDialog = null; - - this._windowTracker = Shell.WindowTracker.get_default(); - - this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(AccessIface, this); - this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/portal/desktop'); - - Gio.DBus.session.own_name('org.freedesktop.impl.portal.desktop.gnome', Gio.BusNameOwnerFlags.REPLACE, null, null); - } - - AccessDialogAsync(params, invocation) { - if (this._accessDialog) { - invocation.return_error_literal(Gio.DBusError, - Gio.DBusError.LIMITS_EXCEEDED, - 'Already showing a system access dialog'); - return; - } - - let [handle, appId, parentWindow_, title, description, body, options] = params; - // We probably want to use parentWindow and global.display.focus_window - // for this check in the future - if (appId && `${appId}.desktop` != this._windowTracker.focus_app.id) { - invocation.return_error_literal(Gio.DBusError, - Gio.DBusError.ACCESS_DENIED, - 'Only the focused app is allowed to show a system access dialog'); - return; - } - - let dialog = new AccessDialog( - invocation, handle, title, description, body, options); - dialog.open(); - - dialog.connect('closed', () => (this._accessDialog = null)); - - this._accessDialog = dialog; - } -}; diff --git a/js/ui/main.js b/js/ui/main.js index 09b0249aa..18b705dd0 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -2,7 +2,7 @@ /* exported componentManager, notificationDaemon, windowAttentionHandler, ctrlAltTabManager, padOsdService, osdWindowManager, osdMonitorLabeler, shellMountOpDBusService, shellDBusService, - shellAccessDialogDBusService, shellAudioSelectionDBusService, + shellAudioSelectionDBusService, screenSaverDBus, screencastService, uiGroup, magnifier, xdndHandler, keyboard, kbdA11yDialog, introspectService, start, pushModal, popModal, activateWindow, createLookingGlass, @@ -10,7 +10,6 @@ const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi; -const AccessDialog = imports.ui.accessDialog; const AudioDeviceSelection = imports.ui.audioDeviceSelection; const Components = imports.ui.components; const CtrlAltTab = imports.ui.ctrlAltTab; @@ -68,7 +67,6 @@ var padOsdService = null; var osdWindowManager = null; var osdMonitorLabeler = null; var sessionMode = null; -var shellAccessDialogDBusService = null; var shellAudioSelectionDBusService = null; var shellDBusService = null; var shellMountOpDBusService = null; @@ -137,7 +135,6 @@ function start() { St.Settings.get().connect('notify::gtk-theme', _loadDefaultStylesheet); _initializeUI(); - shellAccessDialogDBusService = new AccessDialog.AccessDialogDBus(); shellAudioSelectionDBusService = new AudioDeviceSelection.AudioDeviceSelectionDBus(); shellDBusService = new ShellDBus.GnomeShell(); shellMountOpDBusService = new ShellMountOperation.GnomeShellMountOpHandler(); diff --git a/meson.build b/meson.build index 1ee210703..91724d8ea 100644 --- a/meson.build +++ b/meson.build @@ -57,7 +57,6 @@ convertdir = join_paths(datadir, 'GConf', 'gsettings') desktopdir = join_paths(datadir, 'applications') ifacedir = join_paths(datadir, 'dbus-1', 'interfaces') localedir = join_paths(datadir, 'locale') -portaldir = join_paths(datadir, 'xdg-desktop-portal', 'portals') schemadir = join_paths(datadir, 'glib-2.0', 'schemas') servicedir = join_paths(datadir, 'dbus-1', 'services') diff --git a/po/POTFILES.in b/po/POTFILES.in index c8d6c03de..cb94a3438 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,7 +12,6 @@ js/gdm/util.js js/misc/systemActions.js js/misc/util.js js/portalHelper/main.js -js/ui/accessDialog.js js/ui/appDisplay.js js/ui/appFavorites.js js/ui/audioDeviceSelection.js