Example #1
0
    def update_from_media(self, image_file):
        assert os.path.exists(image_file)

        logging.debug("Displaying image '%s'" % (image_file))

        pixbuf = utils.scale_pixbuf(gtk.gdk.pixbuf_new_from_file(image_file),
                                    self.width, self.height)

        logging.debug("width: %d, height: %d" % (
                pixbuf.get_width(), pixbuf.get_height()))

        self.image.set_from_pixbuf(None)
        self.image.set_from_pixbuf(pixbuf)
Example #2
0
    def update_from_media(self, pdf_file):
        self.convert_pdfs()

        try:
            png_file = pdf_file[:-4] + ".png"

            # Skip PDFs that failed to convert to PNGs successfully
            if not os.path.exists(png_file):
                return

            pixbuf = utils.scale_pixbuf(gtk.gdk.pixbuf_new_from_file(png_file),
                                        self.width, self.height)

            logging.debug("Opening PNG convert of PDF %s'" % (pdf_file))
            self.pdf_image.set_from_pixbuf(None)
            self.pdf_image.set_from_pixbuf(pixbuf)
        except Exception, e:
            logging.error("Converted PNG for '%s' is corrupted or inaccessible"
                          % (pdf_file))
            logging.exception(e)