Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Moleri <pmoleri@pmoleri-laptop.(none)>2010-05-09 23:47:25 (GMT)
committer Pablo Moleri <pmoleri@pmoleri-laptop.(none)>2010-05-09 23:47:25 (GMT)
commit9379b317e95455db07fa91697d7407e57cb1d195 (patch)
tree1465aa0ca98810b0c81c1c499da07db249825d4c
parent9bad1637df73e51b658c1452b1bbca90a88c26a1 (diff)
New accessibility toolbar added. Card is highlighted with stronger colors.HEADmaster
-rw-r--r--accessibilitytoolbar.py78
-rw-r--r--activity.py15
-rw-r--r--cardtable.py27
-rw-r--r--memorizetoolbar.py9
-rw-r--r--po/es.po7
-rw-r--r--svgcard.py5
6 files changed, 112 insertions, 29 deletions
diff --git a/accessibilitytoolbar.py b/accessibilitytoolbar.py
new file mode 100644
index 0000000..96d54f9
--- /dev/null
+++ b/accessibilitytoolbar.py
@@ -0,0 +1,78 @@
+# Copyright (C) 2010 ceibalJAM! ceibaljam.org
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import gtk
+from os.path import join, dirname
+
+from gettext import gettext as _
+
+from sugar import profile
+
+import logging
+from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT
+
+_logger = logging.getLogger('memorize-activity')
+
+class AccessibilityToolbar(gtk.Toolbar):
+ __gtype_name__ = 'AccessibilityToolbar'
+
+ __gsignals__ = {
+ 'accessibility_changed': (SIGNAL_RUN_FIRST, None, 2 * [TYPE_PYOBJECT]),
+ }
+
+ def __init__(self, activity):
+ gtk.Toolbar.__init__(self)
+ self.activity = activity
+ self._lock = True
+ self.jobject = None
+
+ # Accessible mode checkbox
+ self._accessible = gtk.CheckButton(_('Accessible'))
+ self._accessible.connect('toggled', self._accessibility_changed)
+ self._add_widget(self._accessible)
+
+ # Scanning speed scale
+ min = 1
+ max = 5
+ step = 1
+ default = 2.5
+
+ self._speed_adj = gtk.Adjustment(default, min, max, step)
+ self._speed_bar = gtk.HScale(self._speed_adj)
+ self._speed_bar.set_draw_value(True)
+ self._speed_bar.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
+ self._speed_bar.set_size_request(240,15)
+ self._speed_adj.connect("value_changed", self._accessibility_changed)
+
+ # Add it to the toolbar
+ self._add_widget(self._speed_bar)
+
+ def _add_widget(self, widget, expand=False):
+ tool_item = gtk.ToolItem()
+ tool_item.set_expand(expand)
+ tool_item.add(widget)
+ widget.show()
+ self.insert(tool_item, -1)
+ tool_item.show()
+
+ def _game_reset_cb(self, widget):
+ self.emit('game_changed', None, None, 'reset', None, None)
+
+ def _load_game(self, button):
+ pass
+
+ def _accessibility_changed(self, widget):
+ self.emit("accessibility_changed", self._accessible.get_active(), self._speed_bar.get_value())
diff --git a/activity.py b/activity.py
index af19665..6f2ac9f 100644
--- a/activity.py
+++ b/activity.py
@@ -44,6 +44,7 @@ import game
import messenger
import memorizetoolbar
import createtoolbar
+import accessibilitytoolbar
import cardlist
import createcardpanel
import face
@@ -53,7 +54,7 @@ IFACE = SERVICE
PATH = '/org/laptop/Memorize'
_TOOLBAR_PLAY = 1
-_TOOLBAR_CREATE = 2
+_TOOLBAR_CREATE = 3
class MemorizeActivity(Activity):
@@ -65,11 +66,15 @@ class MemorizeActivity(Activity):
toolbox = ActivityToolbox(self)
activity_toolbar = toolbox.get_activity_toolbar()
-
+
self._memorizeToolbar = memorizetoolbar.MemorizeToolbar(self)
toolbox.add_toolbar(_('Play'), self._memorizeToolbar)
- self._memorizeToolbar.show()
-
+ self._memorizeToolbar.show()
+
+ self._accessibility_toolbar = accessibilitytoolbar.AccessibilityToolbar(self)
+ toolbox.add_toolbar(_('Accessibility'), self._accessibility_toolbar)
+ self._accessibility_toolbar.show()
+
self._createToolbar = createtoolbar.CreateToolbar(self)
toolbox.add_toolbar(_('Create'), self._createToolbar)
self._createToolbar.show()
@@ -111,7 +116,7 @@ class MemorizeActivity(Activity):
self.game.connect('change_game', self._memorizeToolbar.update_toolbar)
self._memorizeToolbar.connect('game_changed', self.game.change_game)
- self._memorizeToolbar.connect('accesible_toggled', self.table.toggle_accesibility)
+ self._accessibility_toolbar.connect('accessibility_changed', self.table.accessibility_changed)
self.hbox = gtk.HBox(False)
self.set_canvas(self.hbox)
diff --git a/cardtable.py b/cardtable.py
index 4783ae5..905b716 100644
--- a/cardtable.py
+++ b/cardtable.py
@@ -68,9 +68,10 @@ class CardTable(gtk.EventBox):
self.dict = None
self.show_all()
- # Sets the game to run in accesible mode:
- self.accesible = False # This should be optional
+ # Sets the game to run in accessible mode:
+ self.accessible = False # This should be optional
self.scanning_id = 0
+ self.scanning_speed = 2
def _allocate_cb(self, widget, allocation):
size = allocation.height
@@ -160,22 +161,22 @@ class CardTable(gtk.EventBox):
self.show_all()
#gc.collect()
- # If necessary starts scanning for accesibility
+ # If necessary starts scanning for accessibility
self.restart_scanning()
def restart_scanning(self):
# Increments scanning_id so new games will not be scanned by old timers
self.scanning_id += 1
- # accesible game scanning info
- if self.accesible:
+ # accessible game scanning info
+ if self.accessible:
self.scanning_status = {
"direction": "F",
"row": self.size - 1, # Initialized in last row, so the next is the first
"column": 0
}
# Scanning will occur every two seconds <- this should be configurable
- gobject.timeout_add(2000, self.scan_next, self.scanning_id)
+ gobject.timeout_add(self.scanning_speed * 1000, self.scan_next, self.scanning_id)
def scan_next(self, id):
if self.scanning_id != id:
@@ -219,11 +220,11 @@ class CardTable(gtk.EventBox):
if first_card + column < len(self.cards):
self.highlight_card(None, first_card + column, pintar)
- def toggle_accesibility(self, widget, accesible):
- print accesible
- self.accesible = accesible
+ def accessibility_changed(self, widget, accessible, speed):
+ self.accessible = accessible
+ self.scanning_speed = speed
self.restart_scanning()
-
+
def change_game(self, widget, data, grid):
if not self.first_load:
for card in self.cards.values():
@@ -238,8 +239,8 @@ class CardTable(gtk.EventBox):
return x
def mouse_event(self, widget, event, coord):
- # In accesible mode mouse event doesn't highlight cards, the highlighting occurs through the scanning
- if not self.accesible:
+ # In accessible mode mouse event doesn't highlight cards, the highlighting occurs through the scanning
+ if not self.accessible:
#self.table.grab_focus()
card = self.cards[coord[0], coord[1]]
identifier = self.cd2id.get(card)
@@ -280,7 +281,7 @@ class CardTable(gtk.EventBox):
self.card_flipped(card)
def flip_card_mouse(self, widget, event, identifier):
- if self.accesible:
+ if self.accessible:
if self.scanning_status["direction"] == 'F':
# Turn off row highlight
self.paint_cards(False, self.scanning_status["row"], None)
diff --git a/memorizetoolbar.py b/memorizetoolbar.py
index c4fcfec..477d730 100644
--- a/memorizetoolbar.py
+++ b/memorizetoolbar.py
@@ -46,7 +46,6 @@ class MemorizeToolbar(gtk.Toolbar):
__gsignals__ = {
'game_changed': (SIGNAL_RUN_FIRST, None, 5 * [TYPE_PYOBJECT]),
- 'accesible_toggled': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT])
}
def __init__(self, activity):
@@ -105,11 +104,6 @@ class MemorizeToolbar(gtk.Toolbar):
self._game_combo.combo.connect('changed', self._game_changed_cb)
self._add_widget(self._game_combo)
- # Accesible mode checkbox
- self._accesible = gtk.CheckButton(_('Accesible'))
- self._accesible.connect('toggled', self._toggle_accesible)
- self._add_widget(self._accesible)
-
def _add_widget(self, widget, expand=False):
tool_item = gtk.ToolItem()
tool_item.set_expand(expand)
@@ -170,9 +164,6 @@ class MemorizeToolbar(gtk.Toolbar):
game_file = join(dirname(__file__), 'demos', game_name+'.zip')
self.emit('game_changed', game_file, game_size, 'demo', title, None)
self._game_combo.combo.set_active(0)
-
- def _toggle_accesible(self, checkbutton):
- self.emit('accesible_toggled', checkbutton.get_active())
def update_toolbar(self, widget, data, grid):
size = data.get('size')
diff --git a/po/es.po b/po/es.po
index 77d32c5..580010a 100644
--- a/po/es.po
+++ b/po/es.po
@@ -262,6 +262,13 @@ msgstr "Polaco"
msgid "Esperanto"
msgstr "Esperanto"
+# ACCESIBILITY (manually added)
+msgid "Accessibility"
+msgstr "Accesibilidad"
+
+msgid "Accessible"
+msgstr "Accesibile"
+
#~ msgid "Choose image"
#~ msgstr "Escoger imagen"
diff --git a/svgcard.py b/svgcard.py
index d16e4bc..7afe088 100644
--- a/svgcard.py
+++ b/svgcard.py
@@ -41,12 +41,13 @@ class SvgCard(gtk.EventBox):
default_props = {}
default_props['back'] = {'fill_color':'#b2b3b7', 'stroke_color':'#b2b3b7',
'opacity':'1'}
- default_props['back_h'] = {'fill_color':'#b2b3b7',
+ default_props['back_h'] = {'fill_color':'#C06060',
'stroke_color':'#C00000', 'opacity':'1'}
default_props['back_text'] = {'text_color':'#c7c8cc'}
+
default_props['front'] = {'fill_color':'#4c4d4f', 'stroke_color':'#ffffff',
'opacity':'1'}
- default_props['front_h'] = {'fill_color':'#555555',
+ default_props['front_h'] = {'fill_color':'#C06060',
'stroke_color':'#888888', 'opacity':'1'}
default_props['front_text'] = {'text_color':'#ffffff'}