From 63e48d7c8a90664ee7942a4bc87e71125db8c782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 26 Nov 2023 09:57:02 +0100 Subject: [PATCH] First try for Gnome Shell 45 --- extension.js | 64 ++++++++++++++++++++++----------------------------- metadata.json | 8 ++----- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/extension.js b/extension.js index d72ef1c..d980836 100644 --- a/extension.js +++ b/extension.js @@ -29,17 +29,17 @@ https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/panel.js */ -const St = imports.gi.St; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib -const Main = imports.ui.main; -const Mainloop = imports.mainloop; -const Clutter = imports.gi.Clutter; -const PanelMenu = imports.ui.panelMenu; -const PopupMenu = imports.ui.popupMenu; -const GObject = imports.gi.GObject; -const Pixbuf = imports.gi.GdkPixbuf; -const Cogl = imports.gi.Cogl; +import St from 'gi://St'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Main from 'resource:///org/gnome/shell/ui/main.js'; +import Clutter from 'gi://Clutter'; +import PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; +import PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; +import GObject from 'gi://GObject'; +import Pixbuf from 'gi://GdkPixbuf'; +import Cogl from 'gi://Cogl'; +import Extension from 'resource:///org/gnome/shell/extensions/extension.js'; function hashGet(hash, key, defaultValue) { @@ -50,7 +50,7 @@ function hashGet(hash, key, defaultValue) { } function log(message) { - global.log('[GenericMontior]', message); + console.error('[GenericMontior]', message); } @@ -189,8 +189,9 @@ class SignalMgt { this.button = event.get_button(); this.nbClicks = 1; - let sourceId = Mainloop.timeout_add(this.dbus.ClutterSettings['double-click-time'], - this._doClickCallback.bind(this)); + let sourceId = Glib.timeout_add(Glib.G_PRIORITY_DEFAULT, + this.dbus.ClutterSettings['double-click-time'], + this._doClickCallback.bind(this)); this.timeouts.push(sourceId); } @@ -556,13 +557,13 @@ class MonitorWidget extends PanelMenu.Button { // From https://github.com/ubuntu/gnome-shell-extension-appindicator/blob/master/interfaces.js // loads a xml file into an in-memory string function loadInterfaceXml(filename) { - const extension = imports.misc.extensionUtils.getCurrentExtension(); + const extension = Extension.getCurrentExtension(); const interfacesDir = extension.dir.get_child('.'); const file = interfacesDir.get_child(filename); - let [result, contents] = imports.gi.GLib.file_get_contents(file.get_path()); + let [result, contents] = GLib.file_get_contents(file.get_path()); if (result) { // HACK: The "" + trick is important as hell because file_get_contents returns @@ -799,30 +800,21 @@ class GenericMonitorDBUS { } } -class Extension { +export default class GenericMonitorExtension { + constructor(...args) { + super(...args); + this.textDBusService = null; + } + enable() { this.textDBusService = new GenericMonitorDBUS(); } disable() { - this.textDBusService.destructor(); - delete this.textDBusService; - } -} - -let extension = null; - -function init() { -} - -function enable() { - extension = new Extension(); - extension.enable(); -} - -function disable() { - if (extension) { - extension.disable(); - extension = null; + if (this.textDBusService !== null) { + this.textDBusService.destructor(); + delete this.textDBusService; + this.textDBusService = null; + } } } diff --git a/metadata.json b/metadata.json index 0d061ff..263c022 100644 --- a/metadata.json +++ b/metadata.json @@ -2,13 +2,9 @@ "uuid": "generic-monitor@gnome-shell-extensions", "name": "Generic Monitor", "description": "Display text & icon on systray using DBUS", - "version": "13", + "version": "14", "shell-version": [ - "44", - "43", - "42.3", - "42", - "41" + "45" ], "url": "http://indefero.soutade.fr/p/genericmonitor" }