Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2011-09-19 18:48:21 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2011-09-19 18:48:21 (GMT)
commit05811f40eb4cf620bbd216570dea7ac0287a71bb (patch)
tree2bea00467b16144913bf9983e89dea6ca6d7eabc
parent1d85755b9a93149d380a944c2c3b08ab7a384c96 (diff)
Replace demo games combo by a button with a menuv37
The combo with the text can be wide depending of the laguage and buttons fall out of the toolbar. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--activity.py2
-rw-r--r--icons/memorize-collection.svg26
-rw-r--r--memorizetoolbar.py46
3 files changed, 49 insertions, 25 deletions
diff --git a/activity.py b/activity.py
index 9bba185..b0f4b9c 100644
--- a/activity.py
+++ b/activity.py
@@ -96,6 +96,8 @@ class MemorizeActivity(Activity):
self._memorizeToolbarBuilder = \
memorizetoolbar.MemorizeToolbarBuilder(self)
+ toolbar_box.toolbar.insert(gtk.SeparatorToolItem(), -1)
+
self._createToolbarBuilder = \
createtoolbar.CreateToolbarBuilder(self)
diff --git a/icons/memorize-collection.svg b/icons/memorize-collection.svg
new file mode 100644
index 0000000..7c97f23
--- /dev/null
+++ b/icons/memorize-collection.svg
@@ -0,0 +1,26 @@
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#010101">
+ <!ENTITY fill_color "#ffffff">
+]>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="55" height="55" viewBox="0 0 55 55" xml:space="preserve">
+ <g transform="matrix(0.58,0,0,0.58,24.53,0.11)">
+ <rect display="inline" fill="&fill_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="7.291" y="7.833"/>
+ <rect display="inline" fill="&stroke_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="22.625" y="7.833"/>
+ <rect display="inline" fill="&fill_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="37.375" y="7.833"/>
+ <rect display="inline" fill="&fill_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="7.291" y="22.75"/>
+ <rect display="inline" fill="&fill_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="22.625" y="22.75"/>
+ <rect display="inline" fill="&stroke_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="37.375" y="22.75"/>
+ <rect display="inline" fill="&stroke_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="7.291" y="37.625"/>
+ <rect display="inline" fill="&stroke_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="22.625" y="37.625"/>
+ <rect display="inline" fill="&stroke_color;" height="10" stroke="&fill_color;" stroke-width="3.5" width="10" x="37.375" y="37.625"/>
+ </g>
+ <g transform="translate(-0.2743801,0.51351)" id="g3036">
+ <path d="M 9.57,38.95 9.39,32.9 M 25.66,50.97 3.63,51.24 3.52,39.25 l 5.85,-6.36 21.26,0 -0.11,12.12 z M 3.63,39.38 l 21.48,0.27 0.33,10.92 m -0.31,-11.05 5.53,-6.64" style="fill:none;stroke:&fill_color;;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
+ <g transform="matrix(0,-1,-1,0,47.31,85.98)">
+ <g transform="translate(34.08,-1006.42)">
+ <polyline points="51.56,15.31 41.17,16.19 42.05,5.79" style="fill:none;stroke:&fill_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" transform="matrix(-0.47,0.47,-0.47,-0.47,66.29,1019.03)" />
+ <path d="m 39.36,1033.13 -0.06,9.91 -8.75,0.07" style="fill:none;stroke:&fill_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+ </g>
+ </g>
+</svg> \ No newline at end of file
diff --git a/memorizetoolbar.py b/memorizetoolbar.py
index 83e36ee..98ddf0f 100644
--- a/memorizetoolbar.py
+++ b/memorizetoolbar.py
@@ -23,6 +23,8 @@ from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toolcombobox import ToolComboBox
from sugar.graphics.alert import Alert
from sugar.graphics.icon import Icon
+from sugar.activity.widgets import RadioMenuButton
+from sugar.graphics.menuitem import MenuItem
import logging
from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT
@@ -34,15 +36,13 @@ class MemorizeToolbarBuilder(gobject.GObject):
__gtype_name__ = 'MemoryToolbarBuilder'
- standard_game_names = ['Load demo games',
- 'addition',
+ standard_game_names = ['addition',
'letters',
'sounds'
]
- translated_game_names = [_('Load demo games'),
- _('addition'),
- _('letters'),
- _('sounds')
+ translated_game_names = [_('Addition'),
+ _('Letters'),
+ _('Sounds')
]
__gsignals__ = {
@@ -65,14 +65,16 @@ class MemorizeToolbarBuilder(gobject.GObject):
self.toolbar.insert(self._size_combo, -1)
self._size_combo.combo.set_active(0)
- # Change demo games combobox
- self._game_combo = ToolComboBox()
- for i, f in enumerate(self.standard_game_names):
- f = _(f)
- self._game_combo.combo.append_item(i, f)
- self._game_combo.combo.set_active(0)
- self._game_combo.combo.connect('changed', self._game_changed_cb)
- self.toolbar.insert(self._game_combo, -1)
+ # Change demo games button
+ self._demo_games = RadioMenuButton(icon_name='memorize-collection')
+ self._demo_games.props.tooltip = _('Load demo games')
+
+ for i, game in enumerate(self.translated_game_names):
+ menu_item = MenuItem(game)
+ menu_item.connect('activate', self.__activate_game_cb, i)
+ self._demo_games.props.palette.menu.append(menu_item)
+ menu_item.show()
+ self.toolbar.insert(self._demo_games, -1)
# Reset Button
self._restart_button = ToolButton('game-new')
@@ -89,7 +91,7 @@ class MemorizeToolbarBuilder(gobject.GObject):
def update_controls(self, active):
self._size_combo.set_sensitive(active)
- self._game_combo.set_sensitive(active)
+ self._demo_games.set_sensitive(active)
self._restart_button.set_sensitive(active and
self.activity.game.model.count > 0)
@@ -100,9 +102,8 @@ class MemorizeToolbarBuilder(gobject.GObject):
game_size = int(self._sizes[self._size_combo.combo.get_active()][0])
self.emit('game_changed', None, game_size, 'size', None, None)
- def _game_changed_cb(self, combobox):
- if combobox.get_active() == 0:
- return
+ def __activate_game_cb(self, menu, i):
+ self._game_selected_index = i
if self.activity.game.model.is_demo:
self._change_game()
else:
@@ -122,17 +123,12 @@ class MemorizeToolbarBuilder(gobject.GObject):
self._change_game()
def _change_game(self):
- current_game = self._game_combo.combo.get_active()
- game_name = self.standard_game_names[current_game]
- title = game_name
+ title = self.translated_game_names[self._game_selected_index]
game_size = int(self._sizes[self._size_combo.combo.get_active()][0])
- if game_name in self.translated_game_names:
- index = self.translated_game_names.index(game_name)
- game_name = self.standard_game_names[index]
+ game_name = self.standard_game_names[self._game_selected_index]
game_file = join(dirname(__file__), 'demos', game_name + '.zip')
- self._game_combo.combo.set_active(0)
self.emit('game_changed', game_file, game_size, 'demo', title, None)
def update_toolbar(self, widget, data, grid):