#14 Backport upstream PR 1919
Closed 2 years ago by carlwgeorge. Opened 2 years ago by carlwgeorge.
rpms/ carlwgeorge/gnome-shell f35_backport_pr1919  into  rawhide

@@ -0,0 +1,204 @@ 

+ From 6954b520c18acc5847b9e3ed36e2b534f0c68507 Mon Sep 17 00:00:00 2001

+ From: Ian Douglas Scott <idscott@system76.com>

+ Date: Fri, 16 Jul 2021 09:21:22 -0700

+ Subject: [PATCH 1/2] location: Add GObject properties to `Location.Indicator`

+ 

+ Makes `enabled`, `in-use`, and `max-accuracy-level` GObject properties

+ that can be used for property binding, etc.

+ 

+ Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1919>

+ ---

+  js/ui/status/location.js | 93 ++++++++++++++++++++++++----------------

+  1 file changed, 55 insertions(+), 38 deletions(-)

+ 

+ diff --git a/js/ui/status/location.js b/js/ui/status/location.js

+ index 4250ed0fe..d0478b19c 100644

+ --- a/js/ui/status/location.js

+ +++ b/js/ui/status/location.js

+ @@ -42,22 +42,38 @@ const GeoclueManager = Gio.DBusProxy.makeProxyWrapper(GeoclueIface);

+  

+  var AgentIface = loadInterfaceXML('org.freedesktop.GeoClue2.Agent');

+  

+ -var Indicator = GObject.registerClass(

+ -class Indicator extends PanelMenu.SystemIndicator {

+ +var Indicator = GObject.registerClass({

+ +    Properties: {

+ +        'enabled': GObject.ParamSpec.boolean(

+ +            'enabled', 'Enabled', 'Enabled',

+ +            GObject.ParamFlags.READWRITE,

+ +            false),

+ +        'in-use': GObject.ParamSpec.boolean(

+ +            'in-use', 'In use', 'In use',

+ +            GObject.ParamFlags.READABLE,

+ +            false),

+ +        'max-accuracy-level': GObject.ParamSpec.int(

+ +            'max-accuracy-level', 'Max accuracy level', 'Max accuracy level',

+ +            GObject.ParamFlags.READABLE,

+ +            0, 8, 0),

+ +    },

+ +}, class Indicator extends PanelMenu.SystemIndicator {

+      _init() {

+          super._init();

+  

+          this._settings = new Gio.Settings({ schema_id: LOCATION_SCHEMA });

+          this._settings.connect('changed::%s'.format(ENABLED),

+ -                               this._onMaxAccuracyLevelChanged.bind(this));

+ +            () => this.notify('enabled'));

+          this._settings.connect('changed::%s'.format(MAX_ACCURACY_LEVEL),

+ -                               this._onMaxAccuracyLevelChanged.bind(this));

+ +            this._onMaxAccuracyLevelChanged.bind(this));

+  

+          this._indicator = this._addIndicator();

+          this._indicator.icon_name = 'find-location-symbolic';

+ +        this.bind_property('in-use', this._indicator, 'visible', GObject.BindingFlags.SYNC_CREATE);

+  

+          this._item = new PopupMenu.PopupSubMenuMenuItem('', true);

+          this._item.icon.icon_name = 'find-location-symbolic';

+ +        this.bind_property('in-use', this._item, 'visible', GObject.BindingFlags.SYNC_CREATE);

+  

+          this._agent = Gio.DBusExportedObject.wrapJSObject(AgentIface, this);

+          this._agent.export(Gio.DBus.system, '/org/freedesktop/GeoClue2/Agent');

+ @@ -68,6 +84,10 @@ class Indicator extends PanelMenu.SystemIndicator {

+  

+          this.menu.addMenuItem(this._item);

+  

+ +        this.connect('notify::enabled', this._onMaxAccuracyLevelChanged.bind(this));

+ +        this.connect('notify::in-use', this._updateMenuLabels.bind(this));

+ +        this.connect('notify::max-accuracy-level', this._updateMenuLabels.bind(this));

+ +

+          this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,

+                                             'org.freedesktop.GeoClue2',

+                                             0,

+ @@ -80,17 +100,34 @@ class Indicator extends PanelMenu.SystemIndicator {

+          this._connectToPermissionStore();

+      }

+  

+ -    get MaxAccuracyLevel() {

+ -        return this._getMaxAccuracyLevel();

+ +    get enabled() {

+ +        return this._settings.get_boolean(ENABLED);

+ +    }

+ +

+ +    set enabled(value) {

+ +        this._settings.set_boolean(ENABLED, value);

+ +    }

+ +

+ +    get inUse() {

+ +        return this._managerProxy?.InUse ?? false;

+ +    }

+ +

+ +    get maxAccuracyLevel() {

+ +        if (this.enabled) {

+ +            let level = this._settings.get_string(MAX_ACCURACY_LEVEL);

+ +

+ +            return GeoclueAccuracyLevel[level.toUpperCase()] ||

+ +                   GeoclueAccuracyLevel.NONE;

+ +        } else {

+ +            return GeoclueAccuracyLevel.NONE;

+ +        }

+      }

+  

+      AuthorizeAppAsync(params, invocation) {

+          let [desktopId, reqAccuracyLevel] = params;

+  

+          let authorizer = new AppAuthorizer(desktopId,

+ -                                           reqAccuracyLevel,

+ -                                           this._permStoreProxy,

+ -                                           this._getMaxAccuracyLevel());

+ +            reqAccuracyLevel, this._permStoreProxy, this.maxAccuracyLevel);

+  

+          authorizer.authorize(accuracyLevel => {

+              let ret = accuracyLevel != GeoclueAccuracyLevel.NONE;

+ @@ -99,16 +136,8 @@ class Indicator extends PanelMenu.SystemIndicator {

+          });

+      }

+  

+ -    _syncIndicator() {

+ -        if (this._managerProxy == null) {

+ -            this._indicator.visible = false;

+ -            this._item.visible = false;

+ -            return;

+ -        }

+ -

+ -        this._indicator.visible = this._managerProxy.InUse;

+ -        this._item.visible = this._indicator.visible;

+ -        this._updateMenuLabels();

+ +    get MaxAccuracyLevel() {

+ +        return this.maxAccuracyLevel;

+      }

+  

+      _connectToGeoclue() {

+ @@ -134,7 +163,7 @@ class Indicator extends PanelMenu.SystemIndicator {

+          this._propertiesChangedId = this._managerProxy.connect('g-properties-changed',

+                                                                 this._onGeocluePropsChanged.bind(this));

+  

+ -        this._syncIndicator();

+ +        this.notify('in-use');

+  

+          this._managerProxy.AddAgentRemote('gnome-shell', this._onAgentRegistered.bind(this));

+      }

+ @@ -154,12 +183,11 @@ class Indicator extends PanelMenu.SystemIndicator {

+          }

+          this._managerProxy = null;

+  

+ -        this._syncIndicator();

+ +        this.notify('in-use');

+      }

+  

+      _onOnOffAction() {

+ -        let enabled = this._settings.get_boolean(ENABLED);

+ -        this._settings.set_boolean(ENABLED, !enabled);

+ +        this.enabled = !this.enabled;

+      }

+  

+      _onSessionUpdated() {

+ @@ -168,7 +196,7 @@ class Indicator extends PanelMenu.SystemIndicator {

+      }

+  

+      _updateMenuLabels() {

+ -        if (this._settings.get_boolean(ENABLED)) {

+ +        if (this.enabled) {

+              this._item.label.text = this._indicator.visible

+                  ? _("Location In Use")

+                  : _("Location Enabled");

+ @@ -180,7 +208,7 @@ class Indicator extends PanelMenu.SystemIndicator {

+      }

+  

+      _onMaxAccuracyLevelChanged() {

+ -        this._updateMenuLabels();

+ +        this.notify('max-accuracy-level');

+  

+          // Gotta ensure geoclue is up and we are registered as agent to it

+          // before we emit the notify for this property change.

+ @@ -188,26 +216,15 @@ class Indicator extends PanelMenu.SystemIndicator {

+              this._notifyMaxAccuracyLevel();

+      }

+  

+ -    _getMaxAccuracyLevel() {

+ -        if (this._settings.get_boolean(ENABLED)) {

+ -            let level = this._settings.get_string(MAX_ACCURACY_LEVEL);

+ -

+ -            return GeoclueAccuracyLevel[level.toUpperCase()] ||

+ -                   GeoclueAccuracyLevel.NONE;

+ -        } else {

+ -            return GeoclueAccuracyLevel.NONE;

+ -        }

+ -    }

+ -

+      _notifyMaxAccuracyLevel() {

+ -        let variant = new GLib.Variant('u', this._getMaxAccuracyLevel());

+ +        let variant = new GLib.Variant('u', this.maxAccuracyLevel);

+          this._agent.emit_property_changed('MaxAccuracyLevel', variant);

+      }

+  

+      _onGeocluePropsChanged(proxy, properties) {

+          let unpacked = properties.deep_unpack();

+          if ("InUse" in unpacked)

+ -            this._syncIndicator();

+ +            this.notify('in-use');

+      }

+  

+      _connectToPermissionStore() {

+ -- 

+ 2.31.1

+ 

@@ -0,0 +1,183 @@ 

+ From 80a73af5f2c4c4309d1edc7f20e0514f238a7290 Mon Sep 17 00:00:00 2001

+ From: Ian Douglas Scott <idscott@system76.com>

+ Date: Fri, 16 Jul 2021 09:23:58 -0700

+ Subject: [PATCH 2/2] location: Split `Location.Indicator` into a seperate

+  `GeoclueAgent`

+ 

+ Before this, creating a separate instance of `Location.Indicator` failed

+ because it tries to create export the same DBus path.

+ 

+ This is useful for extensions adding panels on multiple monitors. But

+ it also seems like a cleaner design to separate the indicator widget

+ from the logically separate role as a Geoclue agent.

+ 

+ Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1919>

+ ---

+  js/ui/status/location.js | 113 +++++++++++++++++++++++++--------------

+  1 file changed, 72 insertions(+), 41 deletions(-)

+ 

+ diff --git a/js/ui/status/location.js b/js/ui/status/location.js

+ index d0478b19c..1d2658c70 100644

+ --- a/js/ui/status/location.js

+ +++ b/js/ui/status/location.js

+ @@ -42,7 +42,14 @@ const GeoclueManager = Gio.DBusProxy.makeProxyWrapper(GeoclueIface);

+  

+  var AgentIface = loadInterfaceXML('org.freedesktop.GeoClue2.Agent');

+  

+ -var Indicator = GObject.registerClass({

+ +let _geoclueAgent = null;

+ +function _getGeoclueAgent() {

+ +    if (_geoclueAgent === null)

+ +        _geoclueAgent = new GeoclueAgent();

+ +    return _geoclueAgent;

+ +}

+ +

+ +var GeoclueAgent = GObject.registerClass({

+      Properties: {

+          'enabled': GObject.ParamSpec.boolean(

+              'enabled', 'Enabled', 'Enabled',

+ @@ -57,7 +64,7 @@ var Indicator = GObject.registerClass({

+              GObject.ParamFlags.READABLE,

+              0, 8, 0),

+      },

+ -}, class Indicator extends PanelMenu.SystemIndicator {

+ +}, class GeoclueAgent extends GObject.Object {

+      _init() {

+          super._init();

+  

+ @@ -67,34 +74,16 @@ var Indicator = GObject.registerClass({

+          this._settings.connect('changed::%s'.format(MAX_ACCURACY_LEVEL),

+              this._onMaxAccuracyLevelChanged.bind(this));

+  

+ -        this._indicator = this._addIndicator();

+ -        this._indicator.icon_name = 'find-location-symbolic';

+ -        this.bind_property('in-use', this._indicator, 'visible', GObject.BindingFlags.SYNC_CREATE);

+ -

+ -        this._item = new PopupMenu.PopupSubMenuMenuItem('', true);

+ -        this._item.icon.icon_name = 'find-location-symbolic';

+ -        this.bind_property('in-use', this._item, 'visible', GObject.BindingFlags.SYNC_CREATE);

+ -

+          this._agent = Gio.DBusExportedObject.wrapJSObject(AgentIface, this);

+          this._agent.export(Gio.DBus.system, '/org/freedesktop/GeoClue2/Agent');

+  

+ -        this._item.label.text = _("Location Enabled");

+ -        this._onOffAction = this._item.menu.addAction(_("Disable"), this._onOnOffAction.bind(this));

+ -        this._item.menu.addSettingsAction(_('Privacy Settings'), 'gnome-location-panel.desktop');

+ -

+ -        this.menu.addMenuItem(this._item);

+ -

+          this.connect('notify::enabled', this._onMaxAccuracyLevelChanged.bind(this));

+ -        this.connect('notify::in-use', this._updateMenuLabels.bind(this));

+ -        this.connect('notify::max-accuracy-level', this._updateMenuLabels.bind(this));

+  

+          this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,

+                                             'org.freedesktop.GeoClue2',

+                                             0,

+                                             this._connectToGeoclue.bind(this),

+                                             this._onGeoclueVanished.bind(this));

+ -        Main.sessionMode.connect('updated', this._onSessionUpdated.bind(this));

+ -        this._onSessionUpdated();

+          this._onMaxAccuracyLevelChanged();

+          this._connectToGeoclue();

+          this._connectToPermissionStore();

+ @@ -186,27 +175,6 @@ var Indicator = GObject.registerClass({

+          this.notify('in-use');

+      }

+  

+ -    _onOnOffAction() {

+ -        this.enabled = !this.enabled;

+ -    }

+ -

+ -    _onSessionUpdated() {

+ -        let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;

+ -        this.menu.setSensitive(sensitive);

+ -    }

+ -

+ -    _updateMenuLabels() {

+ -        if (this.enabled) {

+ -            this._item.label.text = this._indicator.visible

+ -                ? _("Location In Use")

+ -                : _("Location Enabled");

+ -            this._onOffAction.label.text = _("Disable");

+ -        } else {

+ -            this._item.label.text = _("Location Disabled");

+ -            this._onOffAction.label.text = _("Enable");

+ -        }

+ -    }

+ -

+      _onMaxAccuracyLevelChanged() {

+          this.notify('max-accuracy-level');

+  

+ @@ -242,6 +210,69 @@ var Indicator = GObject.registerClass({

+      }

+  });

+  

+ +var Indicator = GObject.registerClass(

+ +class Indicator extends PanelMenu.SystemIndicator {

+ +    _init() {

+ +        super._init();

+ +

+ +        this._agent = _getGeoclueAgent();

+ +

+ +        this._indicator = this._addIndicator();

+ +        this._indicator.icon_name = 'find-location-symbolic';

+ +        this._agent.bind_property('in-use',

+ +            this._indicator,

+ +            'visible',

+ +            GObject.BindingFlags.SYNC_CREATE);

+ +

+ +        this._item = new PopupMenu.PopupSubMenuMenuItem('', true);

+ +        this._item.icon.icon_name = 'find-location-symbolic';

+ +        this._agent.bind_property('in-use',

+ +            this._item,

+ +            'visible',

+ +            GObject.BindingFlags.SYNC_CREATE);

+ +

+ +        this._item.label.text = _('Location Enabled');

+ +        this._onOffAction = this._item.menu.addAction(_('Disable'), this._onOnOffAction.bind(this));

+ +        this._item.menu.addSettingsAction(_('Privacy Settings'), 'gnome-location-panel.desktop');

+ +

+ +        this.menu.addMenuItem(this._item);

+ +

+ +        this._inUseId = this._agent.connect('notify::in-use', this._updateMenuLabels.bind(this));

+ +        this._maxAccuracyId = this._agent.connect('notify::max-accuracy-level', this._updateMenuLabels.bind(this));

+ +

+ +        this.connect('destroy', this._onDestroy.bind(this));

+ +

+ +        Main.sessionMode.connect('updated', this._onSessionUpdated.bind(this));

+ +        this._onSessionUpdated();

+ +    }

+ +

+ +    _onDestroy() {

+ +        this._agent.disconnect(this._inUseId);

+ +        this._agent.disconnect(this._maxAccuracyId);

+ +    }

+ +

+ +    _onOnOffAction() {

+ +        this.enabled = !this.enabled;

+ +    }

+ +

+ +    _onSessionUpdated() {

+ +        let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;

+ +        this.menu.setSensitive(sensitive);

+ +    }

+ +

+ +    _updateMenuLabels() {

+ +        if (this.enabled) {

+ +            this._item.label.text = this._indicator.visible

+ +                ? _('Location In Use')

+ +                : _('Location Enabled');

+ +            this._onOffAction.label.text = _('Disable');

+ +        } else {

+ +            this._item.label.text = _('Location Disabled');

+ +            this._onOffAction.label.text = _('Enable');

+ +        }

+ +    }

+ +});

+ +

+  var AppAuthorizer = class {

+      constructor(desktopId, reqAccuracyLevel, permStoreProxy, maxAccuracyLevel) {

+          this.desktopId = desktopId;

+ -- 

+ 2.31.1

+ 

file modified
+7 -1
@@ -2,7 +2,7 @@ 

  

  Name:           gnome-shell

  Version:        40.3

- Release:        2%{?dist}

+ Release:        3%{?dist}

  Summary:        Window management and application launching for GNOME

  

  License:        GPLv2+
@@ -16,6 +16,9 @@ 

  # downstream patch to stop trying on configuration errors.

  Patch10005: 0001-gdm-Work-around-failing-fingerprint-auth.patch

  

+ # https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1919

+ Patch10006: 0001-location-Add-GObject-properties-to-Location.Indicato.patch

+ Patch10007: 0002-location-Split-Location.Indicator-into-a-seperate-Ge.patch

  

  %define eds_version 3.33.1

  %define gnome_desktop_version 3.35.91
@@ -234,6 +237,9 @@ 

  %{_mandir}/man1/gnome-shell.1*

  

  %changelog

+ * Tue Aug 03 2021 Carl George <carl@george.computer> - 40.3-3

+ - Backport upstream PR 1919

+ 

  * Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 40.3-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

  

This will be necessary in order for the Pop COSMIC extension to work.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1919

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

I was mistaken, this change is related to a possible future feature, and isn't related to making the extension compatible with GNOME 40.

Pull-Request has been closed by carlwgeorge

2 years ago