diff --git a/app/solaar.py b/app/solaar.py index 27be26ea..a9d55307 100644 --- a/app/solaar.py +++ b/app/solaar.py @@ -85,26 +85,7 @@ if __name__ == '__main__': listener = None notify_missing = True - def status_changed(receiver, device=None, ui_flags=0): - assert receiver is not None - if window: - GObject.idle_add(ui.main_window.update, window, receiver, device) - if icon: - GObject.idle_add(ui.status_icon.update, icon, receiver) - if ui_flags & STATUS.UI_POPUP: - GObject.idle_add(window.popup, icon) - - if device is None: - # always notify on receiver updates - ui_flags |= STATUS.UI_NOTIFY - if ui_flags & STATUS.UI_NOTIFY and ui.notify.available: - GObject.idle_add(ui.notify.show, device or receiver) - - global listener - if not listener: - GObject.timeout_add(5000, check_for_listener) - listener = None - + # initializes the receiver listener from receiver import ReceiverListener def check_for_listener(retry=True): def _check_still_scanning(listener): @@ -134,6 +115,28 @@ if __name__ == '__main__': pairing.state = pairing.State(listener) listener.trigger_device_events() + # callback delivering status events from the receiver/devices to the UI + def status_changed(receiver, device=None, ui_flags=0): + assert receiver is not None + if window: + GObject.idle_add(ui.main_window.update, window, receiver, device) + if icon: + GObject.idle_add(ui.status_icon.update, icon, receiver) + if ui_flags & STATUS.UI_POPUP: + GObject.idle_add(window.popup, icon) + + if device is None: + # always notify on receiver updates + ui_flags |= STATUS.UI_NOTIFY + if ui_flags & STATUS.UI_NOTIFY and ui.notify.available: + GObject.idle_add(ui.notify.show, device or receiver) + + global listener + if not listener: + GObject.timeout_add(5000, check_for_listener) + listener = None + + # clears all properties of devices that have been inactive for too long _DEVICE_TIMEOUT = 3 * 60 # seconds _DEVICE_STATUS_CHECK = 30 # seconds from time import time as _timestamp diff --git a/app/ui/action.py b/app/ui/action.py index 16a2bb36..72c0b508 100644 --- a/app/ui/action.py +++ b/app/ui/action.py @@ -44,11 +44,12 @@ def _show_about_window(action): about.set_logo_icon_name(_NAME) about.set_version(_VERSION) about.set_license_type(Gtk.License.GPL_2_0) + about.set_copyright('\xC2\xA9 2012 Daniel Pavel') about.set_authors(('Daniel Pavel http://github.com/pwr',)) # about.add_credit_section('Testing', 'Douglas Wagner') about.set_website('http://github.com/pwr/Solaar/wiki') about.set_website_label('Solaar Wiki') - # about.set_comments('Using Python %s\n' % PYTTHON_VERSION.split(' ')[0]) + about.set_comments('Shows status of devices connected\nto a Logitech Unifying Receiver.') about.run() about.destroy() about = _action('help-about', 'About ' + _NAME, _show_about_window) @@ -65,7 +66,6 @@ def _pair_device(action, frame): window = frame.get_toplevel() pair_dialog = ui.pair_window.create(action, pairing.state) - # window.present() pair_dialog.set_transient_for(window) pair_dialog.set_modal(True) diff --git a/lib/logitech/devices/constants.py b/lib/logitech/devices/constants.py index 0333b735..e7725f1e 100644 --- a/lib/logitech/devices/constants.py +++ b/lib/logitech/devices/constants.py @@ -37,14 +37,22 @@ PROPS = type('PROPS', (), NAMES = { 'M315': ('Wireless Mouse M315', 'mouse'), 'M325': ('Wireless Mouse M325', 'mouse'), + 'M505': ('Wireless Mouse M505', 'mouse'), 'M510': ('Wireless Mouse M510', 'mouse'), 'M515': ('Couch Mouse M515', 'mouse'), 'M525': ('Wireless Mouse M525', 'mouse'), 'M570': ('Wireless Trackball M570', 'trackball'), + 'M600': ('Touch Mouse M600', 'mouse'), + 'M705': ('Marathon Mouse M705', 'mouse'), 'K270': ('Wireless Keyboard K270', 'keyboard'), 'K350': ('Wireless Keyboard K350', 'keyboard'), + 'K360': ('Wireless Keyboard K360', 'keyboard'), + 'K400': ('Wireless Touch Keyboard K400', 'keyboard'), 'K750': ('Wireless Solar Keyboard K750', 'keyboard'), 'K800': ('Wireless Illuminated Keyboard K800', 'keyboard'), + 'T400': ('Zone Touch Mouse T400', 'mouse'), 'T650': ('Wireless Rechargeable Touchpad T650', 'touchpad'), + 'Cube': ('Logitech Cube', 'mouse'), + 'Anywhere MX': ('Anywhere Mouse MX', 'mouse'), 'Performance MX': ('Performance Mouse MX', 'mouse'), } diff --git a/lib/logitech/devices/k750.py b/lib/logitech/devices/k750.py index fdd3dbc4..81c139fa 100644 --- a/lib/logitech/devices/k750.py +++ b/lib/logitech/devices/k750.py @@ -6,8 +6,6 @@ import logging from struct import unpack as _unpack from .constants import (STATUS, PROPS) -from ..unifying_receiver.constants import FEATURE -from ..unifying_receiver import api as _api # # @@ -29,6 +27,8 @@ def _charge_status(data, hasLux=False): def request_status(devinfo): + from ..unifying_receiver.constants import FEATURE + from ..unifying_receiver import api as _api reply = _api.request(devinfo.handle, devinfo.number, feature=FEATURE.SOLAR_CHARGE, function=b'\x06', params=b'\x78\x01', features=devinfo.features) diff --git a/lib/logitech/unifying_receiver/api.py b/lib/logitech/unifying_receiver/api.py index 2366a652..95730d15 100644 --- a/lib/logitech/unifying_receiver/api.py +++ b/lib/logitech/unifying_receiver/api.py @@ -73,7 +73,7 @@ class ThreadedHandle(object): return str(int(self)) def __repr__(self): - return '' % self.path + return '' % self.path def __bool__(self): return bool(self._handles)