Exemplo n.º 1
0
    def _load_audio(self, widget):
        def load(jobject):
            origin_path = jobject.file_path
            self.set_speak(None)
            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')
            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)

        chooser.pick(parent=self.get_toplevel(),
                     what=chooser.AUDIO,
                     cb=load)
    def _load_image(self, widget):
        def load(jobject):
            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(destination_path)
            logging.debug('Picture Loaded: %s', destination_path)
            self.emit('has-picture', True)

        chooser.pick(parent=self.get_toplevel(), what=chooser.IMAGE, cb=load)
Exemplo n.º 3
0
    def _load_image(self, widget):
        def load(jobject):
            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(destination_path)
            logging.debug('Picture Loaded: %s', destination_path)
            self.emit('has-picture', True)

        chooser.pick(parent=self.get_toplevel(),
                     what=chooser.IMAGE,
                     cb=load)
Exemplo n.º 4
0
    def _load_audio(self, widget):
        def load(jobject):
            index = jobject.file_path

            self.set_speak(None)

            dst = join(self.temp_folder, basename(index))
            shutil.copy(index, dst)
            self.set_snd(dst)
            icon_theme = gtk.icon_theme_get_default()
            pixbuf_t = icon_theme.load_icon("audio-x-generic",
                                            style.XLARGE_ICON_SIZE, 0)
            self.card.set_pixbuf(pixbuf_t)
            self.emit('has-sound', True)
            _logger.debug('Audio Loaded: '+dst)

        chooser.pick(parent=self.get_toplevel(),
                     what=chooser.AUDIO,
                     cb=load)
Exemplo n.º 5
0
    def _load_image(self, widget):
        def load(jobject):
            index = jobject.file_path

            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)
            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)
            pixbuf_t.composite(pixbuf_z, 0, 0, pixbuf_t.get_width(),
                               pixbuf_t.get_height(), 0, 0, 1, 1,
                               gtk.gdk.INTERP_BILINEAR, 255)
            self.card.set_pixbuf(pixbuf_z)
            _logger.debug('Picture Loaded: '+index)
            self.emit('has-picture', True)
            del pixbuf_t
            del pixbuf_z

        chooser.pick(parent=self.get_toplevel(),
                     what=chooser.IMAGE,
                     cb=load)
Exemplo n.º 6
0
    def _image_cb(self, button):
        def cb(object):
            logging.debug('ObjectChooser: %r' % object)
            self._abiword_canvas.insert_image(object.file_path, True)

        chooser.pick(what=chooser.IMAGE, cb=cb)
Exemplo n.º 7
0
 def _image_cb(self, button):
     def cb(object):
         logging.debug('ObjectChooser: %r' % object)
         self._abiword_canvas.insert_image(object.file_path, True)
     chooser.pick(what=chooser.IMAGE, cb=cb)