diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-07-17 17:34:13 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-07-17 17:34:13 (GMT) |
commit | 58d9358a635f8c2463bc9fe436b9e5f6288ed030 (patch) | |
tree | 2c3074e5e9909947f677b94d77231362fd413bc0 | |
parent | ebc553b55581cbf8fb9086a635a746c946dceee0 (diff) |
Solve the error adding imges or audio to art4apps games
-rw-r--r-- | activity.py | 4 | ||||
-rw-r--r-- | createcardpanel.py | 48 |
2 files changed, 31 insertions, 21 deletions
diff --git a/activity.py b/activity.py index 7aa2f13..c18e5dc 100644 --- a/activity.py +++ b/activity.py @@ -106,11 +106,12 @@ class MemorizeActivity(Activity): toolbar_box.toolbar.insert(StopButton(self), -1) + self.game = game.MemorizeGame() # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() self.cardlist = cardlist.CardList() - self.createcardpanel = createcardpanel.CreateCardPanel() + self.createcardpanel = createcardpanel.CreateCardPanel(self.game) self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) self.cardlist.connect( @@ -134,7 +135,6 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) - self.game = game.MemorizeGame() self._edit_button.connect('toggled', self._change_mode_bt) diff --git a/createcardpanel.py b/createcardpanel.py index 35a0ead..ba8cb28 100644 --- a/createcardpanel.py +++ b/createcardpanel.py @@ -57,7 +57,7 @@ class CreateCardPanel(Gtk.EventBox): None, []), } - def __init__(self): + def __init__(self, game): def make_label(icon_name, label): label_box = Gtk.VBox() icon = Icon(icon_name=icon_name, @@ -71,7 +71,7 @@ class CreateCardPanel(Gtk.EventBox): return label_box Gtk.EventBox.__init__(self) - + self._game = game self.equal_pairs = False self._updatebutton_sensitive = False self._card1_has_sound = False @@ -107,8 +107,8 @@ class CreateCardPanel(Gtk.EventBox): # Set card editors - self.cardeditor1 = CardEditor(1) - self.cardeditor2 = CardEditor(2) + self.cardeditor1 = CardEditor(self._game, 1) + self.cardeditor2 = CardEditor(self._game, 2) self.clean(None) self.cardeditor1.connect('has-text', self.receive_text_signals) self.cardeditor2.connect('has-text', self.receive_text_signals) @@ -302,9 +302,9 @@ class CardEditor(Gtk.EventBox): [GObject.TYPE_PYOBJECT]), } - def __init__(self, editor_index): + def __init__(self, game, editor_index): Gtk.EventBox.__init__(self) - + self._game = game self.snd = None self.editor_index = editor_index self.temp_folder = None @@ -413,12 +413,15 @@ class CardEditor(Gtk.EventBox): def _load_image(self, widget): def load(jobject): - index = jobject.file_path - dst = join(self.temp_folder, 'images', basename(index)) - shutil.copy(index, dst) + origin_path = jobject.file_path + self._game.model.mark_modified() + self._game.model.create_temp_directories() + destination_path = join(self._game.model.data['pathimg'], + basename(origin_path)) + shutil.copy(origin_path, destination_path) self.set_speak(None) - self.card.set_image_path(dst) - logging.debug('Picture Loaded: ' + dst) + self.card.set_image_path(destination_path) + logging.debug('Picture Loaded: %s', destination_path) self.emit('has-picture', True) chooser.pick(parent=self.get_toplevel(), @@ -427,18 +430,25 @@ class CardEditor(Gtk.EventBox): def _load_audio(self, widget): def load(jobject): - index = jobject.file_path - + origin_path = jobject.file_path self.set_speak(None) - - dst = join(self.temp_folder, 'sounds', basename(index)) - shutil.copy(index, dst) - self.set_snd(dst) + self._game.model.mark_modified() + self._game.model.create_temp_directories() + destination_path = join(self._game.model.data['pathsnd'], + basename(origin_path)) + shutil.copy(origin_path, destination_path) + self.set_snd(destination_path) + logging.debug('Audio Loaded: %s', destination_path) + + # add a icon too sound_icon_path = join(activity.get_bundle_path(), 'icons/sound.svg') - self.card.set_image_path(sound_icon_path) + destination_path = join(self._game.model.data['pathimg'], + 'sound.svg') + shutil.copy(sound_icon_path, destination_path) + + self.card.set_image_path(destination_path) self.emit('has-sound', True) - logging.debug('Audio Loaded: ' + dst) chooser.pick(parent=self.get_toplevel(), what=chooser.AUDIO, |