def __init__(self, application, pil_image=None, resolution=constants.DEFAULT_SCAN_RESOLUTION, page_size=constants.DEFAULT_PAGE_SIZE): """ Constructs the PageModel. @type pil_image: a PIL image @param pil_image: The image data for this page. @type page_size: str @param page_size: The name of the page size this image should be saved in. @type resolution: int @param resolution: The dpi that the page was scanned at. """ self.application = application Model.__init__(self) self.log = logging.getLogger(self.__class__.__name__) self.resolution = resolution self.page_size = page_size if pil_image: self._raw_pil_image = pil_image self._update_pixbuf() self._update_thumbnail_pixbuf() self.register_observer(self) # TODO: Wtf am I doing here, solves a bug, but why? self.accepts_spurious_change = lambda : True self.log.debug('Created.')
def __init__(self, application): """ Constructs the PreferencesModel. """ Model.__init__(self) self.application = application self.log = logging.getLogger(self.__class__.__name__) self.log.debug('Created.')
def __init__(self, application): """ Constructs the MainModel, as well as necessary sub-models. """ self.application = application Model.__init__(self) self.log = logging.getLogger(self.__class__.__name__) self.log.debug('Created.')
def __notify_observer__(self, observer, method, *args, **kwargs): """This makes a call either through the gtk.idle list or a direct method call depending whether the caller's thread is different from the observer's thread""" assert self.__observer_threads.has_key(observer) if _threading.currentThread() == self.__observer_threads[observer]: # standard call return Model.__notify_observer__(self, observer, method, *args, **kwargs) # multi-threading call gobject.idle_add(self.__idle_callback, observer, method, args, kwargs) return
def unregister_observer(self, observer): Model.unregister_observer(self, observer) del self.__observer_threads[observer] return
def register_observer(self, observer): Model.register_observer(self, observer) self.__observer_threads[observer] = _threading.currentThread() return
def __init__(self): Model.__init__(self) self.__observer_threads = {} self._prop_lock = _threading.Lock() return