Update release notes for 1.4.2.2
[git-cola.git] / cola / notification.py
blob69afa03a3581643321e9b693053b81b7b9a177e7
1 import os
2 from PyQt4 import QtCore
4 from cola.compat import set
5 from cola.decorators import memoize
8 debug = os.environ.get('COLA_NOTIFIER_DEBUG', False)
11 @memoize
12 def notifier():
13 return Notifier()
16 class Notifier(object):
17 """A pure-python re-implementation of QObject."""
18 def __init__(self):
19 self.channels = {}
21 def broadcast(self, signal, *args, **opts):
22 if debug:
23 print ('broadcast: %s(%s, %s)' % (name,
24 args or '<empty>',
25 kwargs or '<empty>'))
26 self.emit(signal, *args, **opts)
28 def emit(self, signal, *args, **opts):
29 subscribers = self.channels.get(signal, None)
30 if subscribers:
31 for fxn in subscribers:
32 fxn(*args, **opts)
34 def connect(self, signal, callback):
35 subscribers = self.channels.setdefault(signal, set())
36 subscribers.add(callback)