Gentoo Archives: gentoo-commits

From: "Marien Zwart (marienz)" <marienz@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-text/pdfshuffler/files: pdfshuffler-poppler-0.18.patch
Date: Wed, 29 Feb 2012 23:54:34
Message-Id: 20120229235421.46C322004C@flycatcher.gentoo.org
marienz     12/02/29 23:54:21

  Added:                pdfshuffler-poppler-0.18.patch
  Log:
  Add a patch to work with poppler >= 0.18, based on a patch by Rafał Mużyło in bug #390607.
  
  (Portage version: 2.2.0_alpha89/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  app-text/pdfshuffler/files/pdfshuffler-poppler-0.18.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/pdfshuffler/files/pdfshuffler-poppler-0.18.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/pdfshuffler/files/pdfshuffler-poppler-0.18.patch?rev=1.1&content-type=text/plain

Index: pdfshuffler-poppler-0.18.patch
===================================================================
Stop using render_to_pixbuf, removed from Poppler 0.18.

Instead draw to a gdk Pixmap, then get a Pixbuf from that.

A more complete fix (dropping Pixmap/Pixbuf usage) is in upstream svn,
but that is too large a change for us to take.

Based on a patch from Rafał Mużyło in gentoo bug #390607.
--- pdfshuffler
+++ pdfshuffler
@@ -982,9 +982,15 @@
             pix_w, pix_h = page.get_size()
             pix_w = int(pix_w * self.scale)
             pix_h = int(pix_h * self.scale)
-            thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
-                                       8, pix_w , pix_h)
-            page.render_to_pixbuf(0,0,pix_w,pix_h,self.scale,0,thumbnail)
+            pixmap = gtk.gdk.Pixmap(None, pix_w, pix_h, 24)
+            cr = pixmap.cairo_create()
+            # The pixmap data is not initialized, so paint it white first:
+            cr.set_source_rgb(1, 1, 1)
+            cr.paint()
+            cr.scale(self.scale, self.scale)
+            page.render(cr)
+            thumbnail = gtk.gdk.pixbuf_get_from_drawable(
+                None, pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, pix_w, pix_h)
             rotation = (-rotation) % 360
             rotation = ((rotation + 45) / 90) * 90
             thumbnail = thumbnail.rotate_simple(rotation)
@@ -1003,11 +1009,13 @@
                 pix_w = thumbnail.get_width()
                 pix_h = thumbnail.get_height()
         except:
+            import traceback
+            traceback.print_exc()
             pix_w = self.default_width
             pix_h = pix_w
             thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
                                        8, pix_w, pix_h)
-            pixbuf.fill(0xffffffff)
+            thumbnail.fill(0xffffffff)
 
         #add border
         thickness = 3