From d6dd98b04dea43bb58ca44e212f0e082237bce41 Mon Sep 17 00:00:00 2001 From: Ignacio Rodríguez Date: Fri, 06 Dec 2013 15:10:14 +0000 Subject: Enable game key support --- diff --git a/activity.py b/activity.py index 6660fa7..ce99523 100644 --- a/activity.py +++ b/activity.py @@ -92,7 +92,7 @@ class StopWatchActivity(Activity): self.tubebox = dobject.TubeBox() self.timer = dobject.TimeHandler("main", self.tubebox) - self.gui = stopwatch.GUIView(self.tubebox, self.timer) + self.gui = stopwatch.GUIView(self.tubebox, self.timer, self) self.set_canvas(self.gui.display) self.show_all() diff --git a/stopwatch.py b/stopwatch.py index ddb4c3c..6d4971e 100644 --- a/stopwatch.py +++ b/stopwatch.py @@ -145,7 +145,7 @@ class WatchModel(): thread.start_new_thread(self._view_listener, (self._state,)) class OneWatchView(): - def __init__(self, mywatch, myname, mymarks, timer): + def __init__(self, mywatch, myname, mymarks, timer, activity): self._logger = logging.getLogger('stopwatch.OneWatchView') self._watch_model = mywatch self._name_model = myname @@ -245,7 +245,7 @@ class OneWatchView(): self.display.connect('focus-in-event', self._got_focus_cb) self.display.connect('focus-out-event', self._lost_focus_cb) self.display.add_events(gtk.gdk.ALL_EVENTS_MASK) - self.display.connect('key-press-event', self._keypress_cb) + activity.connect('key-press-event', self._keypress_cb) #self.display.connect('key-release-event', self._keyrelease_cb) self._watch_model.register_view_listener(self.update_state) @@ -407,7 +407,7 @@ class OneWatchView(): class GUIView(): NUM_WATCHES = 9 - def __init__(self, tubebox, timer): + def __init__(self, tubebox, timer, activity): self.timer = timer self._views = [] self._names = [] @@ -423,7 +423,7 @@ class GUIView(): marks_handler = dobject.UnorderedHandler("marks"+str(i), tubebox) marks_model = dobject.AddOnlySet(marks_handler, translator = dobject.float_translator) self._markers.append(marks_model) - watch_view = OneWatchView(watch_model, name_model, marks_model, timer) + watch_view = OneWatchView(watch_model, name_model, marks_model, timer, activity) self._views.append(watch_view) self.display = gtk.VBox() -- cgit v0.9.1