Add signal management in _manageEventAction()

This commit is contained in:
Grégory Soutadé 2020-11-19 14:23:46 +01:00
parent fbf138faee
commit c8dc01fe62

View File

@ -290,7 +290,7 @@ class MonitorWidget extends PanelMenu.Button {
return box; return box;
} }
_manageEventAction(action) { _manageEventAction(action, signalName) {
if (action === 'open-popup') if (action === 'open-popup')
this.menu.open(true); this.menu.open(true);
else if (action === 'close-popup') else if (action === 'close-popup')
@ -299,6 +299,8 @@ class MonitorWidget extends PanelMenu.Button {
this.menu.toggle(); this.menu.toggle();
else if (action == 'delete') else if (action == 'delete')
this.dbus.deleteItem(this, this.group); this.dbus.deleteItem(this, this.group);
else if (action === 'signal')
this.dbus.emitSignal(signalName, this.fullname);
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
@ -310,10 +312,12 @@ class MonitorWidget extends PanelMenu.Button {
_doClickCallback() { _doClickCallback() {
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'; let action = 'signal';
@ -324,10 +328,8 @@ class MonitorWidget extends PanelMenu.Button {
case 'onRightDblClick': action = this.onRightDblClick; break; case 'onRightDblClick': action = this.onRightDblClick; break;
} }
if (action === 'signal') this._manageEventAction(action, signalName);
this.dbus.emitSignal(signalName, this.fullname);
else
this._manageEventAction(action);
this.nbClicks = 0; this.nbClicks = 0;
this.button = -1; this.button = -1;
@ -349,34 +351,22 @@ class MonitorWidget extends PanelMenu.Button {
} }
_onEnter(/*actor, event*/) { _onEnter(/*actor, event*/) {
if (this.onEnter === 'signal') return this._manageEventAction(this.onEnter, 'onEnter');
this.dbus.emitSignal('onEnter', this.fullname);
else
return this._manageEventAction(this.onEnter);
return Clutter.EVENT_PROPAGATE;
} }
_onLeave(/*actor, event*/) { _onLeave(/*actor, event*/) {
if (this.onLeave === 'signal') return this._manageEventAction(this.onLeave, 'onLeave');
this.dbus.emitSignal('onLeave', this.fullname);
else
return this._manageEventAction(this.onLeave);
return Clutter.EVENT_PROPAGATE;
} }
_onScroll(actor, event) { _onScroll(actor, event) {
if (this.onScroll === 'signal') { let signalName = '';
let direction = event.get_scroll_direction (); let direction = event.get_scroll_direction ();
if (direction == Clutter.ScrollDirection.UP) if (direction == Clutter.ScrollDirection.UP)
this.dbus.emitSignal('onScrollUp', this.fullname); signalName = 'onScrollUp';
else if (direction == Clutter.ScrollDirection.DOWN) else if (direction == Clutter.ScrollDirection.DOWN)
this.dbus.emitSignal('onScrollDown', this.fullname); signalName = 'onScrollDown';
} else
return this._manageEventAction(this.onScroll);
return Clutter.EVENT_PROPAGATE; return this._manageEventAction(this.onScroll, signalName);
} }
update(item) { update(item) {