diff options
Diffstat (limited to '')
-rw-r--r-- | xpybar/config/myirc.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/xpybar/config/myirc.py b/xpybar/config/myirc.py new file mode 100644 index 0000000..3fa4b71 --- /dev/null +++ b/xpybar/config/myirc.py @@ -0,0 +1,38 @@ +# -*- python -*- +from common import * + +class MyIRC(Entry): + def __init__(self, *args, ii = None, **kwargs): + self.semaphore = threading.Semaphore() + self.text = 'Irc: 0' + self.count = 0 + self.ii = ii + Entry.__init__(self, *args, **kwargs) + + def colourise(self, n): + if n >= 1: return '32' + if n >= 5: return '33' + if n >= 10: return '31' + return '39' + + def adjust(self, n): + self.semaphore.acquire() + try: + self.count += n + if self.count < 0: + self.count = 0 + self.text = 'Irc: \033[%sm%i\033[0m' % (self.colourise(self.count), self.count) + finally: + self.semaphore.release() + self.invalidate() + + def action(self, col, button, x, y): + if self.count == 0: + return + if button == LEFT_BUTTON: + G.groupi = 1 + G.group = G.groups[G.groupi] + self.ii.action(0, RIGHT_BUTTON, 0, 0) + + def function(self): + return self.text |