Add onActivate and onDeactivate signals

This commit is contained in:
Grégory Soutadé 2020-05-07 08:39:13 +02:00
parent acc5ef7f4f
commit 3b7247f97e
3 changed files with 15 additions and 2 deletions

View File

@ -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
-------

View File

@ -1,4 +1,5 @@
<interface name="com.soutade.GenericMonitor">
<!-- Functions -->
<method name="notify">
<arg type="s" direction="in" />
</method>
@ -8,6 +9,7 @@
<method name="deleteGroups">
<arg type="s" direction="in" />
</method>
<!-- Click events -->
<signal name="onClick">
<arg type="s" direction="out" />
</signal>
@ -20,4 +22,9 @@
<signal name="onRightDblClick">
<arg type="s" direction="out" />
</signal>
<!-- Activate/Deactivate signals -->
<signal name="onActivate">
</signal>
<signal name="onDectivate">
</signal>
</interface>

View File

@ -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)