First try for Gnome Shell 45

This commit is contained in:
Grégory Soutadé 2023-11-26 09:57:02 +01:00
parent 3ed3394a33
commit 63e48d7c8a
2 changed files with 30 additions and 42 deletions

View File

@ -29,17 +29,17 @@
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/panel.js https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/panel.js
*/ */
const St = imports.gi.St; import St from 'gi://St';
const Gio = imports.gi.Gio; import Gio from 'gi://Gio';
const GLib = imports.gi.GLib import GLib from 'gi://GLib';
const Main = imports.ui.main; import Main from 'resource:///org/gnome/shell/ui/main.js';
const Mainloop = imports.mainloop; import Clutter from 'gi://Clutter';
const Clutter = imports.gi.Clutter; import PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
const PanelMenu = imports.ui.panelMenu; import PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
const PopupMenu = imports.ui.popupMenu; import GObject from 'gi://GObject';
const GObject = imports.gi.GObject; import Pixbuf from 'gi://GdkPixbuf';
const Pixbuf = imports.gi.GdkPixbuf; import Cogl from 'gi://Cogl';
const Cogl = imports.gi.Cogl; import Extension from 'resource:///org/gnome/shell/extensions/extension.js';
function hashGet(hash, key, defaultValue) { function hashGet(hash, key, defaultValue) {
@ -50,7 +50,7 @@ function hashGet(hash, key, defaultValue) {
} }
function log(message) { function log(message) {
global.log('[GenericMontior]', message); console.error('[GenericMontior]', message);
} }
@ -189,8 +189,9 @@ class SignalMgt {
this.button = event.get_button(); this.button = event.get_button();
this.nbClicks = 1; this.nbClicks = 1;
let sourceId = Mainloop.timeout_add(this.dbus.ClutterSettings['double-click-time'], let sourceId = Glib.timeout_add(Glib.G_PRIORITY_DEFAULT,
this._doClickCallback.bind(this)); this.dbus.ClutterSettings['double-click-time'],
this._doClickCallback.bind(this));
this.timeouts.push(sourceId); 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 // From https://github.com/ubuntu/gnome-shell-extension-appindicator/blob/master/interfaces.js
// loads a xml file into an in-memory string // loads a xml file into an in-memory string
function loadInterfaceXml(filename) { function loadInterfaceXml(filename) {
const extension = imports.misc.extensionUtils.getCurrentExtension(); const extension = Extension.getCurrentExtension();
const interfacesDir = extension.dir.get_child('.'); const interfacesDir = extension.dir.get_child('.');
const file = interfacesDir.get_child(filename); 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) { if (result) {
// HACK: The "" + trick is important as hell because file_get_contents returns // 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() { enable() {
this.textDBusService = new GenericMonitorDBUS(); this.textDBusService = new GenericMonitorDBUS();
} }
disable() { disable() {
this.textDBusService.destructor(); if (this.textDBusService !== null) {
delete this.textDBusService; this.textDBusService.destructor();
} delete this.textDBusService;
} this.textDBusService = null;
}
let extension = null;
function init() {
}
function enable() {
extension = new Extension();
extension.enable();
}
function disable() {
if (extension) {
extension.disable();
extension = null;
} }
} }

View File

@ -2,13 +2,9 @@
"uuid": "generic-monitor@gnome-shell-extensions", "uuid": "generic-monitor@gnome-shell-extensions",
"name": "Generic Monitor", "name": "Generic Monitor",
"description": "Display text & icon on systray using DBUS", "description": "Display text & icon on systray using DBUS",
"version": "13", "version": "14",
"shell-version": [ "shell-version": [
"44", "45"
"43",
"42.3",
"42",
"41"
], ],
"url": "http://indefero.soutade.fr/p/genericmonitor" "url": "http://indefero.soutade.fr/p/genericmonitor"
} }