[gnome-shell-extensions] extensions: Stop monkey-patching signal methods



commit 9f88e98d1bfbd5f1b20c574c2c761765ebf1d939
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Aug 20 18:48:25 2022 +0200

    extensions: Stop monkey-patching signal methods
    
    gnome-shell added an EventEmitter class that can be used as base
    for any non-GObject class that needs to emit signals.
    
    Use that instead of the old monkey-patching.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/240>

 extensions/apps-menu/extension.js      |  7 ++++---
 extensions/places-menu/placeDisplay.js | 12 +++++++-----
 2 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 6757f21..23da6c0 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -4,7 +4,7 @@
 const {
     Atk, Clutter, Gio, GLib, GMenu, GObject, Gtk, Meta, Shell, St,
 } = imports.gi;
-const Signals = imports.signals;
+const {EventEmitter} = imports.misc.signals;
 
 const DND = imports.ui.dnd;
 const ExtensionUtils = imports.misc.extensionUtils;
@@ -239,8 +239,10 @@ class ApplicationsMenu extends PopupMenu.PopupMenu {
     }
 }
 
-class DesktopTarget {
+class DesktopTarget extends EventEmitter {
     constructor() {
+        super();
+
         this._desktop = null;
         this._desktopDestroyedId = 0;
 
@@ -357,7 +359,6 @@ class DesktopTarget {
         return true;
     }
 }
-Signals.addSignalMethods(DesktopTarget.prototype);
 
 class ApplicationsButton extends PanelMenu.Button {
     static {
diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js
index 37ca166..9b5c205 100644
--- a/extensions/places-menu/placeDisplay.js
+++ b/extensions/places-menu/placeDisplay.js
@@ -2,7 +2,7 @@
 /* exported PlacesManager */
 
 const {Gio, GLib, Shell} = imports.gi;
-const Signals = imports.signals;
+const {EventEmitter} = imports.misc.signals;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const Main = imports.ui.main;
@@ -23,8 +23,10 @@ const Hostname1Iface = '<node> \
 </node>';
 const Hostname1 = Gio.DBusProxy.makeProxyWrapper(Hostname1Iface);
 
-class PlaceInfo {
+class PlaceInfo extends EventEmitter {
     constructor(...params) {
+        super();
+
         this._init(...params);
     }
 
@@ -119,7 +121,6 @@ class PlaceInfo {
         }
     }
 }
-Signals.addSignalMethods(PlaceInfo.prototype);
 
 class RootInfo extends PlaceInfo {
     _init() {
@@ -247,8 +248,10 @@ const DEFAULT_DIRECTORIES = [
     GLib.UserDirectory.DIRECTORY_VIDEOS,
 ];
 
-var PlacesManager = class {
+var PlacesManager = class extends EventEmitter {
     constructor() {
+        super();
+
         this._places = {
             special: [],
             devices: [],
@@ -544,4 +547,3 @@ var PlacesManager = class {
         return this._places[kind];
     }
 };
-Signals.addSignalMethods(PlacesManager.prototype);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]