diff --git a/System_Monitor@bghome.gmail.com/extension.js b/System_Monitor@bghome.gmail.com/extension.js index c9d46b6..2b42ca3 100644 --- a/System_Monitor@bghome.gmail.com/extension.js +++ b/System_Monitor@bghome.gmail.com/extension.js @@ -8,9 +8,9 @@ import * as View from './view.js'; import * as PrefsKeys from './prefs_keys.js'; const Timer = class { - constructor(params) { - this._settings = params.settings; - this._view = params.view; + constructor(view, settings) { + this._settings = settings; + this._view = view; } start(update_interval) { @@ -42,6 +42,7 @@ const Timer = class { } destroy() { + this.stop(); this._view.destroy(); this._settings = null; this._view = null; @@ -52,12 +53,12 @@ export default class SystemMonitorExtension extends Extension { #timer; enable() { - this.#timer = new Timer({view: new View.Menu({settings: this.getSettings()}), settings: this.getSettings()}); + let settings = this.getSettings(); + this.#timer = new Timer(new View.Menu(this, settings), settings); this.#timer.start(); } disable() { - this.#timer.stop(); this.#timer.destroy(); this.#timer = null; } diff --git a/System_Monitor@bghome.gmail.com/factory.js b/System_Monitor@bghome.gmail.com/factory.js index b735cf9..6283bce 100644 --- a/System_Monitor@bghome.gmail.com/factory.js +++ b/System_Monitor@bghome.gmail.com/factory.js @@ -56,7 +56,7 @@ IconFactory.prototype.concreteClass = IndicatorModule.Icon; // Create an indicator icon object, options will be passed to the real object's constructor. // // For working with themed icons see http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html -IconFactory.prototype.create = function(type, options, can_show_activity) { +IconFactory.prototype.create = function(type, options, can_show_activity, extensionObject) { let default_options = { style_class: 'system-status-icon system-monitor-icon', reactive: true, @@ -65,7 +65,6 @@ IconFactory.prototype.create = function(type, options, can_show_activity) { } let constructor_options = Object.assign(default_options, options); - let extensionObject = Extension.lookupByURL(import.meta.url); if (type == PrefsKeys.STORAGE_METER) { constructor_options.icon_name = 'drive-harddisk-symbolic'; diff --git a/System_Monitor@bghome.gmail.com/util.js b/System_Monitor@bghome.gmail.com/util.js index 35beae0..8bf73eb 100644 --- a/System_Monitor@bghome.gmail.com/util.js +++ b/System_Monitor@bghome.gmail.com/util.js @@ -254,7 +254,6 @@ StopWatch.prototype.printElapsed = function (name) { export const logError = function(error) { let sourceFile = error.fileName; let sourceLine = error.lineNumber; - let extensionObject = Extension.lookupByURL(import.meta.url); - console.error(`Extension ${extensionObject.metadata.uuid}: "${error}" ${sourceFile}:${sourceLine}`); + console.error(`Extension System_Monitor@bghome.gmail.com: "${error}" ${sourceFile}:${sourceLine}`); }; diff --git a/System_Monitor@bghome.gmail.com/view.js b/System_Monitor@bghome.gmail.com/view.js index 02506a2..4242668 100644 --- a/System_Monitor@bghome.gmail.com/view.js +++ b/System_Monitor@bghome.gmail.com/view.js @@ -12,13 +12,14 @@ import * as PrefsKeys from './prefs_keys.js'; export const Menu = GObject.registerClass( class Menu extends PanelMenu.Button { - _init() { + constructor(extensionObject, settings) { let menuAlignment = 0.5; - let extensionObject = Extension.lookupByURL(import.meta.url); - super._init(menuAlignment); + + super(menuAlignment); this._layout = new St.BoxLayout(); - this._settings = extensionObject.getSettings(); + this._settings = settings; + this._extensionObject = extensionObject; this._icons = {}; this._meters = {}; this._meter_widgets = {}; @@ -94,7 +95,7 @@ class Menu extends PanelMenu.Button { } _createIcon(type) { let can_show_activity = this._settings.get_boolean(PrefsKeys.SHOW_ACTIVITY); - let icon = FactoryModule.AbstractFactory.create('icon', type, {}, can_show_activity); + let icon = FactoryModule.AbstractFactory.create('icon', type, {}, can_show_activity, this._extensionObject); let meter = this._meters[type]; if (meter == undefined) { @@ -120,7 +121,7 @@ class Menu extends PanelMenu.Button { meter.addObserver(icon); this._layout.insert_child_at_index(icon, this.available_meters.indexOf(type)); this._icons[type] = icon; - return FactoryModule.AbstractFactory.create('icon', type, {}, can_show_activity); + return FactoryModule.AbstractFactory.create('icon', type, {}, can_show_activity, this._extensionObject); } _destroyIcon(type) { let icon = this._icons[type];