def setUp(self): self.downloader = SimpleFileDownloader() self.downloader.connect("file-url-reachable", self._cb_image_url_reachable) self.downloader.connect("file-download-complete", self._cb_image_download_complete) self._image_is_reachable = None self._image_downloaded_filename = None if os.path.exists(self.DOWNLOAD_FILENAME): os.unlink(self.DOWNLOAD_FILENAME)
def _download_icon_and_show_when_ready(self, url, pkgname, icon_file_name): LOG.debug("did not find the icon locally, must download %s" % icon_file_name) if url is not None: icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, icon_file_name) image_downloader = SimpleFileDownloader() image_downloader.connect('file-download-complete', self._on_image_download_complete, pkgname) image_downloader.download_file(url, icon_file_path)
def __init__(self): Gtk.OffscreenWindow.__init__(self) self.view = WebKit.WebView() settings = self.view.get_settings() settings.set_property("enable-java-applet", False) settings.set_property("enable-plugins", False) settings.set_property("enable-scripts", False) self.view.set_size_request(-1, ExhibitBanner.MAX_HEIGHT) self.add(self.view) self.show_all() self.loader = SimpleFileDownloader() self.loader.connect("file-download-complete", self.on_download_complete) self.loader.connect("error", self.on_download_error) self.exhibit = None self.view.connect("notify::load-status", self._on_load_status)
def __init__(self, distro, icons): Gtk.VBox.__init__(self) # data self.distro = distro self.icons = icons self.data = ScreenshotData() self.data.connect( "screenshots-available", self._on_screenshots_available) # state tracking self.ready = False self.screenshot_pixbuf = None self.screenshot_available = False self._thumbnail_sigs = [] self._height = 0 # zoom cursor try: zoom_pb = self.icons.load_icon(self.ZOOM_ICON, 22, 0) # FIXME self._zoom_cursor = Gdk.Cursor.new_from_pixbuf( Gdk.Display.get_default(), zoom_pb, 0, 0) # x, y except: self._zoom_cursor = None # convenience class for handling the downloading (or not) of # any screenshot self.loader = SimpleFileDownloader() self.loader.connect( 'error', self._on_screenshot_load_error) self.loader.connect( 'file-url-reachable', self._on_screenshot_query_complete) self.loader.connect( 'file-download-complete', self._on_screenshot_download_complete) self._build_ui() # add cleanup handler to avoid signals after we are destroyed self.connect("destroy", self._on_destroy)
def __init__(self, id_, url, cancellable, gallery): Gtk.Button.__init__(self) self.id_ = id_ def download_complete_cb(loader, path): width, height = ThumbnailGallery.THUMBNAIL_SIZE_CONTRAINTS pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( path, width, height, # width, height constraints True) # respect image proportionality im = Gtk.Image.new_from_pixbuf(pixbuf) self.add(im) self.show_all() loader = SimpleFileDownloader() loader.connect("file-download-complete", download_complete_cb) loader.download_file(url, use_cache=ScreenshotGallery.USE_CACHING) self.connect("draw", self.on_draw)
def _download_icon_and_show_when_ready(self, url, pkgname, icon_file_name): LOG.debug("did not find the icon locally, must download %s" % icon_file_name) def on_image_download_complete(downloader, image_file_path, pkgname): LOG.debug("download for '%s' complete" % image_file_path) pb = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file_path, self.icon_size, self.icon_size) # replace the icon in the icon_cache now that we've got the real # one icon_file = split_icon_ext(os.path.basename(image_file_path)) self.icon_cache[icon_file] = pb self.emit("needs-refresh", pkgname) if url is not None: icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, icon_file_name) image_downloader = SimpleFileDownloader() image_downloader.connect('file-download-complete', on_image_download_complete, pkgname) image_downloader.download_file(url, icon_file_path)