[core] Add input processing

Create infrastructure for input event handling and add i3bar event
processing. For each event, callbacks can be registered in the input
module.
Modules and widgets both identify themselves using a unique ID (the
module name for modules, a generated UUID for the widgets). This ID is
then used for registering the callbacks. This is possible since both
widgets and modules are statically allocated & do not change their IDs.

Callback actions can be either callable Python objects (in which case
the event is passed as parameter), or strings, in which case the string
is interpreted as a shell command.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-09 19:29:16 +01:00
parent fa30b9505b
commit e72c25b0bc
10 changed files with 274 additions and 19 deletions

View file

@ -6,8 +6,19 @@ def assertWidgetAttributes(test, widget):
test.assertTrue(isinstance(widget, Widget))
test.assertTrue(hasattr(widget, "full_text"))
class MockInput(object):
def start(self):
pass
def stop(self):
pass
def register_callback(self, obj, button, cmd):
pass
class MockEngine(object):
pass
def __init__(self):
self.input = MockInput()
class MockOutput(object):
def start(self):
@ -16,7 +27,7 @@ class MockOutput(object):
def stop(self):
pass
def draw(self, widget, engine):
def draw(self, widget, engine, module):
engine.stop()
def begin(self):
@ -28,12 +39,17 @@ class MockOutput(object):
def end(self):
pass
class MockModule(object):
def __init__(self, engine=None, config=None):
self.id = None
class MockWidget(Widget):
def __init__(self, text):
super(MockWidget, self).__init__(text)
self._text = text
self.module = None
self.attr_state = "state-default"
self.id = "none"
def state(self):
return self.attr_state