Merge lp:~sil/lernid/poppler-gonna-make-you-poppler into lp:lernid

Proposed by Stuart Langridge
Status: Merged
Merged at revision: not available
Proposed branch: lp:~sil/lernid/poppler-gonna-make-you-poppler
Merge into: lp:lernid
Diff against target: 38 lines (+13/-9)
1 file modified
bin/lernid (+13/-9)
To merge this branch: bzr merge lp:~sil/lernid/poppler-gonna-make-you-poppler
Reviewer Review Type Date Requested Status
Jono Bacon Pending
Review via email: mp+16822@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) wrote :

Use libpoppler instead of shelling out to Ghostscript, because we are a Python Gnome application and not, for example, something written with Athena in 1987

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/lernid'
2--- bin/lernid 2009-12-28 11:35:14 +0000
3+++ bin/lernid 2010-01-04 23:55:20 +0000
4@@ -34,6 +34,8 @@
5 import subprocess
6 import re
7 import tempfile
8+import poppler
9+from gtk.gdk import Pixbuf, COLORSPACE_RGB
10
11 # Check if we are working in the source tree or from the installed
12 # package and mangle the python path accordingly
13@@ -180,15 +182,17 @@
14 self.connect_dialog(None)
15
16 def change_slide(self, slidenumber):
17- firstpage = "-dFirstPage=" + str(slidenumber)
18- lastpage = "-dLastPage=" + str(slidenumber)
19- outputfile = "-sOutputFile=" + self.tempslide.name
20- slidedeck = os.path.join(self.lerniddatafolder, "slides.pdf")
21-
22- print 'output file', outputfile
23- subprocess.Popen(['gs', '-dNOPAUSE', firstpage, lastpage, '-dBATCH', '-sDEVICE=jpeg', outputfile, '-r200', slidedeck]).wait()
24-
25- self.master_slide = gtk.gdk.pixbuf_new_from_file(self.tempslide.name)
26+ try:
27+ slide_url = "file://%s/slides.pdf" % os.path.realpath(self.lerniddatafolder)
28+ pdf = poppler.document_new_from_file(slide_url, None)
29+ pg = pdf.get_page(int(slidenumber) - 1)
30+ w, h = pg.get_size()
31+ pb = Pixbuf(COLORSPACE_RGB,False, 8, int(w), int(h))
32+ pg.render_to_pixbuf(0,0,8,11,1,0,pb)
33+ except:
34+ logging.debug("Something went wrong when loading slide %s" % slidenumber)
35+ return
36+ self.master_slide = pb
37 self.slide_resize()
38 self.tabs.set_current_page(self.TAB_SCHEDULE)
39

Subscribers

People subscribed via source and target branches