Commit 1870724b authored by Bruno Coudoin's avatar Bruno Coudoin

completed the removal of the OK button in the control bar

added an internal ok button in some activities

svn path=/branches/gcomprixogoo/; revision=3484
parent ac8175bb
......@@ -194,7 +194,7 @@ class Gcompris_anim:
self.gcomprisBoard.sublevel=0
self.gcomprisBoard.number_of_sublevel=0
gcompris.bar_set(255)
gcompris.bar_set(0)
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
gcompris.skin.image_to_skin("gcompris-bg.jpg"))
......
......@@ -78,9 +78,9 @@ class Gcompris_bargame:
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_reload.png"))
if(pixmap):
gcompris.bar_set_repeat_icon(pixmap)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT_ICON)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
else:
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT)
gcompris.bar_set_level(self.gcomprisBoard)
# Create persistent over levels root item canvas for the board
......@@ -124,7 +124,6 @@ class Gcompris_bargame:
def ok(self):
self.answer.has_focus()
self.play(self.answer.value,True)
pass
def key_press(self, keyval, commit_str, preedit_str):
return False
......@@ -234,24 +233,34 @@ class Gcompris_bargame:
self.holes.append(self.hole(self,
self.rootitem,
i * width_ref * scale,
gcompris.BOARD_HEIGHT - 120, i,
gcompris.BOARD_HEIGHT - 140, i,
self.board_size[self.gcomprisBoard.sublevel-1],
scale))
for i in range(self.number_balls[self.gcomprisBoard.sublevel-1][1]):
self.balls.append(self.ball(self.rootitem,
i * width_ref * scale + 150,
gcompris.BOARD_HEIGHT - 160,
gcompris.BOARD_HEIGHT - 180,
scale,
self.pixmap_blue_ball))
self.balls.append(self.ball(self.rootitem,
i * width_ref * scale +150,
gcompris.BOARD_HEIGHT-70,
gcompris.BOARD_HEIGHT-90,
scale,
self.pixmap_green_ball))
self.answer.set_number_of_balls(self.number_balls[self.gcomprisBoard.sublevel-1])
# The OK Button
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("ok.png"))
item = goocanvas.Image(parent = self.rootitem,
pixbuf = pixmap,
x = gcompris.BOARD_WIDTH - pixmap.get_width() - 10,
y = gcompris.BOARD_HEIGHT - 210
)
item.connect("button_press_event", self.ok_event)
gcompris.utils.item_focus_init(item, None)
def play(self, value, human):
for i in range(1,value+1):
......@@ -400,9 +409,9 @@ class Gcompris_bargame:
answer_bounds = self.background.get_bounds()
gcompris.utils.item_focus_init(self.background, None)
self.itemgroup.translate(gcompris.BOARD_WIDTH - 200,
self.itemgroup.translate(gcompris.BOARD_WIDTH - 180,
gcompris.BOARD_HEIGHT - answer_bounds.y2 \
- answer_bounds.y1 - 5)
- answer_bounds.y1 - 10)
self.background_focused = goocanvas.Image(
parent = self.itemgroup,
......@@ -477,7 +486,7 @@ class Gcompris_bargame:
self.prof_item = goocanvas.Image(
parent = root,
y = 230
y = 210
)
......@@ -502,3 +511,5 @@ class Gcompris_bargame:
return False
def ok_event(self, widget, target, event=None):
self.ok()
......@@ -1556,7 +1556,6 @@ void python_gcompris_module_init(void)
/* The GComprisBarFlags enum constants */
PyModule_AddIntConstant(gcomprisModule, "BAR_LEVEL", GC_BAR_LEVEL);
PyModule_AddIntConstant(gcomprisModule, "BAR_OK", GC_BAR_OK);
PyModule_AddIntConstant(gcomprisModule, "BAR_REPEAT", GC_BAR_REPEAT);
PyModule_AddIntConstant(gcomprisModule, "BAR_REPEAT_ICON", GC_BAR_REPEAT_ICON);
PyModule_AddIntConstant(gcomprisModule, "BAR_CONFIG", GC_BAR_CONFIG);
......
......@@ -61,7 +61,6 @@ static GooCanvasItem *bar_item = NULL;
static GooCanvasItem *exit_item = NULL;
static GooCanvasItem *home_item = NULL;
static GooCanvasItem *level_item = NULL;
static GooCanvasItem *ok_item = NULL;
static GooCanvasItem *help_item = NULL;
static GooCanvasItem *repeat_item = NULL;
static GooCanvasItem *config_item = NULL;
......@@ -145,18 +144,6 @@ void gc_bar_start (GooCanvas *theCanvas)
setup_item_signals(home_item, "back");
// OK
pixmap = gc_skin_pixmap_load("ok.png");
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
ok_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 5,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
setup_item_signals(ok_item, "ok");
// LEVEL
pixmap = gc_skin_pixmap_load("level1.png");
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
......@@ -228,9 +215,6 @@ void gc_bar_start (GooCanvas *theCanvas)
g_object_set (level_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
g_object_set (ok_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
g_object_set (repeat_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
......@@ -337,15 +321,6 @@ gc_bar_set (const GComprisBarFlags flags)
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
if(flags&GC_BAR_OK)
g_object_set (ok_item,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
NULL);
else
g_object_set (ok_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
if(gc_help_has_board(gc_board_get_current()))
g_object_set (help_item,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
......
......@@ -91,12 +91,11 @@ void gc_bar_set_repeat_icon (GdkPixbuf *pixmap);
typedef enum
{
GC_BAR_LEVEL = 1 << 0,
GC_BAR_OK = 1 << 1,
GC_BAR_REPEAT = 1 << 2,
GC_BAR_CONFIG = 1 << 3,
GC_BAR_ABOUT = 1 << 4,
GC_BAR_REPEAT_ICON = 1 << 5,
GC_BAR_QUIT = 1 << 6,
GC_BAR_REPEAT = 1 << 1,
GC_BAR_CONFIG = 1 << 2,
GC_BAR_ABOUT = 1 << 3,
GC_BAR_REPEAT_ICON = 1 << 4,
GC_BAR_QUIT = 1 << 5,
} GComprisBarFlags;
/* Difficulty filtering */
......
......@@ -83,7 +83,7 @@ class Gcompris_guessnumber:
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
gcompris.bar_set(gcompris.BAR_OK|gcompris.BAR_LEVEL)
gcompris.bar_set(gcompris.BAR_LEVEL)
gcompris.bar_set_level(self.gcomprisBoard)
......@@ -101,7 +101,7 @@ class Gcompris_guessnumber:
self.cleanup_game()
def ok(self):
print("Gcompris_guessnumber ok.")
pass
def repeat(self):
......@@ -217,7 +217,7 @@ class Gcompris_guessnumber:
fill_color_rgba=0xff0006ffL,
)
self.entry_text()
text_item = self.entry_text()
#
# Display the helico
......@@ -235,6 +235,16 @@ class Gcompris_guessnumber:
y = self.y,
)
# The OK Button
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("ok.png"))
item = goocanvas.Image(parent = self.rootitem,
pixbuf = pixmap,
x = gcompris.BOARD_WIDTH - pixmap.get_width() - 30,
y = 65
)
item.connect("button_press_event", self.ok_event, text_item)
gcompris.utils.item_focus_init(item, None)
def entry_text(self):
self.entry = gtk.Entry()
......@@ -266,6 +276,8 @@ class Gcompris_guessnumber:
#self.widget.grab_focus()
#self.entry.grab_focus()
return self.entry
def enter_char_callback(self, widget):
text = widget.get_text()
widget.set_text(text.decode('utf8').upper().encode('utf8'))
......@@ -358,3 +370,6 @@ class Gcompris_guessnumber:
# it takes self.num_moveticks iterations of duration self.move_tick to move squares
self.movestep_timer = gobject.timeout_add(self.move_tick, self.move_step)
def ok_event(self, widget, target, event, data):
self.enter_callback(data)
......@@ -41,7 +41,7 @@ class Gcompris_pythontemplate:
print "template start"
# Set the buttons we want in the bar
gcompris.bar_set(gcompris.BAR_OK)
gcompris.bar_set(gcompris.BAR_LEVEL)
# Set a background image
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
......
......@@ -99,7 +99,7 @@ class Gcompris_redraw:
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
gcompris.bar_set(gcompris.BAR_OK|gcompris.BAR_LEVEL)
gcompris.bar_set(gcompris.BAR_LEVEL)
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
gcompris.skin.image_to_skin("gcompris-bg.jpg"))
gcompris.bar_set_level(self.gcomprisBoard)
......@@ -377,6 +377,18 @@ class Gcompris_redraw:
self.old_tool_item.props.pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin(self.tools[i][2]))
gcompris.set_cursor(self.tools[i][3]);
# The OK Button
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("ok.png"))
item = goocanvas.Image(parent = self.rootitem,
pixbuf = pixmap,
x = 20,
y = gcompris.BOARD_HEIGHT - 100
)
item.connect("button_press_event", self.ok_event)
gcompris.utils.item_focus_init(item, None)
gcompris.bar_set_level(self.gcomprisBoard)
# Event when a tool is selected
def tool_item_event(self, item, target, event, tool):
......@@ -1523,3 +1535,5 @@ class Gcompris_redraw:
self.gcomprisBoard.number_of_sublevel=math.ceil(len(self.drawlist)/9.0)
self.gcomprisBoard.maxlevel=min(9, math.ceil(float(len(self.drawlist))/self.gcomprisBoard.number_of_sublevel))
def ok_event(self, widget, target, event=None):
self.ok()
......@@ -133,11 +133,21 @@ class Gcompris_searace:
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_reload.png"))
if(pixmap):
gcompris.bar_set_repeat_icon(pixmap)
gcompris.bar_set(gcompris.BAR_OK|gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
else:
gcompris.bar_set(gcompris.BAR_OK|gcompris.BAR_LEVEL|gcompris.BAR_REPEAT);
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT);
# The OK Button
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("ok.png"))
item = goocanvas.Image(parent = self.rootitem,
pixbuf = pixmap,
x = gcompris.BOARD_WIDTH - pixmap.get_width() - 20,
y = gcompris.BOARD_HEIGHT - pixmap.get_height() - 5
)
item.connect("button_press_event", self.ok_event)
gcompris.utils.item_focus_init(item, None)
gcompris.bar_set_level(self.gcomprisBoard)
......@@ -395,7 +405,7 @@ class Gcompris_searace:
self.left_boat.sw.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
w = 250.0
h = 90.0
h = 100.0
y = 350.0 # The upper limit of the text boxes
x_left = gcompris.BOARD_WIDTH/4 - 30
x_right = (gcompris.BOARD_WIDTH/4)*3 + 30
......@@ -1005,3 +1015,5 @@ class Gcompris_searace:
return True
return False
def ok_event(self, widget, target, event=None):
self.ok()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment