Пример #1
0
    def next_photo(self, *_args):
        """Changes to the next photo."""
        reload_config()
        croot = config.get('collection.dir')
        if not self.wallpaper_list:
            self.wallpaper_list = glob.glob(
                os.path.join(croot, '*', '*.jpg'))
            png_images = glob.glob(
                os.path.join(croot, '*', '*.png'))
            self.wallpaper_list.extend(png_images)
            random.shuffle(self.wallpaper_list)
        if self.wallpaper_list:
            self.last_rotate = time.time()-15 # to ensure next time...
            wallpaper = self.wallpaper_list.pop()

            image_file = os.path.join(croot, wallpaper)
            dirname, base = os.path.split(image_file)
            basename, _unused_ext = os.path.splitext(base)
            self.info_file = os.path.join(dirname, basename)+'.inf'
            self.image_info = infofile.parse_info_file(self.info_file)
            self.image_file = image_file
            title = self.image_info.get('title', basename)
            set_wallpaper(image_file, title)
            album = self.image_info.get('albumTitle', dirname)
            self.set_tooltip_for_photo('%s - %s' % (title, album))
Пример #2
0
    def load_collection(self, images, monitor_dir=None):
        """Loads a list of images into the photo browser."""
        model = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf,
                              gobject.TYPE_PYOBJECT)

        image_list = []
        for image in images:
            dirname, filename = os.path.split(image)
            basename, ext = os.path.splitext(filename)
            thumb = os.path.join(dirname, '.thumbs',
                                 basename + '.thumbnail' + ext)
            info_file = os.path.join(dirname, basename) + '.inf'
            inf = infofile.parse_info_file(info_file)
            title = inf.get('title', basename)
            album = inf.get('albumTitle', dirname)
            credit = inf.get('credit', _('Not available'))
            tags = inf.get('tags', '')

            title = html_escape(title)
            album = html_escape(album)
            credit = html_escape(credit)
            tags = html_escape(tags)

            data = dict(title=title,
                        filename=image,
                        thumb=thumb,
                        inf=inf,
                        info_file=info_file,
                        album=album,
                        tags=tags,
                        file_time=os.path.getctime(image),
                        credit=credit)

            if len(title) > 24:
                title = title[:21] + '...'
            if 0 <= time.time() - os.path.getmtime(image) < 24 * 3600:
                title = _('<b>*New* %s</b>') % title
            position = model.append((title, EMPTY_PICTURE, data))
            image_list.append(dict(position=position, data=data))
        old_model = self.iconview.get_model()
        if old_model is not None:
            old_model.clear()
        self.sort_photos(model)
        self.iconview.set_model(model)
        gobject.idle_add(
            ThumbLoader(self.iconview, model, reversed(image_list)))
        self.on_iconview_handle_selection_changed(self.iconview)
        if gnomevfs:
            if self.collection_monitor['monitor'] is not None:
                gobject.idle_add(gnomevfs.monitor_cancel,
                                 self.collection_monitor['monitor'])
                self.collection_monitor = dict(monitor=None, dir=None)
            if monitor_dir:
                self.collection_monitor['dir'] = monitor_dir
                self.collection_monitor['monitor'] = gnomevfs.monitor_add(
                    monitor_dir, gnomevfs.MONITOR_DIRECTORY,
                    self.collection_directory_changed)
        gc.collect()
Пример #3
0
    def next_photo(self, *_args):
        """Changes to the next photo."""
        reload_config()
        croot = config.get('collection.dir')
        if not self.wallpaper_list:
            self.wallpaper_list = glob.glob(os.path.join(croot, '*', '*.jpg'))
            png_images = glob.glob(os.path.join(croot, '*', '*.png'))
            self.wallpaper_list.extend(png_images)
            random.shuffle(self.wallpaper_list)
        if self.wallpaper_list:
            self.last_rotate = time.time() - 15  # to ensure next time...
            wallpaper = self.wallpaper_list.pop()

            image_file = os.path.join(croot, wallpaper)
            set_wallpaper(image_file)

            dirname, base = os.path.split(image_file)
            basename, _unused_ext = os.path.splitext(base)
            self.info_file = os.path.join(dirname, basename) + '.inf'
            self.image_info = infofile.parse_info_file(self.info_file)
            self.image_file = image_file
            title = self.image_info.get('title', basename)
            album = self.image_info.get('albumTitle', dirname)
            self.set_tooltip_for_photo('%s - %s' % (title, album))
Пример #4
0
    def load_collection(self, images, monitor_dir=None):
        """Loads a list of images into the photo browser."""
        model = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf,
                              gobject.TYPE_PYOBJECT)

        image_list = []
        for image in images:
            dirname, filename = os.path.split(image)
            basename, ext = os.path.splitext(filename)
            thumb = os.path.join(dirname,
                            '.thumbs', basename+'.thumbnail'+ext)
            info_file = os.path.join(dirname, basename) + '.inf'
            inf = infofile.parse_info_file(info_file)
            title = inf.get('title', basename)
            album = inf.get('albumTitle', dirname)
            credit = inf.get('credit', _('Not available'))
            tags = inf.get('tags', '')

            title = html_escape(title)
            album = html_escape(album)
            credit = html_escape(credit)
            tags = html_escape(tags)


            data = dict(title=title,
                        filename=image,
                        thumb=thumb,
                        inf = inf,
                        info_file = info_file,
                        album = album,
                        tags = tags,
                        file_time = os.path.getctime(image),
                        credit = credit)

            if len(title)>24:
                title = title[:21] + '...'
            if 0 <= time.time() - os.path.getmtime(image) < 24*3600:
                title = _('<b>*New* %s</b>') % title
            position = model.append((title, EMPTY_PICTURE, data))
            image_list.append(dict(
                position=position,
                data=data))
        old_model = self.iconview.get_model()
        if old_model is not None:
            old_model.clear()
        self.sort_photos(model)
        self.iconview.set_model(model)
        gobject.idle_add(ThumbLoader(self.iconview, model,
                         reversed(image_list)))
        self.on_iconview_handle_selection_changed(self.iconview)
        if gnomevfs:
            if self.collection_monitor['monitor'] is not None:
                gobject.idle_add(gnomevfs.monitor_cancel,
                                 self.collection_monitor['monitor'])
                self.collection_monitor = dict(monitor=None, dir=None)
            if monitor_dir:
                self.collection_monitor['dir'] = monitor_dir
                self.collection_monitor['monitor'] = gnomevfs.monitor_add(
                    monitor_dir,
                    gnomevfs.MONITOR_DIRECTORY,
                    self.collection_directory_changed)
        gc.collect()