Пример #1
0
    def __init__(self, window):

        #: Reference to main window
        self._window = window

        #: Caching thread
        self._thread = mt.ThreadPool(name=self.__class__.__name__)
        self._lock = mt.Lock()
        self._cache_lock = {}

        #: Archive path, if currently opened file is archive
        self._base_path = None
        #: List of image file names, either from extraction or directory
        self._image_files = []
        #: Index of current page
        self._current_image_index = None
        #: Set of images reading for decoding (i.e. already extracted)
        self._available_images = set()
        #: List of pixbufs we want to cache
        self._wanted_pixbufs = []
        #: Pixbuf map from page > Pixbuf
        self._raw_pixbufs = {}
        #: How many pages to keep in cache
        self._cache_pages = prefs['max pages to cache']

        self._window.filehandler.file_available += self._file_available
Пример #2
0
 def page_available(self, page):
     ''' Called whenever a new page becomes available, i.e. the corresponding
     file has been extracted. '''
     log.debug('Page %u is available', page)
     index = page - 1
     assert index not in self._available_images
     self._cache_lock[index] = mt.Lock()
     self._available_images.add(index)
     # Check if we need to cache it.
     if index in self._wanted_pixbufs or -1 == self._cache_pages:
         self._thread.apply_async(self._cache_pixbuf, (index, ))
Пример #3
0
    def __init__(self, uid_column, pixbuf_column, status_column):
        ''' Constructs a new ThumbnailView.
        @param uid_column: index of unique identifer column.
        @param pixbuf_column: index of pixbuf column.
        @param status_column: index of status boolean column
                              (True if pixbuf is not temporary filler)
        '''

        #: Keep track of already generated thumbnails.
        self._uid_column = uid_column
        self._pixbuf_column = pixbuf_column
        self._status_column = status_column

        #: Worker thread
        self._threadpool = mt.ThreadPool(
            name=self.__class__.__name__,
            processes=prefs['max thumbnail threads'] or None)
        self._lock = mt.Lock()
        self._done = set()
        self._taskid = 0