[core/input] __ for private variables, use id as property
This commit is contained in:
parent
428b627daf
commit
95410e4adf
4 changed files with 11 additions and 13 deletions
|
@ -22,22 +22,19 @@ callbacks = {}
|
|||
class Object(object):
|
||||
def __init__(self):
|
||||
super(Object, self).__init__()
|
||||
self._id = str(uuid.uuid4())
|
||||
|
||||
def id(self):
|
||||
return self._id
|
||||
self.id = str(uuid.uuid4())
|
||||
|
||||
def register(obj, button=None, cmd=None):
|
||||
logging.debug('registering callback {} {}'.format(obj.id(), button))
|
||||
callbacks.setdefault(obj.id(), {}).setdefault(button, []).append(cmd)
|
||||
logging.debug('registering callback {} {}'.format(obj.id, button))
|
||||
callbacks.setdefault(obj.id, {}).setdefault(button, []).append(cmd)
|
||||
|
||||
def trigger(event):
|
||||
for field in ['instance', 'name']:
|
||||
if field in event:
|
||||
cb = callbacks.get(event[field])
|
||||
_invoke(event, cb)
|
||||
__invoke(event, cb)
|
||||
|
||||
def _invoke(event, callback):
|
||||
def __invoke(event, callback):
|
||||
if not callback: return
|
||||
if not 'button' in event: return
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ class i3(object):
|
|||
'border_left': self._theme.border_left(),
|
||||
'border_right': self._theme.border_right(),
|
||||
'border_bottom': self._theme.border_bottom(),
|
||||
'instance': widget.id(),
|
||||
'name': module.id(),
|
||||
'instance': widget.id,
|
||||
'name': module.id,
|
||||
}
|
||||
|
||||
def __separator(self, module, widget):
|
||||
|
@ -109,7 +109,7 @@ class i3(object):
|
|||
def update(self, affected_modules=None):
|
||||
now = time.time()
|
||||
for module in self._modules:
|
||||
if affected_modules and not module.id() in affected_modules:
|
||||
if affected_modules and not module.id in affected_modules:
|
||||
continue
|
||||
if not affected_modules and module.next_update:
|
||||
if now < module.next_update:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue