Beispiel #1
0
    def get_items_from_dir(self):
        # Obtain the directories first:
        scanner = FileScanner()
        dirs = scanner.get_dirs_from_dir(self.directory)

        for dir_ in sorted(dirs, 
                           key=lambda dir_: os.stat(dir_).st_mtime, 
                           reverse=True):
            if self.filter_ and not self.filter_.lower() in dir_.lower():
                continue
            yield DirectoryItem(dir_, self.thumb_size/2)
    
        # Now the files:
        files = scanner.get_files_from_dir(self.directory)
        
        file_manager = FileManager()
        file_manager.set_files(files)
        file_manager.sort_by_date(True)
        file_manager.go_first()

        for _ in range(file_manager.get_list_length()):
            current_file = file_manager.get_current_file()
            if not self.filter_ or self.filter_.lower() in current_file.get_basename().lower():
                yield ImageItem(current_file, self.thumb_size/2)
            file_manager.go_forward(1)

        self.items_count = (len(dirs), len(files))
Beispiel #2
0
    def get_pixbuf(self):
        scanner = FileScanner()
        files = scanner.get_files_from_dir(self.directory)

        if files:
            file_manager = FileManager(on_list_modified=lambda: None)
            file_manager.set_files(files)
            file_manager.sort_by_date(True)
            file_manager.go_first()
            return self.get_mixed_thumbnail(file_manager.get_current_file(), self.default_thumbnail_size)
        else:
            dir_icon = GTKIconImage(gtk.STOCK_DIRECTORY, self.default_gtk_icon_size)
            return dir_icon.get_pixbuf()