diff --git a/README.md b/README.md
index 543dde9..d0340c6 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,7 @@ All functions read JSON formatted parameters
"group": "groupname",
// style and icon-style are optional
// item can have text and/or icon
+ // item can have click action "signal" or "delete"
"items": [
{
"name":"",
@@ -32,6 +33,7 @@ All functions read JSON formatted parameters
"style":"",
"icon-style":"",
"icon":"",
+ "on-click":"",
}, ...
]
}
@@ -48,6 +50,15 @@ All functions read JSON formatted parameters
}
+When text/icon is clicked and on-click parameter is set to "signal",
+extension emit one of the following signals :
+
+ * onClick
+ * onRightClick
+ * onDblClick
+ * onRightDblClick
+
+
Example
-------
diff --git a/dbus.xml b/dbus.xml
index cd4f275..d189808 100644
--- a/dbus.xml
+++ b/dbus.xml
@@ -8,4 +8,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extension.js b/extension.js
index f8d8f7d..96d5562 100644
--- a/extension.js
+++ b/extension.js
@@ -20,14 +20,19 @@
const St = imports.gi.St;
const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+const GLib = imports.gi.GLib
const Main = imports.ui.main;
+const Mainloop = imports.mainloop;
+const clutter = imports.gi.Clutter;
class MonitorWidget {
- constructor(name, group, text, style, icon, iconStyle) {
+ constructor(name, group, text, style, icon, iconStyle, onClick) {
this.name = name;
this.group = group;
this._createIcon(icon, iconStyle);
this._createText(text, style);
+ this.onClick = onClick;
}
_createText(text, style) {
@@ -100,6 +105,8 @@ function loadInterfaceXml(filename) {
class GenericMonitorDBUS {
constructor() {
this.monitor_groups = {};
+ this.actor_clicked = {};
+ this.clutterSettings = clutter.Settings.get_default();
this.box = Main.panel._centerBox;
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(loadInterfaceXml('dbus.xml'), this);
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
@@ -118,6 +125,10 @@ class GenericMonitorDBUS {
throw new Error('No name defined for item');
if (!item.hasOwnProperty('text') && !item.hasOwnProperty('icon'))
throw new Error('No text not icon defined for item');
+ if (item.hasOwnProperty('on-click')) {
+ if (item['on-click'] !== 'signal' && item['on-click'] !== 'delete')
+ throw new Error('Invalid on-click value');
+ }
}
}
@@ -131,6 +142,73 @@ class GenericMonitorDBUS {
return null;
}
+ _doClickCallback() {
+ for(let itemIndex in this.actor_clicked) {
+ let item = this.actor_clicked[itemIndex];
+ let right = '';
+ let nbClicks = '';
+ if (item['button'] == 3)
+ right = 'Right';
+ if (item['nbClicks'] > 1)
+ nbClicks = 'Dbl';
+ let signalName = 'on' + right + nbClicks + 'Click';
+ this._dbusImpl.emit_signal(signalName, GLib.Variant.new('(s)',[item['name']]));
+ }
+ this.actor_clicked = {}
+ }
+
+ _actorToMonitorWidget(actor) {
+ for (let groupName in this.monitor_groups) {
+ let group = this.monitor_groups[groupName];
+ for (let itemIndex in group) {
+ let item = group[itemIndex];
+ if (item.widget === actor ||
+ item.icon === actor)
+ return [groupName, item];
+ }
+ }
+ return null;
+ }
+
+ _removeFromArray(array, value) {
+ for(let i=0; i