Add management for onDblClick, onRightClick and onRightDblClick events. Before they were put under Click event.

This commit is contained in:
Grégory Soutadé 2020-11-18 16:17:58 +01:00
parent 8a480254cd
commit 4c52c9fa8e

View File

@ -17,12 +17,18 @@
*/
/* Based on https://stackoverflow.com/questions/33001192/how-to-send-a-string-to-a-gnome-shell-extension */
// https://github.com/bananenfisch/RecentItems/blob/master/extension.js
// https://github.com/julio641742/gnome-shell-extension-reference/blob/master/tutorials/POPUPMENU-EXTENSION.md
// https://gjs-docs.gnome.org/st10~1.0_api/st.widget
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panelMenu.js
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/popupMenu.js
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panel.js
/*
Some useful documentation :
https://github.com/bananenfisch/RecentItems/blob/master/extension.js
https://github.com/julio641742/gnome-shell-extension-reference/blob/master/tutorials/POPUPMENU-EXTENSION.md
https://gjs-docs.gnome.org/st10~1.0_api/st.widget
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panelMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/popupMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panel.js
*/
const St = imports.gi.St;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
@ -113,6 +119,9 @@ class MonitorWidget extends PanelMenu.Button {
this._createPopup(item['popup']);
this.onClick = hash_get(item, 'on-click', '');
this.onDblClick = hash_get(item, 'on-dblclick', '');
this.onRightClick = hash_get(item, 'on-rightclick', '');
this.onRightDblClick = hash_get(item, 'on-rightdblclick', '');
this.onEnter = hash_get(item, 'on-enter', '');
this.onLeave = hash_get(item, 'on-leave', '');
this.onScroll = hash_get(item, 'on-scroll', '');
@ -298,7 +307,6 @@ class MonitorWidget extends PanelMenu.Button {
}
_doClickCallback() {
if (this.onClick === 'signal') {
let right = '';
let nbClicks = '';
if (this.button == 3)
@ -306,9 +314,19 @@ class MonitorWidget extends PanelMenu.Button {
if (this.nbClicks > 1)
nbClicks = 'Dbl';
let signalName = 'on' + right + nbClicks + 'Click';
let action = 'signal';
switch(signalName) {
case 'onClick': action = this.onClick; break;
case 'onDblClick': action = this.onDblClick; break;
case 'onRightClick': action = this.onRightClick; break;
case 'onRightDblClick': action = this.onRightDblClick; break;
}
if (action === 'signal')
this.dbus.emit_signal(signalName, this.fullname);
} else
this._manageEventAction(this.onClick);
else
this._manageEventAction(action);
this.nbClicks = 0;
this.button = -1;
@ -443,6 +461,9 @@ class MonitorWidget extends PanelMenu.Button {
}
this.onClick = hash_get(item, 'on-click', this.onClick);
this.onDblClick = hash_get(item, 'on-dblclick', this.onDblClick);
this.onRightClick = hash_get(item, 'on-rightclick', this.onRightClick);
this.onRightDblClick = hash_get(item, 'on-rightdblclick', this.onRightDblClick);
this.onEnter = hash_get(item, 'on-enter', this.onEnter);
this.onLeave = hash_get(item, 'on-leave', this.onLeave);
this.onScroll = hash_get(item, 'on-scroll', this.onScroll);