From 3b7247f97e3638b6f05c8317faf501ec2b059619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 7 May 2020 08:39:13 +0200 Subject: [PATCH] Add onActivate and onDeactivate signals --- README.md | 5 +++++ dbus.xml | 7 +++++++ extension.js | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6324702..3bc21b0 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ extension emit one of the following signals : * onDblClick * onRightDblClick +Other signals are available when extension is activated/deactivated : + + * onActivate + * onDeactivate + Example ------- diff --git a/dbus.xml b/dbus.xml index d189808..6cc828e 100644 --- a/dbus.xml +++ b/dbus.xml @@ -1,4 +1,5 @@ + @@ -8,6 +9,7 @@ + @@ -20,4 +22,9 @@ + + + + + diff --git a/extension.js b/extension.js index 7a14aeb..ec2464c 100644 --- a/extension.js +++ b/extension.js @@ -49,7 +49,7 @@ class MonitorWidget { // Don't know why, _rightBox seems undefined on shell 3.36 !! if (this.box === undefined) { - log(`${box} is undefined, falling back to centerBox`); + log(`${box} box is undefined, falling back to center one`); this.box = Main.panel._centerBox; } @@ -79,7 +79,6 @@ class MonitorWidget { _addToBox(lastWidget) { // lastWidget => NULL, insert at the end - // Add to box if (this.box !== Main.panel._rigthBox || lastWidget) { if (this.icon) { this.box.insert_child_above(this.icon, lastWidget); @@ -177,6 +176,7 @@ class GenericMonitorDBUS { this.clutterSettings = clutter.Settings.get_default(); this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(loadInterfaceXml('dbus.xml'), this); this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor'); + this._dbusImpl.emit_signal('onActivate', null); } _checkParmeters(parameters) { @@ -399,6 +399,7 @@ class GenericMonitorDBUS { } destructor() { + this._dbusImpl.emit_signal('onDeactivate', null); for (let groupIndex in this.monitor_groups) { let group = this.monitor_groups[groupIndex]; for (let itemIndex in group)