diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2011-09-27 17:23:17 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2011-09-27 17:23:17 (GMT) |
commit | a998a202ee7afe0ef283bbae8eb338294c004abc (patch) | |
tree | 373c8b05cc6a4037388507be1a0fb360ab9a9274 /createcardpanel.py | |
parent | 5a0c2083c7b04a5d4b30ef0a91ddcb4e0b236535 (diff) |
matching mainline
Diffstat (limited to 'createcardpanel.py')
-rw-r--r-- | createcardpanel.py | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/createcardpanel.py b/createcardpanel.py index d7b94ad..dcf2f19 100644 --- a/createcardpanel.py +++ b/createcardpanel.py @@ -18,12 +18,9 @@ # import gtk -from os import environ from os.path import join, basename -import hippo import shutil -import tempfile from gettext import gettext as _ import svgcard import logging @@ -33,7 +30,7 @@ from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon from sugar.graphics.palette import Palette from port.widgets import ToggleToolButton -from port.widgets import CanvasRoundBox, ToolComboBox +from port.widgets import ToolComboBox from port import chooser import theme @@ -43,6 +40,7 @@ import speak.face _logger = logging.getLogger('memorize-activity') + class CreateCardPanel(gtk.EventBox): __gsignals__ = { 'add-pair': (SIGNAL_RUN_FIRST, None, 8 * [TYPE_PYOBJECT]), @@ -119,41 +117,45 @@ class CreateCardPanel(gtk.EventBox): def emit_add_pair(self, widget): self._addbutton.set_sensitive(False) if self.equal_pairs: - self.emit('add-pair', self.cardeditor1.get_text(), - self.cardeditor1.get_text(), - self.cardeditor1.get_pixbuf(), - self.cardeditor1.get_pixbuf(), - self.cardeditor1.get_snd(), self.cardeditor1.get_snd(), - self.cardeditor1.get_speak(), self.cardeditor1.get_speak() - ) + self.emit('add-pair', self.cardeditor1.get_text(), + self.cardeditor1.get_text(), + self.cardeditor1.get_pixbuf(), + self.cardeditor1.get_pixbuf(), + self.cardeditor1.get_snd(), + self.cardeditor1.get_snd(), + self.cardeditor1.get_speak(), + self.cardeditor1.get_speak()) else: - self.emit('add-pair', self.cardeditor1.get_text(), - self.cardeditor2.get_text(), - self.cardeditor1.get_pixbuf(), - self.cardeditor2.get_pixbuf(), - self.cardeditor1.get_snd(), self.cardeditor2.get_snd(), - self.cardeditor1.get_speak(), self.cardeditor2.get_speak() - ) + self.emit('add-pair', self.cardeditor1.get_text(), + self.cardeditor2.get_text(), + self.cardeditor1.get_pixbuf(), + self.cardeditor2.get_pixbuf(), + self.cardeditor1.get_snd(), + self.cardeditor2.get_snd(), + self.cardeditor1.get_speak(), + self.cardeditor2.get_speak()) self.clean(None) def emit_update_pair(self, widget): self._addbutton.set_sensitive(False) if self.equal_pairs: - self.emit('update-pair', self.cardeditor1.get_text(), - self.cardeditor1.get_text(), - self.cardeditor1.get_pixbuf(), - self.cardeditor1.get_pixbuf(), - self.cardeditor1.get_snd(), self.cardeditor1.get_snd(), - self.cardeditor1.get_speak(), self.cardeditor1.get_speak() - ) + self.emit('update-pair', self.cardeditor1.get_text(), + self.cardeditor1.get_text(), + self.cardeditor1.get_pixbuf(), + self.cardeditor1.get_pixbuf(), + self.cardeditor1.get_snd(), + self.cardeditor1.get_snd(), + self.cardeditor1.get_speak(), + self.cardeditor1.get_speak()) else: - self.emit('update-pair', self.cardeditor1.get_text(), - self.cardeditor2.get_text(), - self.cardeditor1.get_pixbuf(), - self.cardeditor2.get_pixbuf(), - self.cardeditor1.get_snd(), self.cardeditor2.get_snd(), - self.cardeditor1.get_speak(), self.cardeditor2.get_speak() - ) + self.emit('update-pair', self.cardeditor1.get_text(), + self.cardeditor2.get_text(), + self.cardeditor1.get_pixbuf(), + self.cardeditor2.get_pixbuf(), + self.cardeditor1.get_snd(), + self.cardeditor2.get_snd(), + self.cardeditor1.get_speak(), + self.cardeditor2.get_speak()) self.clean(None) def pair_selected(self, widget, selected, newtext1, newtext2, aimg, bimg, @@ -215,8 +217,8 @@ class CreateCardPanel(gtk.EventBox): def _update_buttom_status(self): if not self.equal_pairs: if (self._card1_has_text or self._card1_has_picture \ - or self._card1_has_sound) and (self._card2_has_text - or self._card2_has_picture + or self._card1_has_sound) and (self._card2_has_text + or self._card2_has_picture or self._card2_has_sound): self._addbutton.set_sensitive(True) self._updatebutton.set_sensitive(self._updatebutton_sensitive) @@ -232,6 +234,11 @@ class CreateCardPanel(gtk.EventBox): self._addbutton.set_sensitive(False) self._updatebutton.set_sensitive(False) + def set_temp_folder(self, temp_folder): + self.cardeditor1.temp_folder = temp_folder + self.cardeditor2.temp_folder = temp_folder + + class CardEditor(gtk.EventBox): __gsignals__ = { @@ -245,8 +252,7 @@ class CardEditor(gtk.EventBox): self.snd = None - tmp_root = join(environ['SUGAR_ACTIVITY_ROOT'], 'instance') - self.temp_folder = tempfile.mkdtemp(dir=tmp_root) + self.temp_folder = None box = gtk.VBox() box.props.spacing = theme.PAD @@ -257,11 +263,11 @@ class CardEditor(gtk.EventBox): box.pack_start(self.previewlabel, False) self.card = svgcard.SvgCard(-1, - { 'front_text' : { 'card_text' : '', - 'text_color' : '#ffffff' }, - 'front_border': { 'fill_color' : '#4c4d4f', - 'stroke_color' : '#ffffff', - 'opacity' : '1' } }, + {'front_text': {'card_text': '', + 'text_color': '#ffffff'}, + 'front_border': {'fill_color': '#4c4d4f', + 'stroke_color': '#ffffff', + 'opacity': '1'}}, None, theme.PAIR_SIZE, 1, '#c0c0c0') self.card.flip() card_align = gtk.Alignment(.5, .5, 0, 0) @@ -300,16 +306,7 @@ class CardEditor(gtk.EventBox): else: self.usespeak = None - toolbar_box = CanvasRoundBox( - radius=8, - border=2, - border_color=style.COLOR_BUTTON_GREY.get_int(), - background_color=style.COLOR_PANEL_GREY.get_int()) - toolbar_box.append(hippo.CanvasWidget(widget=toolbar), - hippo.PACK_EXPAND) - toolbar_canvas = hippo.Canvas() - toolbar_canvas.set_root(toolbar_box) - box.pack_start(toolbar_canvas, False) + box.pack_start(toolbar, False) self.add(box) @@ -360,8 +357,8 @@ class CardEditor(gtk.EventBox): self.set_speak(None) pixbuf_t = gtk.gdk.pixbuf_new_from_file_at_size( - index, theme.PAIR_SIZE - theme.PAD*2, - theme.PAIR_SIZE - theme.PAD*2) + index, theme.PAIR_SIZE - theme.PAD * 2, + theme.PAIR_SIZE - theme.PAD * 2) size = max(pixbuf_t.get_width(), pixbuf_t.get_height()) pixbuf_z = gtk.gdk.pixbuf_new_from_file_at_size( 'images/white.png', size, size) @@ -369,7 +366,7 @@ class CardEditor(gtk.EventBox): pixbuf_t.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255) self.card.set_pixbuf(pixbuf_z) - _logger.debug('Picture Loaded: '+index) + _logger.debug('Picture Loaded: ' + index) self.emit('has-picture', True) del pixbuf_t del pixbuf_z @@ -384,7 +381,7 @@ class CardEditor(gtk.EventBox): self.set_speak(None) - dst = join(self.temp_folder, basename(index)) + dst = join(self.temp_folder, 'sounds', basename(index)) shutil.copy(index, dst) self.set_snd(dst) icon_theme = gtk.icon_theme_get_default() @@ -392,7 +389,7 @@ class CardEditor(gtk.EventBox): style.XLARGE_ICON_SIZE, 0) self.card.set_pixbuf(pixbuf_t) self.emit('has-sound', True) - _logger.debug('Audio Loaded: '+dst) + _logger.debug('Audio Loaded: ' + dst) chooser.pick(parent=self.get_toplevel(), what=chooser.AUDIO, @@ -429,6 +426,7 @@ class CardEditor(gtk.EventBox): self.usespeak.props.active = False self.usespeak.palette.face.shut_up() + class SpeakPalette(Palette): def __init__(self, editor): Palette.__init__(self, _('Pronounce text during tile flip')) |