From 8219c0213c74c4ae09258022f00086353883682b Mon Sep 17 00:00:00 2001
From: Florian Müllner <fmuellner@gnome.org>
Date: Aug 06 2023 14:42:50 +0000
Subject: [PATCH 1/2] lint: Sync with gjs/gnome-shell


Adapt to removed jsdoc-plugin rule and be less strict about
mandating doc comments and strict type comparisons.

---

diff --git a/lint/eslintrc-gjs.yml b/lint/eslintrc-gjs.yml
index 62fd4a2..e1f4519 100644
--- a/lint/eslintrc-gjs.yml
+++ b/lint/eslintrc-gjs.yml
@@ -68,7 +68,10 @@ rules:
   jsdoc/check-tag-names: error
   jsdoc/check-types: error
   jsdoc/implements-on-classes: error
-  jsdoc/newline-after-description: error
+  jsdoc/tag-lines: 
+    - error
+    - any
+    - startLines: 1
   jsdoc/require-jsdoc: error
   jsdoc/require-param: error
   jsdoc/require-param-description: error
diff --git a/lint/eslintrc-shell.yml b/lint/eslintrc-shell.yml
index 30fb077..77379b8 100644
--- a/lint/eslintrc-shell.yml
+++ b/lint/eslintrc-shell.yml
@@ -4,11 +4,20 @@ rules:
     - properties: never
       allow: [^vfunc_, ^on_]
   consistent-return: error
+  eqeqeq:
+    - error
+    - smart
   key-spacing:
     - error
     - mode: minimum
       beforeColon: false
       afterColon: true
   prefer-arrow-callback: error
+  jsdoc/require-param-description: off
+  jsdoc/require-jsdoc:
+    - error
+    - exemptEmptyFunctions: true
+      publicOnly:
+        esm: true
 globals:
   global: readonly

From 2644ad0284a532b99a17c2613ab0a1294aad4922 Mon Sep 17 00:00:00 2001
From: Florian Müllner <fmuellner@gnome.org>
Date: Aug 06 2023 14:42:50 +0000
Subject: [PATCH 2/2] Port to ESM


gnome-shell now uses ESM both internally and for loading extensions.
Adapt to those changes to work with versions above 45.

---

diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index f923d31..0000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-    "extends": [
-        "./lint/eslintrc-gjs.yml",
-        "./lint/eslintrc-shell.yml"
-    ]
-}
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..bd06d4f
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,5 @@
+extends:
+ - ./lint/eslintrc-gjs.yml
+ - ./lint/eslintrc-shell.yml
+parserOptions:
+    sourceType: module
diff --git a/extension.js b/extension.js
index 5c3bd6e..71b0a3f 100644
--- a/extension.js
+++ b/extension.js
@@ -15,11 +15,17 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
-const {Clutter, Gio, GLib, GObject, Meta, St} = imports.gi;
+import Clutter from 'gi://Clutter';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Meta from 'gi://Meta';
+import St from 'gi://St';
 
-const Background = imports.ui.background;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Main = imports.ui.main;
+import {Extension, InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
+
+import * as Background from 'resource:///org/gnome/shell/ui/background.js';
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
 
 var IconContainer = GObject.registerClass(
 class IconContainer extends St.Widget {
@@ -42,7 +48,7 @@ class BackgroundLogo extends St.Widget {
 
         this._logoFile = null;
 
-        this._settings = ExtensionUtils.getSettings();
+        this._settings = Extension.lookupByURL(import.meta.url).getSettings();
         this._ifaceSettings = new Gio.Settings({
             schema_id: 'org.gnome.desktop.interface',
         });
@@ -249,10 +255,10 @@ class BackgroundLogo extends St.Widget {
 });
 
 
-class Extension {
-    constructor() {
-        this._bgManagerProto = Background.BackgroundManager.prototype;
-        this._createBackgroundOrig = this._bgManagerProto._createBackgroundActor;
+export default class BackgroundLogoExtension extends Extension {
+    constructor(metadata) {
+        super(metadata);
+        this._injectionManager = new InjectionManager();
     }
 
     _reloadBackgrounds() {
@@ -260,23 +266,22 @@ class Extension {
     }
 
     enable() {
-        const {_createBackgroundOrig} = this;
-        this._bgManagerProto._createBackgroundActor = function () {
-            const backgroundActor = _createBackgroundOrig.call(this);
-            const logo_ = new BackgroundLogo(backgroundActor);
-
-            return backgroundActor;
-        };
+        const bgMgrProto = Background.BackgroundManager.prototype;
+        this._injectionManager.overrideMethod(bgMgrProto, '_createBackgroundActor', originalMethod => {
+            /* eslint-disable no-invalid-this */
+            return function () {
+                const backgroundActor = originalMethod.call(this);
+                const logo_ = new BackgroundLogo(backgroundActor);
+
+                return backgroundActor;
+            };
+            /* eslint-enable */
+        });
         this._reloadBackgrounds();
     }
 
     disable() {
-        this._bgManagerProto._createBackgroundActor = this._createBackgroundOrig;
+        this._injectionManager.clear();
         this._reloadBackgrounds();
     }
 }
-
-/** */
-function init() {
-    return new Extension();
-}
diff --git a/prefs.js b/prefs.js
index 1e5b0fb..ab9880c 100644
--- a/prefs.js
+++ b/prefs.js
@@ -1,8 +1,14 @@
-/* exported init, buildPrefsWidget */
-const {Adw, Gdk, GdkPixbuf, Gio, GLib, GnomeDesktop, GObject, Gtk} = imports.gi;
+import Adw from 'gi://Adw';
+import Gdk from 'gi://Gdk';
+import GdkPixbuf from 'gi://GdkPixbuf';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import GnomeDesktop from 'gi://GnomeDesktop?version=4.0';
+import Gtk from 'gi://Gtk';
 const ByteArray = imports.byteArray;
 
-const ExtensionUtils = imports.misc.extensionUtils;
+import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
 
 const BACKGROUND_SCHEMA = 'org.gnome.desktop.background';
 
@@ -309,22 +315,17 @@ class OptionsGroup extends Adw.PreferencesGroup {
 
 const BackgroundLogoPrefsWidget = GObject.registerClass(
 class BackgroundLogoPrefsWidget extends Adw.PreferencesPage {
-    _init() {
+    _init(settings) {
         super._init();
 
-        const settings = ExtensionUtils.getSettings();
-
         this.add(new PreviewGroup(settings));
         this.add(new LogoGroup(settings));
         this.add(new OptionsGroup(settings));
     }
 });
 
-/** */
-function init() {
-}
-
-/** */
-function buildPrefsWidget() {
-    return new BackgroundLogoPrefsWidget();
+export default class BackgroundLogoPreferences extends ExtensionPreferences {
+    getPreferencesWidget() {
+        return new BackgroundLogoPrefsWidget(this.getSettings());
+    }
 }

