Commit fce9ab37 authored by Bruno Coudoin's avatar Bruno Coudoin

port to goocanvas goes on

svn path=/branches/gcomprixogoo/; revision=3177
parent a93b56f7
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
path=$1 path=$1
activity=clickanddraw activity=clickanddraw
plugindir=$path/../boards/.libs plugindir=$path/../boards/.libs
pythonplugindir=$path./drawnumber-activity pythonplugindir=$path/../drawnumber-activity
resourcedir=$path/../drawnumber-activity/resources resourcedir=$path/../drawnumber-activity/resources
section="/computer/mouse" section="/computer/mouse"
...@@ -32,6 +32,7 @@ import gcompris.bonus ...@@ -32,6 +32,7 @@ import gcompris.bonus
import gcompris.anim import gcompris.anim
import gtk import gtk
import gtk.gdk import gtk.gdk
import cairo
from gettext import gettext as _ from gettext import gettext as _
from connect4p import rules from connect4p import rules
...@@ -88,7 +89,8 @@ class Gcompris_connect4: ...@@ -88,7 +89,8 @@ class Gcompris_connect4:
x=0.0, x=0.0,
y=0.0 y=0.0
) )
selector.connect("event", self.columnItemEvent, 0) selector.connect("motion_notify_event", self.columnItemEvent, 0)
selector.connect("button_press_event", self.columnItemEvent, 0)
if self.mode == 1: if self.mode == 1:
self.prof = \ self.prof = \
...@@ -98,8 +100,8 @@ class Gcompris_connect4: ...@@ -98,8 +100,8 @@ class Gcompris_connect4:
x=10, x=10,
y=350.0 y=350.0
) )
self.prof.connect("event", self.profItemEvent, 0) self.prof.connect("button_press_event", self.profItemEvent, 0)
self.prof.connect("event", gcompris.utils.item_event_focus) self.prof.connect("enter_notify_event", gcompris.utils.item_event_focus)
self.timericon = gcompris.anim.CanvasItem( gcompris.anim.Animation("connect4/sablier.txt"), self.timericon = gcompris.anim.CanvasItem( gcompris.anim.Animation("connect4/sablier.txt"),
self.rootitem ) self.rootitem )
...@@ -116,11 +118,11 @@ class Gcompris_connect4: ...@@ -116,11 +118,11 @@ class Gcompris_connect4:
self.score_item = \ self.score_item = \
goocanvas.Text( goocanvas.Text(
parent = self.rootitem, parent = self.rootitem,
font=gcompris.skin.get_font("gcompris/board/huge bold"), font=gcompris.skin.get_font("gcompris/board/huge bold"),
x=60, x=60,
y=250, y=250,
justification=gtk.JUSTIFY_CENTER, anchor = gtk.ANCHOR_CENTER,
fill_color_rgba=0xFF0000FFL) fill_color_rgba=0xFF0000FFL)
self.update_scores((0, 0)) self.update_scores((0, 0))
...@@ -158,7 +160,7 @@ class Gcompris_connect4: ...@@ -158,7 +160,7 @@ class Gcompris_connect4:
def update_scores(self, scores=None): def update_scores(self, scores=None):
if scores: self.scores = list(scores) if scores: self.scores = list(scores)
txt = str(self.scores[0]) + "\n\n" + str(self.scores[1]) txt = str(self.scores[0]) + "\n\n" + str(self.scores[1])
self.score_item.set(text=txt) self.score_item.props.text = txt
def stone_init(self): def stone_init(self):
if self.player_stone: if self.player_stone:
...@@ -217,10 +219,10 @@ class Gcompris_connect4: ...@@ -217,10 +219,10 @@ class Gcompris_connect4:
self.boardItem.remove() self.boardItem.remove()
self.boardItem = \ self.boardItem = \
goocanvas.Group( goocanvas.Group(
parent = self.gcomprisBoard.canvas.get_root_item(), parent = self.gcomprisBoard.canvas.get_root_item()
x=(gcompris.BOARD_WIDTH-self.boardSize)/2.0, )
y=50.0 self.boardItem.translate((gcompris.BOARD_WIDTH-self.boardSize)/2.0,
) 50.0)
self.player1 = human.Human(self.gcomprisBoard.level) self.player1 = human.Human(self.gcomprisBoard.level)
if self.mode == 1: if self.mode == 1:
self.player2 = minmax.MinMax(self.gcomprisBoard.level, self.refreshScreen) self.player2 = minmax.MinMax(self.gcomprisBoard.level, self.refreshScreen)
...@@ -240,25 +242,27 @@ class Gcompris_connect4: ...@@ -240,25 +242,27 @@ class Gcompris_connect4:
if self.mode == 1: if self.mode == 1:
self.prof.props.visibility = goocanvas.ITEM_VISIBLE self.prof.props.visibility = goocanvas.ITEM_VISIBLE
def columnItemEvent(self, widget, event, columns): def columnItemEvent(self, widget, target, event, columns):
(x, y)= self.gcomprisBoard.canvas.\
convert_from_item_space(widget, event.x, event.y)
if self.mode == 1 and self.cur_player == 2: # AI playing if self.mode == 1 and self.cur_player == 2: # AI playing
return False return False
if self.cur_player == 0 or self.timerAnim: # Game over or Timer animate if self.cur_player == 0 or self.timerAnim: # Game over or Timer animate
return False return False
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
column = int((event.x - (gcompris.BOARD_WIDTH-self.boardSize)/2.0) // self.stoneSize) column = int((x - (gcompris.BOARD_WIDTH-self.boardSize)/2.0) // self.stoneSize)
if 0 <= column < self.nbColumns: if 0 <= column < self.nbColumns:
if self.play(self.player1, self.cur_player, column): if self.play(self.player1, self.cur_player, column):
self.timericon.goocanvas.props.visibility = goocanvas.ITEM_VISIBLE self.timericon.goocanvas.props.visibility = goocanvas.ITEM_VISIBLE
self.player_stone.props.visibility = goocanvas.ITEM_INVISIBLE self.player_stone.props.visibility = goocanvas.ITEM_INVISIBLE
elif event.type == gtk.gdk.MOTION_NOTIFY: elif event.type == gtk.gdk.MOTION_NOTIFY:
column = int((event.x - (gcompris.BOARD_WIDTH-self.boardSize)/2.0) // self.stoneSize) column = int((x - (gcompris.BOARD_WIDTH-self.boardSize)/2.0) // self.stoneSize)
if 0 <= column < self.nbColumns: if 0 <= column < self.nbColumns:
self.keyb_column = column self.keyb_column = column
self.update_stone2() self.update_stone2()
return False return False
def profItemEvent(self, widget, event, column): def profItemEvent(self, widget, target, event, column):
if event.type == gtk.gdk.BUTTON_PRESS: if event.type == gtk.gdk.BUTTON_PRESS:
self.cur_player=1 self.cur_player=1
self.prof.props.visibility = goocanvas.ITEM_INVISIBLE self.prof.props.visibility = goocanvas.ITEM_INVISIBLE
...@@ -308,7 +312,8 @@ class Gcompris_connect4: ...@@ -308,7 +312,8 @@ class Gcompris_connect4:
x=x*(self.boardSize/self.nbColumns), x=x*(self.boardSize/self.nbColumns),
y=0 y=0
) )
self.stone.connect("event", self.columnItemEvent, 0) self.stone.connect("button_press_event", self.columnItemEvent, 0)
self.stone.connect("motion_notify_event", self.columnItemEvent, 0)
self.countAnim = self.nbLines-y self.countAnim = self.nbLines-y
self.timerAnim = gobject.timeout_add(200, self.animTimer) self.timerAnim = gobject.timeout_add(200, self.animTimer)
self.timericon.goocanvas.props.visibility = goocanvas.ITEM_VISIBLE self.timericon.goocanvas.props.visibility = goocanvas.ITEM_VISIBLE
...@@ -343,20 +348,20 @@ class Gcompris_connect4: ...@@ -343,20 +348,20 @@ class Gcompris_connect4:
self.scores[player-1] += 1 self.scores[player-1] += 1
self.update_scores() self.update_scores()
points = ( self.winLine[0][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2, points = goocanvas.Points([(self.winLine[0][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2,
(self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[0][1])+self.stoneSize/2, (self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[0][1])+self.stoneSize/2),
self.winLine[1][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2, (self.winLine[1][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2,
(self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[1][1])+self.stoneSize/2 (self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[1][1])+self.stoneSize/2)
) ])
self.redLine = \ self.redLine = \
goocanvas.Polyline( goocanvas.Polyline(
parent = self.boardItem, parent = self.boardItem,
fill_color_rgba=0xFF0000FFL, stroke_color_rgba=0xFF0000FFL,
points=points, points = points,
width_pixels = 8 line_width = 8,
line_cap = cairo.LINE_CAP_ROUND
) )
self.redLine.set_property("cap-style", gtk.gdk.CAP_ROUND)
if player == 1: if player == 1:
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER) gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER)
elif player == 2: elif player == 2:
......
...@@ -27,11 +27,12 @@ import gcompris.score ...@@ -27,11 +27,12 @@ import gcompris.score
import gtk import gtk
import gtk.gdk import gtk.gdk
import gobject import gobject
import cairo
from drawnumber import Gcompris_drawnumber from drawnumber import Gcompris_drawnumber
class Gcompris_clickanddraw(Gcompris_drawnumber) : class Gcompris_clickanddraw(Gcompris_drawnumber):
def set_sublevel(self,sublevel=1): def set_sublevel(self, sublevel=1):
"""Start of the game at sublevel number sublevel of level n""" """Start of the game at sublevel number sublevel of level n"""
if self.MAX!=0 : if self.MAX!=0 :
...@@ -44,7 +45,8 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) : ...@@ -44,7 +45,8 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) :
) )
#Setting of the first background image of the level #Setting of the first background image of the level
gcompris.set_background(self.ROOT,self.data[sublevel][0][1]) gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
self.data[sublevel][0][1])
#Initialisation of sub-elements in list #Initialisation of sub-elements in list
self.POINT=[0] self.POINT=[0]
...@@ -64,6 +66,7 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) : ...@@ -64,6 +66,7 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) :
#Data loading from global data and display of points and numbers #Data loading from global data and display of points and numbers
i=self.MAX i=self.MAX
prev_point = None
while(i>0): while(i>0):
if self.gcomprisBoard.level==1 : if self.gcomprisBoard.level==1 :
self.POINT.append(self.point(idpt=(self.MAX-i+1), self.POINT.append(self.point(idpt=(self.MAX-i+1),
...@@ -78,29 +81,33 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) : ...@@ -78,29 +81,33 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) :
x=self.data[sublevel][i][0], x=self.data[sublevel][i][0],
y=self.data[sublevel][i][1],d=20)) y=self.data[sublevel][i][1],d=20))
self.POINT[(self.MAX-i+1)].connect('event',self.action,(self.MAX-i+1)) self.POINT[(self.MAX-i+1)].connect('button_press_event',
self.action,(self.MAX-i+1))
#Setting of display level to prevent from covert a point with another #Setting of display level to prevent covering a point with another
#point which cause an impossibility to select it. #point which cause an impossibility to select it.
self.POINT[(self.MAX-i+1)].lower(300-(self.MAX-i+1)) if prev_point:
i=i-1 self.POINT[(self.MAX-i+1)].lower(prev_point)
prev_point = self.POINT[(self.MAX-i+1)]
i = i-1
#Setting color of the first point to blue instead of green #Setting color of the first point to blue instead of green
self.POINT[1].set(fill_color='blue') self.POINT[1].set_properties(fill_color_rgba = 0x003DF5D0)
def action(self,objet,truc,idpt): def action(self, objet, target, truc, idpt):
"""Action to do at each step during normal execution of the game""" """Action to do at each step during normal execution of the game"""
if truc.type == gtk.gdk.BUTTON_PRESS : if truc.type == gtk.gdk.BUTTON_PRESS :
if idpt == (self.actu+1): #Action to execute if the selected point is the following of previous one if idpt == (self.actu+1): #Action to execute if the selected point is the following of previous one
xd,yd,xa,ya = self.POINT[(idpt-1)].x, self.POINT[(idpt-1)].y, self.POINT[idpt].x, self.POINT[idpt].y xd,yd,xa,ya = self.POINT[(idpt-1)].x, self.POINT[(idpt-1)].y, self.POINT[idpt].x, self.POINT[idpt].y
goocanvas.Polyline( goocanvas.Polyline(
parent = self.ROOT, parent = self.ROOT,
points=(xd,yd,xa,ya), points = goocanvas.Points([(xd,yd), (xa,ya)]),
fill_color='black', fill_color = 'black',
line_width=2) line_cap = cairo.LINE_CAP_ROUND,
line_width = 2)
if idpt == 2: # Always raise the first point if idpt == 2: # Always raise the first point
self.POINT[self.MAX].raise_to_top() self.POINT[self.MAX].raise_(None)
objet.props.visibility = goocanvas.ITEM_INVISIBLE objet.props.visibility = goocanvas.ITEM_INVISIBLE
if idpt==self.MAX : #Action to exectute if all points have been selected in good way if idpt==self.MAX : #Action to exectute if all points have been selected in good way
...@@ -109,6 +116,7 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) : ...@@ -109,6 +116,7 @@ class Gcompris_clickanddraw(Gcompris_drawnumber) :
self.gamewon = 1 self.gamewon = 1
self.timeout = gobject.timeout_add(1500, self.lauch_bonus) # The level is complete -> Bonus display self.timeout = gobject.timeout_add(1500, self.lauch_bonus) # The level is complete -> Bonus display
else : #Action to execute if the selected point isn't the last one of this level else : # Action to execute if the selected point isn't the last one of this level
self.POINT[(idpt+1)].set(fill_color='blue') #Set color in blue to next point. Too easy ??? # Set color in blue to next point. Too easy ???
self.POINT[(idpt+1)].set_properties(fill_color_rgba=0x003DF5D0)
self.actu = self.actu+1 #self.actu update to set it at actual value of selected point self.actu = self.actu+1 #self.actu update to set it at actual value of selected point
...@@ -24,9 +24,11 @@ import gcompris ...@@ -24,9 +24,11 @@ import gcompris
import gcompris.utils import gcompris.utils
import gcompris.bonus import gcompris.bonus
import gcompris.score import gcompris.score
import gcompris.skin
import gtk import gtk
import gtk.gdk import gtk.gdk
import gobject import gobject
import cairo
class Gcompris_drawnumber : class Gcompris_drawnumber :
...@@ -126,23 +128,29 @@ class Gcompris_drawnumber : ...@@ -126,23 +128,29 @@ class Gcompris_drawnumber :
#Data loading from global data and display of points and numbers #Data loading from global data and display of points and numbers
i=1 i=1
while(i<=(self.MAX)): prev_text = None
prev_point = None
while(i <= self.MAX):
self.POINT.append(self.point(i,self.data[sublevel][i][0],
self.data[sublevel][i][1],30))
self.POINT[i].connect('button_press_event', self.action, i)
self.TEXT.append(self.text(i, self.TEXT.append(self.text(i,
self.data[sublevel][i][0], self.data[sublevel][i][0],
self.data[sublevel][i][1])) self.data[sublevel][i][1]))
self.TEXT[i].connect('event', self.action, i) self.TEXT[i].connect('button_press_event', self.action, i)
self.TEXT[i].lower(300-i)
self.POINT.append(self.point(i,self.data[sublevel][i][0], # Setting of display level to prevent covering a point with another point which
self.data[sublevel][i][1],30)) # cause an impossibility to select it.
self.POINT[i].connect('event', self.action, i) self.TEXT[i].lower(prev_point)
prev_text = self.TEXT[i]
self.POINT[i].lower(prev_text)
prev_point = self.POINT[i]
#Setting of display level to prevent from covert a point with another point which
#cause an impossibility to select it.
self.POINT[i].lower(300-i)
i=i+1 i=i+1
#Setting color of the first point to blue instead of green #Setting color of the first point to blue instead of green
self.POINT[1].set(fill_color='blue') self.POINT[1].set_properties(fill_color_rgba=0x003DF5D0)
def point(self, idpt, x, y, d=30): def point(self, idpt, x, y, d=30):
"""Setting point from his x and y location""" """Setting point from his x and y location"""
...@@ -152,7 +160,7 @@ class Gcompris_drawnumber : ...@@ -152,7 +160,7 @@ class Gcompris_drawnumber :
center_y = y, center_y = y,
radius_x = d/2, radius_x = d/2,
radius_y = d/2, radius_y = d/2,
fill_color = "green", # default color is green and outline in black fill_color_rgba = 0x3DF500D0, # default color is green and outline in black
stroke_color = "black", stroke_color = "black",
line_width = 1.5 line_width = 1.5
) )
...@@ -163,31 +171,33 @@ class Gcompris_drawnumber : ...@@ -163,31 +171,33 @@ class Gcompris_drawnumber :
"""Setting text beside the point number idpt locate as xt, yt""" """Setting text beside the point number idpt locate as xt, yt"""
labell = goocanvas.Text( labell = goocanvas.Text(
parent = self.ROOT, parent = self.ROOT,
x=xt, x = xt,
y=yt, y = yt,
fill_color="black", fill_color = "black",
size_points=14, font = gcompris.skin.get_font("gcompris/board/big bold"),
text=str(idpt)) # ,font=gcompris.FONT_TITLE) anchor = gtk.ANCHOR_CENTER,
text = str(idpt))
return labell return labell
def lauch_bonus(self): def lauch_bonus(self):
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.RANDOM) gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.RANDOM)
def action(self,objet,truc,idpt): def action(self, objet, target, truc, idpt):
"""Action to do at each step during normal execution of the game""" """Action to do at each step during normal execution of the game"""
if truc.type == gtk.gdk.BUTTON_PRESS : if truc.type == gtk.gdk.BUTTON_PRESS :
if idpt == (self.actu+1): #Action to execute if the selected point is the following of previous one if idpt == (self.actu+1): #Action to execute if the selected point is the following of previous one
xd,yd,xa,ya=self.POINT[(idpt-1)].x,self.POINT[(idpt-1)].y,self.POINT[idpt].x,self.POINT[idpt].y xd,yd,xa,ya = self.POINT[(idpt-1)].x,self.POINT[(idpt-1)].y,self.POINT[idpt].x,self.POINT[idpt].y
item = goocanvas.Polyline( item = goocanvas.Polyline(
parent = self.ROOT, parent = self.ROOT,
points=(xd,yd,xa,ya), points = goocanvas.Points([(xd,yd),(xa,ya)]),
fill_color='black', stroke_color = 'black',
line_width=1.5) line_cap = cairo.LINE_CAP_ROUND,
line_width = 1.5)
if idpt == 2: # Always raise the first point if idpt == 2: # Always raise the first point
self.POINT[self.MAX].raise_to_top() self.POINT[self.MAX].raise_(None)
self.TEXT[self.MAX].raise_to_top() self.TEXT[self.MAX].raise_(None)
self.POINT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE self.POINT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE
self.TEXT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE self.TEXT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE
...@@ -197,7 +207,8 @@ class Gcompris_drawnumber : ...@@ -197,7 +207,8 @@ class Gcompris_drawnumber :
self.timeout = gobject.timeout_add(1500, self.lauch_bonus) # The level is complete -> Bonus display self.timeout = gobject.timeout_add(1500, self.lauch_bonus) # The level is complete -> Bonus display
else : #Action to execute if the selected point isn't the last one of this level else : #Action to execute if the selected point isn't the last one of this level
#self.POINT[(idpt+1)].set(fill_color='blue') #Set color in blue to next point. Too easy ??? #Set color in blue to next point. Too easy ???
#self.POINT[(idpt+1)].set_properties(fill_color_rgba=0x003DF5F0)
self.actu=self.actu+1 #self.actu update to set it at actual value of selected point self.actu=self.actu+1 #self.actu update to set it at actual value of selected point
def ok(self): def ok(self):
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# Follow Line Board module # Follow Line Board module
import gobject import gobject
import goocanvas import goocanvas
import cairo
import gcompris import gcompris
import gcompris.skin import gcompris.skin
import gcompris.bonus import gcompris.bonus
...@@ -188,9 +189,10 @@ class Gcompris_followline: ...@@ -188,9 +189,10 @@ class Gcompris_followline:
item = goocanvas.Polyline( item = goocanvas.Polyline(
parent = self.lines_group, parent = self.lines_group,
points = goocanvas.Points([(x, y), (x + step + 4, y2)]), points = goocanvas.Points([(x, y), (x + step, y2)]),
stroke_color_rgba = self.color_empty, stroke_color_rgba = self.color_empty,
line_width = line_width, line_width = line_width,
line_cap = cairo.LINE_CAP_ROUND
) )
item.connect("enter_notify_event", self.line_item_event) item.connect("enter_notify_event", self.line_item_event)
...@@ -202,18 +204,8 @@ class Gcompris_followline: ...@@ -202,18 +204,8 @@ class Gcompris_followline:
(x + step, y2)]), (x + step, y2)]),
fill_color_rgba = self.color_border, fill_color_rgba = self.color_border,
line_width = line_width + 20, line_width = line_width + 20,
line_cap = cairo.LINE_CAP_ROUND
) )
# Make the outline smooth
goocanvas.Ellipse(
parent = self.rootitem,
center_x = x + step,
center_y = y2,
radius_x = (line_width + 20) / 2,
radius_y = (line_width + 20) / 2,
fill_color_rgba = self.color_border,
line_width = 0,
)
y = y2 y = y2
self.highlight_next_line() self.highlight_next_line()
......
# gcompris - searace # gcompris - searace
# #
# Time-stamp: <2001/08/20 00:54:45 bruno>
#
# Copyright (C) 2004 Bruno Coudoin # Copyright (C) 2004 Bruno Coudoin
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -130,6 +128,8 @@ class Gcompris_searace: ...@@ -130,6 +128,8 @@ class Gcompris_searace:
y=0, y=0,
) )
item.connect("button_press_event", self.ruler_item_event) item.connect("button_press_event", self.ruler_item_event)
item.connect("button_release_event", self.ruler_item_event)
item.connect("motion_notify_event", self.ruler_item_event)
self.display_sea_area() self.display_sea_area()
...@@ -179,7 +179,7 @@ class Gcompris_searace: ...@@ -179,7 +179,7 @@ class Gcompris_searace:
self.race_one_command(self.left_boat) self.race_one_command(self.left_boat)
self.race_one_command(self.right_boat) self.race_one_command(self.right_boat)
else: else:
self.statusitem.set(text=_("The race is already being run")) self.statusitem.props.text = _("The race is already being run")
# Called by gcompris when the user click on the level icon # Called by gcompris when the user click on the level icon
def set_level(self, level): def set_level(self, level):
...@@ -256,10 +256,11 @@ class Gcompris_searace: ...@@ -256,10 +256,11 @@ class Gcompris_searace:
pixbuf = pixmap, pixbuf = pixmap,
x=self.left_boat.x, x=self.left_boat.x,
y=self.left_boat.y, y=self.left_boat.y,
anchor=gtk.ANCHOR_CENTER,
) )
self.left_boat.item.raise_(None) self.left_boat.item.raise_(None)
self.left_boat.item.connect("button_press_event", self.ruler_item_event) self.left_boat.item.connect("button_press_event", self.ruler_item_event)
self.left_boat.item.connect("button_release_event", self.ruler_item_event)
self.left_boat.item.connect("motion_notify_event", self.ruler_item_event)
if(self.right_boat.item): if(self.right_boat.item):
self.right_boat.item.remove() self.right_boat.item.remove()
...@@ -270,10 +271,11 @@ class Gcompris_searace: ...@@ -270,10 +271,11 @@ class Gcompris_searace:
pixbuf = pixmap, pixbuf = pixmap,
x=self.right_boat.x, x=self.right_boat.x,
y=self.right_boat.y, y=self.right_boat.y,
anchor=gtk.ANCHOR_CENTER,
) )
self.right_boat.item.raise_(None) self.right_boat.item.raise_(None)
self.right_boat.item.connect("button_press_event", self.ruler_item_event) self.right_boat.item.connect("button_press_event", self.ruler_item_event)
self.right_boat.item.connect("button_release_event", self.ruler_item_event)
self.right_boat.item.connect("motion_notify_event", self.ruler_item_event)
# Reset command line processing as well. # Reset command line processing as well.
...@@ -283,7 +285,9 @@ class Gcompris_searace: ...@@ -283,7 +285,9 @@ class Gcompris_searace:
self.right_boat.arrived = False self.right_boat.arrived = False
self.left_boat.won = False self.left_boat.won = False
self.right_boat.won = False self.right_boat.won = False
self.statusitem.set(text="") self.left_boat.speeditem.props.text = ""
self.right_boat.speeditem.props.text = ""
self.statusitem.props.text = ""
# Let the user enter comands # Let the user enter comands
self.left_boat.tv.set_editable(True) self.left_boat.tv.set_editable(True)
...@@ -319,17 +323,6 @@ class Gcompris_searace: ...@@ -319,17 +323,6 @@ class Gcompris_searace:
color = cb color = cb
ci += 1 ci += 1
# Shadow for text number
item = goocanvas.Text(
parent = self.rootitem,
text=int(ci),
font=gcompris.skin.get_font("gcompris/content"),
x=text_x+1,
y=y+1,
fill_color_rgba=0x000000FFL
)
item.connect("button_press_event", self.ruler_item_event)
# Text number # Text number
item = goocanvas.Text( item = goocanvas.Text(
parent = self.rootitem, parent = self.rootitem,
...@@ -337,18 +330,23 @@ class Gcompris_searace: ...@@ -337,18 +330,23 @@ class Gcompris_searace:
font=gcompris.skin.get_font("gcompris/content"), font=gcompris.skin.get_font("gcompris/content"),
x=text_x, x=text_x,
y=y, y=y,
fill_color_rgba=cb fill_color_rgba=cb,
anchor = gtk.ANCHOR_CENTER
) )
item.connect("button_press_event", self.ruler_item_event) item.connect("button_press_event", self.ruler_item_event)
item.connect("button_release_event", self.ruler_item_event)
item.connect("motion_notify_event", self.ruler_item_event)
item = goocanvas.Polyline( item = goocanvas.Polyline(
parent = self.rootitem, parent = self.rootitem,
points = goocanvas.Points([(self.sea_area[0], y), points = goocanvas.Points([(self.sea_area[0], y),
(self.sea_area[2], y)]), (self.sea_area[2], y)]),
fill_color_rgba = color, stroke_color_rgba = color,
line_width = 1.0 line_width = 1.0
) )
item.connect("button_press_event", self.ruler_item_event) item.connect("button_press_event", self.ruler_item_event)
item.connect("button_release_event", self.ruler_item_event)
item.connect("motion_notify_event", self.ruler_item_event)
ci = 0 ci = 0
...@@ -359,17 +357,6 @@ class Gcompris_searace: ...@@ -359,17 +357,6 @@ class Gcompris_searace:
color = cb color = cb
ci += 1 ci += 1
# Shadow for text number
item = goocanvas.Text(
parent = self.rootitem,
text=int(ci),