[gcompris/gcomprixogoo] Adapted the follow line to work on touch screen.
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Adapted the follow line to work on touch screen.
- Date: Sat, 9 Jan 2010 13:20:50 +0000 (UTC)
commit 791e0adf91cd460861c41f787f0368b545068d69
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Sat Jan 9 14:09:01 2010 +0100
Adapted the follow line to work on touch screen.
This was reported by Ronny Standtke.
Now not only the motion events are catched but also click events.
src/followline-activity/followline.py | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/followline-activity/followline.py b/src/followline-activity/followline.py
index b3bc7f1..8beca97 100644
--- a/src/followline-activity/followline.py
+++ b/src/followline-activity/followline.py
@@ -66,9 +66,10 @@ class Gcompris_followline:
gcompris.bar_set(gcompris.BAR_LEVEL)
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"followline/followline.svgz")
- self.background_item_connect_id = \
- self.gcomprisBoard.canvas.get_root_item().connect("motion_notify_event",
- self.loosing_item_event)
+ self.gcomprisBoard.canvas.get_root_item().connect("motion_notify_event",
+ self.loosing_item_motion)
+ self.gcomprisBoard.canvas.get_root_item().connect("button_press_event",
+ self.loosing_item_click)
gcompris.bar_set_level(self.gcomprisBoard)
@@ -81,8 +82,10 @@ class Gcompris_followline:
self.cleanup()
# Disconnect from the background item
- self.gcomprisBoard.canvas.get_root_item().disconnect(
- self.background_item_connect_id)
+ self.gcomprisBoard.canvas.get_root_item().disconnect_by_func(
+ self.loosing_item_motion)
+ self.gcomprisBoard.canvas.get_root_item().disconnect_by_func(
+ self.loosing_item_click)
gcompris.sound.policy_set(self.saved_policy)
@@ -194,6 +197,7 @@ class Gcompris_followline:
line_cap = cairo.LINE_CAP_ROUND
)
item.connect("enter_notify_event", self.line_item_event)
+ item.connect("button_press_event", self.line_item_event)
# Draw the black tube
if x > start_x and x < stop_x-step:
@@ -300,16 +304,21 @@ class Gcompris_followline:
return done
- def loosing_item_event(self, widget, target, event=None):
+ def loosing_item_click(self, widget, target, event=None):
if target.__class__ != goocanvas.Svg:
return False
+ self.lost()
- if event.type == gtk.gdk.BUTTON_PRESS:
+ def loosing_item_motion(self, widget, target, event=None):
+ if target.__class__ != goocanvas.Svg:
return False
+ self.loosing_count += 1
+ if(self.loosing_count % 10 == 0):
+ self.lost()
+
+ def lost(self):
if(self.state == "Started"):
- self.loosing_count += 1
- if(self.loosing_count % 10 == 0):
gcompris.sound.play_ogg("sounds/smudge.wav")
self.highlight_previous_line()
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]