diff options
author | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 12:55:18 +0200 |
---|---|---|
committer | Marek Siarkowicz <mareksiarkowicz@gmail.com> | 2015-06-15 12:55:52 +0200 |
commit | 65f9c06e00c78c382451458ea1d8a9dad1016fb0 (patch) | |
tree | 0f59941eac2c930cf3b37d525b04a05220249075 | |
parent | 8c724233f95dec5a871bb1eb39da621902d3fcd1 (diff) | |
download | pyParrotZikTCP-65f9c06e00c78c382451458ea1d8a9dad1016fb0.tar.xz pyParrotZikTCP-65f9c06e00c78c382451458ea1d8a9dad1016fb0.zip |
Refactor. Move
-rwxr-xr-x | parrot_zik/parrot_zik_tray | 28 | ||||
-rw-r--r-- | parrot_zik/utils.py | 31 |
2 files changed, 32 insertions, 27 deletions
diff --git a/parrot_zik/parrot_zik_tray b/parrot_zik/parrot_zik_tray index ae57e4d..914a37e 100755 --- a/parrot_zik/parrot_zik_tray +++ b/parrot_zik/parrot_zik_tray @@ -1,5 +1,4 @@ #!/usr/bin/env python -from threading import Lock import gtk from parrot_zik.interface.version1 import ParrotZikVersion1Interface @@ -9,37 +8,12 @@ from parrot_zik import bluetooth_paired_devices from parrot_zik.indicator import MenuItem from parrot_zik.indicator import Menu from parrot_zik.indicator import SysIndicator +from parrot_zik.utils import repeat REFRESH_FREQUENCY = 30000 RECONNECT_FREQUENCY = 5000 -class repeat(object): - def __init__(self, f): - self.f = f - self.id = None - self.lock = Lock() - - def __call__(self, cls): - self.f(cls) - - def start(self, cls, frequency): - self.lock.acquire() - if not self.id: - def run(): - self.f(cls) - return True - - self.id = gtk.timeout_add(frequency, run) - self.lock.release() - - def stop(self): - self.lock.acquire() - if self.id: - gtk.timeout_remove(self.id) - self.id = None - self.lock.release() - class ParrotZikIndicator(SysIndicator): def __init__(self): diff --git a/parrot_zik/utils.py b/parrot_zik/utils.py new file mode 100644 index 0000000..18b878d --- /dev/null +++ b/parrot_zik/utils.py @@ -0,0 +1,31 @@ +from threading import Lock + +import gtk + + +class repeat(object): + def __init__(self, f): + self.f = f + self.id = None + self.lock = Lock() + + def __call__(self, cls): + self.f(cls) + + def start(self, cls, frequency): + self.lock.acquire() + if not self.id: + def run(): + self.f(cls) + return True + + self.id = gtk.timeout_add(frequency, run) + self.lock.release() + + def stop(self): + self.lock.acquire() + if self.id: + gtk.timeout_remove(self.id) + self.id = None + self.lock.release() + |