From 0d825e2e3c0d5753b0c91eb0d7bd42c2abd92f0c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 12 Feb 2018 11:42:05 +1000 Subject: [PATCH] wacom: replace the signal forwarders with lambdas We're doing nothing but forwarding the signal here, so let's just replace them with lambdas so it's immediately obvious what we do with the signal. --- tuhi/wacom.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tuhi/wacom.py b/tuhi/wacom.py index 18f0d2f..b4f70b4 100644 --- a/tuhi/wacom.py +++ b/tuhi/wacom.py @@ -766,17 +766,14 @@ class WacomDevice(GObject.Object): logger.debug(f'{self._device.name} is using protocol {protocol}') - self._wacom_protocol.connect('drawing', self._on_drawing_received) - self._wacom_protocol.connect('battery-status', self._on_battery_status) - - def _on_drawing_received(self, protocol, drawing): - self.emit('drawing', drawing) - - def _on_button_press_required(self, protocol): - self.emit('button-press-required') - - def _on_battery_status(self, protocol, percent, is_charging): - self.emit('battery-status', percent, is_charging) + self._wacom_protocol.connect( + 'drawing', + lambda protocol, drawing, self: self.emit('drawing', drawing), + self) + self._wacom_protocol.connect( + 'battery-status', + lambda prot, percent, is_charging, self: self.emit('battery-status', percent, is_charging), + self) @GObject.Property def uuid(self): @@ -793,7 +790,9 @@ class WacomDevice(GObject.Object): logger.debug(f'{self._device.address}: registering device, assigned {self.uuid}') wp = WacomRegisterHelper(self._device) - s = wp.connect('button-press-required', self._on_button_press_required) + s = wp.connect('button-press-required', + lambda protocol, self: self.emit('button-press-required'), + self) protocol = wp.register_device(self._uuid) wp.disconnect(s) del wp