Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuriel de Souza Godoi <muriel@laptop.org>2007-09-20 18:40:22 (GMT)
committer Muriel de Souza Godoi <muriel@laptop.org>2007-09-20 18:40:22 (GMT)
commite3af6ee47390ac2bde75a6c31f85c091fdc3bce2 (patch)
treed1a5862820ac0548d35220c412d6faf46a267bcd
parent5aed505296e2a7ab3d3ec8515f42c357c646f32b (diff)
add create game icons, create game guidevelop
New svgcard system using a cache to minimize memory usage.
-rwxr-xr-xactivity.py19
-rw-r--r--cardlist.py57
-rwxr-xr-xcardtable.py8
-rw-r--r--createcardpanel.py10
-rwxr-xr-xcreatetoolbar.py91
-rwxr-xr-xgames/numbers/numbers.mem6
-rw-r--r--images/game-load.svg166
-rwxr-xr-ximages/game-new.svg (renamed from images/new.svg)0
-rw-r--r--images/game-save.svg166
-rwxr-xr-xmemorizetoolbar.py23
-rwxr-xr-xplayerscoreboard.py21
-rwxr-xr-xsvgcard.py166
12 files changed, 554 insertions, 179 deletions
diff --git a/activity.py b/activity.py
index 14c3ad7..2eefa76 100755
--- a/activity.py
+++ b/activity.py
@@ -61,6 +61,7 @@ class MemorizeActivity(Activity):
self.game = game.MemorizeGame()
self.create_load = False
+ self.create_mode = False
self.hbox = gtk.HBox(False)
self.hbox.pack_start(self.scoreboard, False, False)
@@ -104,8 +105,6 @@ class MemorizeActivity(Activity):
self.game.connect('wait_mode_buddy', self.scoreboard.set_wait_mode)
self.game.connect('change-turn', self.scoreboard.set_selected)
- self.show_all()
-
# connect to the in/out events of the memorize activity
self.connect('focus_in_event', self._focus_in)
self.connect('focus_out_event', self._focus_out)
@@ -140,6 +139,7 @@ class MemorizeActivity(Activity):
_logger.debug("buddy joined - __init__: %s", self.owner.props.nick)
self.game.load_game('addition', 4)
self.game.add_buddy(self.owner)
+ self.show_all()
def change_mode(self, notebook, index):
if index == 2:
@@ -150,17 +150,22 @@ class MemorizeActivity(Activity):
self.createcardpanel.connect('add-pair', self.cardlist.add_pair)
self.createcardpanel.connect('update-pair', self.cardlist.update_selected)
self.cardlist.connect('pair-selected', self.createcardpanel.load_pair)
+ self._createToolbar.connect('create_new_game', self.cardlist.clean_list)
+ self._createToolbar.connect('create_load_game', self.cardlist.load_game)
+ self._createToolbar.connect('create_save_game', self.cardlist.save_game)
self.create_load = True
-
self.hbox.remove(self.scoreboard)
self.hbox.remove(self.table)
self.hbox.pack_start(self.createcardpanel)
self.hbox.pack_start(self.cardlist, False, False)
+ self.create_mode = True
else:
- self.hbox.remove(self.cardlist)
- self.hbox.remove(self.createcardpanel)
- self.hbox.pack_start(self.scoreboard, False, False)
- self.hbox.pack_start(self.table)
+ if self.create_mode:
+ self.hbox.remove(self.cardlist)
+ self.hbox.remove(self.createcardpanel)
+ self.hbox.pack_start(self.scoreboard, False, False)
+ self.hbox.pack_start(self.table)
+ self.create_mode = False
def restart(self, widget):
self.game.reset()
diff --git a/cardlist.py b/cardlist.py
index cce0b04..b84e2fe 100644
--- a/cardlist.py
+++ b/cardlist.py
@@ -21,6 +21,8 @@ import gtk
import svgcard
import gobject
import logging
+import os
+import model
_logger = logging.getLogger('memorize-activity')
@@ -32,7 +34,7 @@ class CardList(gtk.EventBox):
def __init__(self):
gtk.EventBox.__init__(self)
-
+ self.model = model.Model(os.path.dirname(__file__))
self.pairs = []
self.current_pair = None
@@ -52,22 +54,45 @@ class CardList(gtk.EventBox):
#scroll.get_child().set_property('shadow-type', gtk.SHADOW_NONE)
scroll.get_child().modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000000'))
self.add(scroll)
- self.add_pair(self, '')
+ self.add_pair(self, '', '')
self.pairs[0].set_selected(True)
self.current_pair = self.pairs[0]
self.show()
+
+ def load_game(self, widget, game_name):
+ self.model.read(game_name)
+ game_pairs = self.model.pairs
+ self.clean_list()
+ map(lambda key: self.add_pair(None, game_pairs[key].props.achar, game_pairs[key].props.bchar, False) , game_pairs)
+
+ def save_game(self, widget, game_name):
+ game_model = model.Model(os.path.dirname(__file__))
+ game_model.data['name'] = 'game_name'
+ for pair in range(len(self.pairs)):
+ pair_card = model.Pair()
+ pair_card.set_property('achar', self.pairs[pair].get_text())
+ pair_card.set_property('bchar', self.pairs[pair].get_text())
+ game_model.pairs[pair] = pair_card
+ game_model.write()
+
+ def clean_list(self, button = None):
+ map(lambda x: self.vbox.remove(x), self.pairs)
+ del self.pairs
+ self.pairs = []
- def add_pair(self, widget, text):
- pair = Pair(text, text)
+ def add_pair(self, widget, achar, bchar, show = True):
+ pair = Pair(achar, bchar)
self.vbox.pack_end(pair, False, True)
self.pairs.append(pair)
- pair.connect('pair-selected',self.set_selected)
- pair.connect('pair-closed',self.rem_pair)
- self.show_all()
+ pair.connect('pair-selected', self.set_selected)
+ pair.connect('pair-closed', self.rem_pair)
+ if show:
+ self.show_all()
def rem_pair(self, widget, event):
self.vbox.remove(widget)
- del self.pairs[widget]
+ self.pairs.remove(widget)
+ del widget
def set_selected(self, widget, event):
if self.current_pair <> None:
@@ -75,10 +100,10 @@ class CardList(gtk.EventBox):
self.old.set_selected(False)
self.current_pair = widget
widget.set_selected(True)
- self.emit('pair-selected',self.current_pair.get_text() )
+ self.emit('pair-selected', self.current_pair.get_text())
- def update_selected(self, widget, newtext):
- self.current_pair.change_text(newtext)
+ def update_selected(self, widget, newtext1, newtext2):
+ self.current_pair.change_text(newtext1)
class Pair(gtk.EventBox):
@@ -99,11 +124,11 @@ class Pair(gtk.EventBox):
close_button = gtk.Button('X')
close_button.connect('button-press-event', self.emit_close)
table = gtk.Table()
- table.connect('button-press-event',self.emit_selected)
+ table.connect('button-press-event', self.emit_selected)
table.set_col_spacings(5)
table.set_border_width(10)
- self.bcard1 = svgcard.SvgCard(-1, {'front_text':{'card_text':text1, 'text_color':'#ffffff'}, 'front_border':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, {}, None, 184, 1, self.bg_color)
- self.bcard2 = svgcard.SvgCard(-1, {'front_text':{'card_text':text2, 'text_color':'#ffffff'}, 'front_border':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, {}, None, 184, 1, self.bg_color)
+ self.bcard1 = svgcard.SvgCard(-1, {'front_text':{'card_text':text1, 'text_color':'#ffffff'}, 'front':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, None, 184, 1, self.bg_color)
+ self.bcard2 = svgcard.SvgCard(-1, {'front_text':{'card_text':text2, 'text_color':'#ffffff'}, 'front':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, None, 184, 1, self.bg_color)
self.bcard1.flip()
self.bcard2.flip()
@@ -116,10 +141,10 @@ class Pair(gtk.EventBox):
self.show_all()
def emit_selected(self, widget, event):
- self.emit('pair-selected',self)
+ self.emit('pair-selected', self)
def emit_close(self, widget, event):
- self.emit('pair-closed',self)
+ self.emit('pair-closed', self)
def set_selected(self, status):
if not status:
diff --git a/cardtable.py b/cardtable.py
index c1fb1be..f1a992c 100755
--- a/cardtable.py
+++ b/cardtable.py
@@ -69,8 +69,6 @@ class CardTable(gtk.EventBox):
else:
text1 = str(self.data.get('face',''))
text2 = str(self.data.get('face',''))
- buffer_card_1 = svgcard.SvgCard(-1, {'back_text':{'card_text':text1}}, {}, None, self.card_size,1)
- buffer_card_2 = svgcard.SvgCard(-1, {'back_text':{'card_text':text2}}, {}, None, self.card_size,1)
x = 0
y = 0
@@ -82,18 +80,14 @@ class CardTable(gtk.EventBox):
else:
jpg = None
props = {}
- props['front_border'] = {'opacity':'1'}
- props['front_h_border'] ={'opacity':'1'}
props['front_text']= {'card_text':card.get('char', '')}
if card['ab']== 'a':
- buffer_card = buffer_card_1
props['back_text']= {'card_text':text1}
elif card['ab']== 'b':
- buffer_card = buffer_card_2
props['back_text']= {'card_text':text2}
- card = svgcard.SvgCard(id, props, buffer_card.get_cache(), jpg, self.card_size,self.data.get('align','1'))
+ card = svgcard.SvgCard(id, props, jpg, self.card_size,self.data.get('align','1'))
card.connect('enter-notify-event', self.mouse_event, [x, y])
card.connect("button-press-event", self.flip_card_mouse, id)
self.table_positions[(x, y)]=1
diff --git a/createcardpanel.py b/createcardpanel.py
index fa8ecd6..e2de4bc 100644
--- a/createcardpanel.py
+++ b/createcardpanel.py
@@ -27,8 +27,8 @@ _logger = logging.getLogger('memorize-activity')
class CreateCardPanel(gtk.EventBox):
__gsignals__ = {
- 'add-pair': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT]),
- 'update-pair': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT]),
+ 'add-pair': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT]),
+ 'update-pair': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT]),
}
def __init__(self):
@@ -54,10 +54,10 @@ class CreateCardPanel(gtk.EventBox):
self.show_all()
def emit_add_pair(self, widget, event):
- self.emit('add-pair',self.cardeditor.get_text())
+ self.emit('add-pair',self.cardeditor.get_text(),self.cardeditor.get_text())
def emit_update_pair(self, widget, event):
- self.emit('update-pair',self.cardeditor.get_text())
+ self.emit('update-pair',self.cardeditor.get_text(),self.cardeditor.get_text())
def load_pair(self, widget, newtext):
self.cardeditor.set_text(newtext)
@@ -88,7 +88,7 @@ class CardEditor(gtk.EventBox):
table.set_col_spacings(10)
table.set_row_spacings(10)
table.set_border_width(20)
- self.card = svgcard.SvgCard(-1, {'front_text':{'card_text':'', 'text_color':'#ffffff'}, 'front_border':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, {}, None, 184, 1, '#c0c0c0')
+ self.card = svgcard.SvgCard(-1, {'front_text':{'card_text':'', 'text_color':'#ffffff'}, 'front_border':{'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}}, None, 184, 1, '#c0c0c0')
self.card.flip()
table.attach(self.previewlabel, 0, 1, 1, 2)
diff --git a/createtoolbar.py b/createtoolbar.py
index f7981e4..af6a2dc 100755
--- a/createtoolbar.py
+++ b/createtoolbar.py
@@ -22,57 +22,76 @@ from gettext import gettext as _
import gtk
import os
-
+import gobject
+
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.combobox import ComboBox
+from sugar.graphics.toolcombobox import ToolComboBox
class CreateToolbar(gtk.Toolbar):
__gtype_name__ = 'CreateToolbar'
+ __gsignals__ = {
+ 'create_new_game': (gobject.SIGNAL_RUN_FIRST, None, []),
+ 'create_load_game': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT]),
+ 'create_save_game': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT]),
+ }
+
def __init__(self, activity):
gtk.Toolbar.__init__(self)
self.activity = activity
self._lock = True
- # Reset Button
- new_icon = os.path.join(os.path.dirname(__file__), "images/new.svg")
+ # New Button
+ new_icon = os.path.join(os.path.dirname(__file__), "images/game-new.svg")
new_image = gtk.Image()
new_image.set_from_file(new_icon)
- self._reset_button = gtk.ToolButton(new_image)
- #self._reset_button.set_image(new_image)
- #self._reset_button.connect('clicked', self._game_changed_cb)
- self._add_widget(self._reset_button)
-
- # Separator
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- self.insert(separator, -1)
+ self._new_button = ToolButton()
+ self._new_button.set_icon_widget(new_image)
+ self._new_button.set_tooltip(_('New game set'))
+ self._new_button.connect('clicked', self._new_game_bt)
+ self._add_widget(self._new_button)
- self._add_widget(gtk.Label('Game name: '))
- # Change game combobox
+ # Load Button
+ load_icon = os.path.join(os.path.dirname(__file__), "images/game-load.svg")
+ load_image = gtk.Image()
+ load_image.set_from_file(load_icon)
+ self._load_button = ToolButton()
+ self._load_button.set_icon_widget(load_image)
+ self._load_button.set_tooltip(_('Load game set'))
+ self._load_button.connect('enter-notify-event', self._drop_palette)
+ self._add_widget(self._load_button)
self.games = os.listdir(os.path.join(os.path.dirname(__file__), 'games'))
self.games.sort()
- self._game_combo = gtk.ComboBoxEntry()
- for i, f in enumerate(self.games):
- self._game_combo.append_text(f)
- if f == 'numbers':
- self._game_combo.set_active(i)
- #self._game_combo.connect('changed', self._game_changed_cb)
- self._add_widget(self._game_combo)
+ palette = self._load_button.get_palette()
+ for game in self.games:
+ menu_item = gtk.MenuItem(game)
+ menu_item.connect('activate', self._game_changed_cb, game)
+ palette.menu.prepend(menu_item)
+ menu_item.show()
+
+ # Save Button
+ save_icon = os.path.join(os.path.dirname(__file__), "images/game-save.svg")
+ save_image = gtk.Image()
+ save_image.set_from_file(save_icon)
+ self._save_button = ToolButton()
+ self._save_button.set_icon_widget(save_image)
+ self._save_button.set_tooltip(_('Save game set'))
+ self._save_button.connect('clicked', self._save_game_bt)
+ self._add_widget(self._save_button)
# Separator
separator2 = gtk.SeparatorToolItem()
separator2.set_draw(True)
self.insert(separator2, -1)
-
+
+ self._add_widget(gtk.Label(_('Game name: ')))
+ self.game_name_entry = gtk.Entry()
+ self._add_widget(self.game_name_entry)
+
self._add_widget(gtk.CheckButton('Equal pairs'))
-
- # Separator
- separator2 = gtk.SeparatorToolItem()
- separator2.set_draw(True)
- self.insert(separator2, -1)
self._add_widget(gtk.CheckButton('Grouped'))
+
def _add_widget(self, widget, expand=False):
tool_item = gtk.ToolItem()
@@ -80,4 +99,18 @@ class CreateToolbar(gtk.Toolbar):
tool_item.add(widget)
widget.show()
self.insert(tool_item, -1)
- tool_item.show() \ No newline at end of file
+ tool_item.show()
+
+ def _game_changed_cb(self, combobox, game_name):
+ self.game_name_entry.set_text(game_name)
+ self.emit('create_load_game',game_name)
+
+ def _drop_palette(self, button):
+ button.get_palette().popdown(False)
+
+ def _new_game_bt(self, button):
+ self.game_name_entry.set_text('')
+ self.emit('create_new_game')
+
+ def _save_game_bt(self, button):
+ self.emit('create_save_game',self.game_name_entry.get_text()) \ No newline at end of file
diff --git a/games/numbers/numbers.mem b/games/numbers/numbers.mem
index 2ced428..2fe7811 100755
--- a/games/numbers/numbers.mem
+++ b/games/numbers/numbers.mem
@@ -16,8 +16,8 @@
<pair achar="13" asnd="13.ogg" bimg="13x.jpg" bsnd="13.ogg" />
<pair achar="14" asnd="14.ogg" bimg="14x.jpg" bsnd="14.ogg" />
<pair achar="15" asnd="15.ogg" bimg="15x.jpg" bsnd="15.ogg" />
- <pair achar="16" asnd="16.ogg" bimg="16x.jpg" asnd="16.ogg" />
- <pair achar="17" asnd="17.ogg" bimg="17x.jpg" asnd="17.ogg" />
- <pair achar="18" asnd="18.ogg" bimg="18x.jpg" asnd="18.ogg" />
+ <pair achar="16" asnd="16.ogg" bimg="16x.jpg" bsnd="16.ogg" />
+ <pair achar="17" asnd="17.ogg" bimg="17x.jpg" bsnd="17.ogg" />
+ <pair achar="18" asnd="18.ogg" bimg="18x.jpg" bsnd="18.ogg" />
</memorize>
diff --git a/images/game-load.svg b/images/game-load.svg
new file mode 100644
index 0000000..deaaa2a
--- /dev/null
+++ b/images/game-load.svg
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 55 55"
+ height="55px"
+ version="1.1"
+ viewBox="0 0 55 55"
+ width="55px"
+ x="0px"
+ xml:space="preserve"
+ y="0px"
+ id="svg5142"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docname="game-load.svg"
+ sodipodi:docbase="/home/msgodoi/olpc/workspace/Memorize.activity/images"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata5176"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs5174">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </defs><sodipodi:namedview
+ inkscape:window-height="871"
+ inkscape:window-width="1432"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="12.145455"
+ inkscape:cx="27.5"
+ inkscape:cy="30.793413"
+ inkscape:window-x="4"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg5142" /><g
+ id="g5125"
+ transform="translate(-2,2)"><g
+ id="g5147">
+ <g
+ id="g5149">
+ <path
+ style="fill:#ffffff;stroke:#8c8c8c;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ id="path5151"
+ d="M 6.736,49.002 L 31.256,49.002 C 33.481,49.002 34.695,47.555 34.695,45.561 L 34.695,18.281 C 34.695,16.551 32.963,14.84 31.256,14.84 L 26.867,14.84" />
+ </g>
+ </g><g
+ id="g5153">
+ <g
+ id="g5155">
+ <path
+ style="fill:#ffffff;stroke:#8c8c8c;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ id="path5157"
+ d="M 26.867,38.592 C 26.867,40.428 25.522,41.793 23.426,42.639 L 6.736,49.002 L 6.736,14.84 L 23.426,6.241 C 25.654,5.847 26.867,7.081 26.867,9.075 L 26.867,38.592 z " />
+ </g>
+ </g><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5159"
+ d="M 9.424,42.607 C 9.424,42.607 8.073,42.064 6.722,42.064 C 5.371,42.064 4.019,42.607 4.019,42.607" /><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5161"
+ d="M 9.424,32.006 C 9.424,32.006 8.185,31.463 6.609,31.463 C 5.032,31.463 4.019,32.006 4.019,32.006" /><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5163"
+ d="M 9.424,21.678 C 9.424,21.678 8.299,21.134 6.497,21.134 C 4.695,21.134 4.019,21.678 4.019,21.678" /><line
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="line5165"
+ y2="11.505"
+ y1="46.533001"
+ x2="13.209"
+ x1="13.209" /></g><g
+ id="g4140"
+ transform="matrix(0.8372116,0,0,0.8372116,8.751416,-7.2720533e-2)"><rect
+ style="fill:#ffffff;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2221"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="32.505089" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2223"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2225"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="47.70649" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2227"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="32.505089" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2229"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2231"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="47.70649" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2233"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="32.505089" /><rect
+ style="fill:#ffffff;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2235"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2237"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="47.70649" /></g><line
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="line5169"
+ y2="36.425068"
+ y1="22.462688"
+ x2="44.528595"
+ x1="44.72258" /><polyline
+ style="fill:none;stroke:#ffffff;stroke-width:5.1055975;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="polyline5171"
+ points=" 51.562,15.306 41.17,16.188 42.053,5.794 "
+ transform="matrix(-0.5053552,0.4648229,-0.493202,-0.4762768,73.4836,10.383118)" /><line
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="line4138"
+ y2="36.52364"
+ y1="36.329655"
+ x2="44.443764"
+ x1="36.409523" /></svg> \ No newline at end of file
diff --git a/images/new.svg b/images/game-new.svg
index 4dc4b64..4dc4b64 100755
--- a/images/new.svg
+++ b/images/game-new.svg
diff --git a/images/game-save.svg b/images/game-save.svg
new file mode 100644
index 0000000..8d43d4b
--- /dev/null
+++ b/images/game-save.svg
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 55 55"
+ height="55px"
+ version="1.1"
+ viewBox="0 0 55 55"
+ width="55px"
+ x="0px"
+ xml:space="preserve"
+ y="0px"
+ id="svg5142"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docname="game-save.svg"
+ sodipodi:docbase="/home/msgodoi/olpc/workspace/Memorize.activity/images"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata5176"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs5174">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </defs><sodipodi:namedview
+ inkscape:window-height="871"
+ inkscape:window-width="1432"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="12.145455"
+ inkscape:cx="27.5"
+ inkscape:cy="30.793413"
+ inkscape:window-x="4"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg5142" /><g
+ id="g5125"
+ transform="translate(-2,2)"><g
+ id="g5147">
+ <g
+ id="g5149">
+ <path
+ style="fill:#ffffff;stroke:#8c8c8c;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ id="path5151"
+ d="M 6.736,49.002 L 31.256,49.002 C 33.481,49.002 34.695,47.555 34.695,45.561 L 34.695,18.281 C 34.695,16.551 32.963,14.84 31.256,14.84 L 26.867,14.84" />
+ </g>
+ </g><g
+ id="g5153">
+ <g
+ id="g5155">
+ <path
+ style="fill:#ffffff;stroke:#8c8c8c;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ id="path5157"
+ d="M 26.867,38.592 C 26.867,40.428 25.522,41.793 23.426,42.639 L 6.736,49.002 L 6.736,14.84 L 23.426,6.241 C 25.654,5.847 26.867,7.081 26.867,9.075 L 26.867,38.592 z " />
+ </g>
+ </g><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5159"
+ d="M 9.424,42.607 C 9.424,42.607 8.073,42.064 6.722,42.064 C 5.371,42.064 4.019,42.607 4.019,42.607" /><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5161"
+ d="M 9.424,32.006 C 9.424,32.006 8.185,31.463 6.609,31.463 C 5.032,31.463 4.019,32.006 4.019,32.006" /><path
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="path5163"
+ d="M 9.424,21.678 C 9.424,21.678 8.299,21.134 6.497,21.134 C 4.695,21.134 4.019,21.678 4.019,21.678" /><line
+ style="fill:none;stroke:#8c8c8c;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round"
+ id="line5165"
+ y2="11.505"
+ y1="46.533001"
+ x2="13.209"
+ x1="13.209" /></g><g
+ id="g4140"
+ transform="matrix(0.8372116,0,0,0.8372116,8.751416,-7.2720533e-2)"><rect
+ style="fill:#ffffff;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2221"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="32.505089" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2223"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2225"
+ height="5.0509453"
+ width="5.0529833"
+ y="2.5764074"
+ x="47.70649" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2227"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="32.505089" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2229"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2231"
+ height="5.0509453"
+ width="5.0529833"
+ y="10.110903"
+ x="47.70649" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2233"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="32.505089" /><rect
+ style="fill:#ffffff;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2235"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="40.25333" /><rect
+ style="fill:#aaaaaa;stroke:#000000;stroke-width:2.38888216;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2237"
+ height="5.0509453"
+ width="5.0529833"
+ y="17.624184"
+ x="47.70649" /></g><line
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="line5169"
+ y2="36.425068"
+ y1="22.462688"
+ x2="45.845959"
+ x1="46.039944" /><polyline
+ style="fill:none;stroke:#ffffff;stroke-width:5.1055975;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="polyline5171"
+ points=" 51.562,15.306 41.17,16.188 42.053,5.794 "
+ transform="matrix(0.4648229,0.5053552,-0.4762768,0.493202,24.919883,7.4889306)" /><line
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ id="line4138"
+ y2="36.52364"
+ y1="36.329655"
+ x2="45.78508"
+ x1="37.750839" /></svg> \ No newline at end of file
diff --git a/memorizetoolbar.py b/memorizetoolbar.py
index bf9f84d..bb17ba2 100755
--- a/memorizetoolbar.py
+++ b/memorizetoolbar.py
@@ -24,7 +24,7 @@ import os
from gettext import gettext as _
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.combobox import ComboBox
+from sugar.graphics.toolcombobox import ToolComboBox
class MemorizeToolbar(gtk.Toolbar):
@@ -42,6 +42,7 @@ class MemorizeToolbar(gtk.Toolbar):
# Reset Button
self._reset_button = ToolButton('insert-image')
self._reset_button.connect('clicked', self._game_changed_cb)
+ self._reset_button.set_tooltip(_('Restart Game'))
self.insert(self._reset_button, -1)
self._reset_button.show()
@@ -53,12 +54,12 @@ class MemorizeToolbar(gtk.Toolbar):
# Change game combobox
self.games = os.listdir(os.path.join(os.path.dirname(__file__), 'games'))
self.games.sort()
- self._game_combo = ComboBox()
+ self._game_combo = ToolComboBox()
for i, f in enumerate(self.games):
if f in self.standard_game_names:
f = _(f)
- self._game_combo.append_item(i, f)
- self._game_combo.connect('changed', self._game_changed_cb)
+ self._game_combo.combo.append_item(i, f)
+ self._game_combo.combo.connect('changed', self._game_changed_cb)
self._add_widget(self._game_combo)
separator = gtk.SeparatorToolItem()
@@ -67,11 +68,11 @@ class MemorizeToolbar(gtk.Toolbar):
self._lock = False
# Change size combobox
- self._size_combo = ComboBox()
+ self._size_combo = ToolComboBox()
self._sizes = ['4 X 4', '5 X 5', '6 X 6']
for i, f in enumerate(self._sizes):
- self._size_combo.append_item(i, f)
- self._size_combo.connect('changed', self._game_changed_cb)
+ self._size_combo.combo.append_item(i, f)
+ self._size_combo.combo.connect('changed', self._game_changed_cb)
self._add_widget(self._size_combo)
def _add_widget(self, widget, expand=False):
@@ -84,8 +85,8 @@ class MemorizeToolbar(gtk.Toolbar):
def _game_changed_cb(self, combobox):
if not self._lock:
- game_name = self.games[self._game_combo.get_active()]
- game_size = int(self._sizes[self._size_combo.get_active()][0])
+ game_name = self.games[self._game_combo.combo.get_active()]
+ 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]
@@ -96,7 +97,7 @@ class MemorizeToolbar(gtk.Toolbar):
size = data.get('size')
self._lock = True
game_index = self.games.index(game)
- self._game_combo.set_active(game_index)
+ self._game_combo.combo.set_active(game_index)
size_index = self._sizes.index(size+' X '+size)
- self._size_combo.set_active(int(size_index))
+ self._size_combo.combo.set_active(int(size_index))
self._lock = False
diff --git a/playerscoreboard.py b/playerscoreboard.py
index 2526917..32bf551 100755
--- a/playerscoreboard.py
+++ b/playerscoreboard.py
@@ -54,12 +54,7 @@ class PlayerScoreboard(gtk.EventBox):
self.icon = svglabel.SvgLabel(self.xo_buddy, fill_color, stroke_color, False, self.current_color, 45, 55)
# Set waiting buddy icon
- self.waiting_icon = svglabel.SvgLabel(self.xo_buddy, self.default_color, '#ffffff', False, self.current_color, 45, 55)
-
- # Cache the score icon
- score_label = Score(fill_color, stroke_color)
- self.score_pixbuf_unsel = score_label.get_pixbuf()
- self.score_pixbuf_sel = score_label.get_pixbuf_sel()
+ #self.waiting_icon = svglabel.SvgLabel(self.xo_buddy, self.default_color, '#ffffff', False, self.current_color, 45, 55)
# Set nick label
self.nick = gtk.Label(nick)
@@ -68,10 +63,10 @@ class PlayerScoreboard(gtk.EventBox):
self.nick.set_alignment(0, 0.5)
# Set message label
- self.msg = gtk.Label('Waiting for next game...')
- self.msg.modify_font(pango.FontDescription("12"))
- self.msg.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
- self.msg.set_alignment(0, 0.5)
+ #self.msg = gtk.Label('Waiting for next game...')
+ #self.msg.modify_font(pango.FontDescription("12"))
+ #self.msg.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
+ #self.msg.set_alignment(0, 0.5)
self.add(self.table)
self.table.attach(self.icon, 0, 1, 0, 1)
@@ -82,6 +77,12 @@ class PlayerScoreboard(gtk.EventBox):
self.increase_score()
def increase_score(self):
+ if len(self.scores) == 0:
+ # Cache the score icon
+ score_label = Score(self.fill_color, self.stroke_color)
+ self.score_pixbuf_unsel = score_label.get_pixbuf()
+ self.score_pixbuf_sel = score_label.get_pixbuf_sel()
+
new_score = Score(self.fill_color, self.stroke_color, self.score_pixbuf_sel, self.score_pixbuf_unsel,self.status)
self.scores.append(new_score)
new_score.show()
diff --git a/svgcard.py b/svgcard.py
index d122d3e..cd88743 100755
--- a/svgcard.py
+++ b/svgcard.py
@@ -35,74 +35,69 @@ class SvgCard(gtk.DrawingArea):
# Default properties
default_props = {}
- default_props['back_border'] = {'fill_color':'#b2b3b7', 'stroke_color':'#b2b3b7', 'opacity':'1'}
- default_props['back_h_border'] = {'fill_color':'#b2b3b7', 'stroke_color':'#ffffff', 'opacity':'1'}
+ default_props['back'] = {'fill_color':'#b2b3b7', 'stroke_color':'#b2b3b7', 'opacity':'1'}
+ default_props['back_h'] = {'fill_color':'#b2b3b7', 'stroke_color':'#ffffff', 'opacity':'1'}
default_props['back_text'] = {'text_color':'#c7c8cc'}
- default_props['front_border'] = {'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'0'}
- default_props['front_h_border'] = {'fill_color':'#555555', 'stroke_color':'#888888', 'opacity':'0.5'}
+ default_props['front'] = {'fill_color':'#4c4d4f', 'stroke_color':'#ffffff', 'opacity':'1'}
+ default_props['front_h'] = {'fill_color':'#555555', 'stroke_color':'#888888', 'opacity':'1'}
default_props['front_text'] = {'text_color':'#ffffff'}
- def __init__(self, id, pprops, pcache, jpeg, size, align, bg_color='#000000'):
+ cache = {}
+
+ def __init__(self, id, pprops, jpeg, size, align, bg_color='#000000'):
gtk.DrawingArea.__init__(self)
self.set_size_request(size, size)
self.bg_color = bg_color
- self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.bg_color))
- self.connect('expose-event', self._expose_cb)
+ self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.bg_color))
self.flipped = False
self.flipped_once = False
self.id = id
self.jpeg = jpeg
+ self.show_jpeg = False
+ self.show_text = False
self.size = size
self.align = align
- self.set_flags(gtk.CAN_FOCUS)
# Views properties
- views = ['back_border', 'back_h_border', 'back_text', 'front_border', 'front_h_border', 'front_text']
+ views = ['back', 'back_h', 'back_text', 'front', 'front_h', 'front_text']
self.pprops = pprops
self.props = {}
for view in views:
self.props[view] = {}
self.props[view].update(self.default_props[view])
self.props[view].update(pprops.get(view, {}))
-
- # Cache
- self.cache = {}
- self.cache.update(pcache)
-
- build_all = (len(self.cache) == 0)
-
- self.build_all = build_all
-
- if build_all or pprops.has_key('back_border'):
- self.cache['back_border']= self._read_icon_data(self.props['back_border'])
- if build_all or pprops.has_key('back_h_border'):
- self.cache['back_h_border']= self._read_icon_data(self.props['back_h_border'])
-
- self.back_layout = self.get_text_layout(self.props['back_text'].get('card_text', ''), self.size-12)
- self.back_layout_position = (self.size -(self.back_layout.get_size()[1]/1000))/2
-
- if build_all or self.pprops.has_key('back_border') or self.pprops.has_key('back_text'):
- self.cache['back'] = self.build_face('back')
- if build_all or self.pprops.has_key('back_h_border') or self.pprops.has_key('back_text'):
- self.cache['back_h'] = self.build_face('back_h')
-
- self.current_pixbuf = self.cache['back']
- self.current_layout = self.back_layout
- self.current_layout_position = self.back_layout_position
- self.current_text_color = self.props['back_text'].get('text_color', '#c7c8cc')
+
+ if len(self.props['back_text'].get('card_text','')) > 0:
+ self.back_layout = self.get_text_layout(self.props['back_text']['card_text'], self.size-12)
+ self.back_layout_position = (self.size -(self.back_layout.get_size()[1]/1000))/2
+ self.current_layout = self.back_layout
+ self.current_layout_position = self.back_layout_position
+ self.current_text_color = self.props['back_text']['text_color']
+ self.show_text = True
+ self.current_face = 'back'
# Set events and listeners
+ self.connect('expose-event', self._expose_cb)
self.set_events(gtk.gdk.ALL_EVENTS_MASK)
gc.collect()
self.show()
def _expose_cb(self, widget, event):
- self.window.draw_pixbuf(None, self.current_pixbuf, 0, 0, 0, 0)
gc = self.window.new_gc()
- widget.window.draw_layout(gc, x=6, y=self.current_layout_position, layout=self.current_layout, foreground=gtk.gdk.color_parse(self.current_text_color))
+ pixbuf = self._read_icon_data(self.current_face)
+ self.window.draw_pixbuf(None, pixbuf, 0, 0, 0, 0)
+ if self.show_jpeg:
+ self.window.draw_pixbuf(None, self.jpeg, 0, 0, 11, 11)
+ if self.show_text:
+ widget.window.draw_layout(gc, x=6, y=self.current_layout_position, layout=self.current_layout, foreground=gtk.gdk.color_parse(self.current_text_color))
return False
- def _read_icon_data(self, dict):
+ def _read_icon_data(self, view):
+ dict = self.props[view]
+ set = str(self.size)+dict.get('fill_color')+dict.get('stroke_color')
+ if self.cache.has_key(set):
+ return self.cache[set]
+
icon_file = open(self.border_svg, 'r')
data = icon_file.read()
icon_file.close()
@@ -120,83 +115,73 @@ class SvgCard(gtk.DrawingArea):
data = re.sub('size_card1', str(self.size), data)
data = re.sub('size_card2', str(self.size-6), data)
data = re.sub('size_card3', str(self.size-17), data)
- return rsvg.Handle(data=data).get_pixbuf()
-
- def build_face(self, face):
- if face.endswith('_h'):
- text = face[:-2]
- else:
- text = face
- pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.size, self.size)
- pixbuf.fill(0x00000000)
- self.cache[face + '_border'].composite(pixbuf, 0, 0, self.size, self.size, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
- if face.startswith('front') and self.jpeg <> None:
- self.cache['jpeg'].composite(pixbuf, 11, 11, self.size-22, self.size-22, 11, 11, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
+ pixbuf = rsvg.Handle(data=data).get_pixbuf()
+ self.cache[set] = pixbuf
return pixbuf
def set_border(self, stroke_color, fill_color):
- self.props['front_border'].update({'fill_color':fill_color, 'stroke_color':stroke_color})
- self.cache['front_border'] = self._read_icon_data(self.props['front_border'])
- self.cache['front'] = self.build_face('front')
- self.current_pixbuf = self.cache['front']
- self.queue_draw()
+ self.props['front'].update({'fill_color':fill_color, 'stroke_color':stroke_color})
+ self.queue_draw()
+ while gtk.events_pending():
+ gtk.main_iteration()
def set_highlight(self, status, mouse = False):
if self.flipped:
if mouse:
return
if status:
- self.current_pixbuf = self.cache['front_h']
+ self.current_face = 'front_h'
else:
- self.current_pixbuf = self.cache['front']
+ self.current_face = 'front'
else:
if status:
- self.current_pixbuf = self.cache['back_h']
+ self.current_face = 'back_h'
else:
- self.current_pixbuf = self.cache['back']
+ self.current_face = 'back'
self.queue_draw()
def flip(self):
if not self.flipped:
if not self.flipped_once:
- if self.build_all or self.pprops.has_key('front_border'):
- self.cache['front_border']= self._read_icon_data(self.props['front_border'])
- if self.build_all or self.pprops.has_key('front_h_border'):
- self.cache['front_h_border']= self._read_icon_data(self.props['front_h_border'])
- self.front_layout = self.get_text_layout(self.props['front_text'].get('card_text', ''), self.size-11)
- if self.align == '2': # top
- self.front_layout_position = 6
- elif self.align == '3': # bottom
- self.front_layout_position = self.size -(self.front_layout.get_size()[1]/1000)
- else: # center and none
- self.front_layout_position = (self.size -(self.front_layout.get_size()[1]/1000))/2
if self.jpeg <> None:
pixbuf_t = gtk.gdk.pixbuf_new_from_file(self.jpeg)
- self.cache['jpeg']= pixbuf_t.scale_simple(self.size-22, self.size-22, gtk.gdk.INTERP_BILINEAR)
- del pixbuf_t
-
- if self.cache.has_key('front_border') or self.cache.has_key('front_text'):
- self.cache['front'] = self.build_face('front')
- if self.cache.has_key('front_h_border') or self.cache.has_key('front_text'):
- self.cache['front_h'] = self.build_face('front_h')
+ self.jpeg = pixbuf_t.scale_simple(self.size-22, self.size-22, gtk.gdk.INTERP_BILINEAR)
+ del pixbuf_t
+ if len(self.props.get('front_text',[]).get('card_text','')) > 0:
+ self.front_layout = self.get_text_layout(self.props['front_text']['card_text'], self.size-12)
+ self.front_layout_position = (self.size -(self.front_layout.get_size()[1]/1000))/2
self.flipped_once = True
- self.current_layout = self.front_layout
- self.current_layout_position = self.front_layout_position
- self.current_text_color = self.props['front_text'].get('text_color', '#c7c8cc')
- self.current_pixbuf = self.build_face('front')
+ if self.jpeg <> None:
+ self.show_jpeg = True
+ if len(self.props['front_text'].get('card_text','')) > 0:
+ self.current_layout = self.front_layout
+ self.current_layout_position = self.front_layout_position
+ self.current_text_color = self.props['front_text']['text_color']
+ self.show_text = True
+ else:
+ self.show_text = False
+
+ self.current_face = 'front'
+
self.flipped = True
self.queue_draw()
+
while gtk.events_pending():
gtk.main_iteration()
gc.collect()
def flop(self):
- self.current_pixbuf = self.build_face('back')
- self.current_layout = self.back_layout
- self.current_layout_position = self.back_layout_position
- self.current_text_color = self.props['back_text'].get('text_color', '#c7c8cc')
+ self.current_face = 'back'
+ if len(self.props['back_text'].get('card_text','')) > 0:
+ self.current_layout = self.back_layout
+ self.current_layout_position = self.back_layout_position
+ self.current_text_color = self.props['back_text']['text_color']
+ self.show_text = True
+ else:
+ self.show_text = False
self.flipped = False
+ self.show_jpeg = False
self.queue_draw()
def is_flipped(self):
@@ -205,13 +190,10 @@ class SvgCard(gtk.DrawingArea):
def get_id(self):
return self.id
- def get_cache(self):
- return self.cache
-
def reset(self):
if self.flipped:
fill_color = self.default_props.get('front_border').get('fill_color')
- stroke_color = self.default_props.get('front_border').get('stroke_color')
+ stroke_color = self.default_propsfront_text.get('front_border').get('stroke_color')
self.set_border(fill_color, stroke_color)
self.flop()
@@ -254,7 +236,9 @@ class SvgCard(gtk.DrawingArea):
self.current_layout = self.front_layout
self.current_layout_position = self.front_layout_position
- self.queue_draw()
-
+ self.current_text_color = self.props['front_text']['text_color']
+ if len(newtext) > 0:
+ self.show_text = True
+ self.queue_draw()
def get_text(self):
return self.props['front_text']['card_text'] \ No newline at end of file