Add management for onDblClick, onRightClick and onRightDblClick events. Before they were put under Click event.
This commit is contained in:
parent
8a480254cd
commit
4c52c9fa8e
69
extension.js
69
extension.js
|
@ -17,12 +17,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Based on https://stackoverflow.com/questions/33001192/how-to-send-a-string-to-a-gnome-shell-extension */
|
/* 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
|
Some useful documentation :
|
||||||
// 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://github.com/bananenfisch/RecentItems/blob/master/extension.js
|
||||||
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panel.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 St = imports.gi.St;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
|
@ -112,10 +118,13 @@ class MonitorWidget extends PanelMenu.Button {
|
||||||
if (item.hasOwnProperty('popup'))
|
if (item.hasOwnProperty('popup'))
|
||||||
this._createPopup(item['popup']);
|
this._createPopup(item['popup']);
|
||||||
|
|
||||||
this.onClick = hash_get(item, 'on-click', '');
|
this.onClick = hash_get(item, 'on-click', '');
|
||||||
this.onEnter = hash_get(item, 'on-enter', '');
|
this.onDblClick = hash_get(item, 'on-dblclick', '');
|
||||||
this.onLeave = hash_get(item, 'on-leave', '');
|
this.onRightClick = hash_get(item, 'on-rightclick', '');
|
||||||
this.onScroll = hash_get(item, 'on-scroll', '');
|
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', '');
|
||||||
|
|
||||||
let box = hash_get(item, 'box', 'center');
|
let box = hash_get(item, 'box', 'center');
|
||||||
|
|
||||||
|
@ -298,17 +307,26 @@ class MonitorWidget extends PanelMenu.Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
_doClickCallback() {
|
_doClickCallback() {
|
||||||
if (this.onClick === 'signal') {
|
let right = '';
|
||||||
let right = '';
|
let nbClicks = '';
|
||||||
let nbClicks = '';
|
if (this.button == 3)
|
||||||
if (this.button == 3)
|
right = 'Right';
|
||||||
right = 'Right';
|
if (this.nbClicks > 1)
|
||||||
if (this.nbClicks > 1)
|
nbClicks = 'Dbl';
|
||||||
nbClicks = 'Dbl';
|
let signalName = 'on' + right + nbClicks + 'Click';
|
||||||
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);
|
this.dbus.emit_signal(signalName, this.fullname);
|
||||||
} else
|
else
|
||||||
this._manageEventAction(this.onClick);
|
this._manageEventAction(action);
|
||||||
this.nbClicks = 0;
|
this.nbClicks = 0;
|
||||||
this.button = -1;
|
this.button = -1;
|
||||||
|
|
||||||
|
@ -442,10 +460,13 @@ class MonitorWidget extends PanelMenu.Button {
|
||||||
this.menu.open(true);
|
this.menu.open(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onClick = hash_get(item, 'on-click', this.onClick);
|
this.onClick = hash_get(item, 'on-click', this.onClick);
|
||||||
this.onEnter = hash_get(item, 'on-enter', this.onEnter);
|
this.onDblClick = hash_get(item, 'on-dblclick', this.onDblClick);
|
||||||
this.onLeave = hash_get(item, 'on-leave', this.onLeave);
|
this.onRightClick = hash_get(item, 'on-rightclick', this.onRightClick);
|
||||||
this.onScroll = hash_get(item, 'on-scroll', this.onScroll);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
openPopup() {
|
openPopup() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user