Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 245f38606492725a4a4462569dc0614dcccf2639

  • avatar
  • Lucian
  • Mon Jul 19 09:40:30 EDT 2010
First experiments with using evince for inline PDF viewing.
pdfview.py
(45 / 0)
  
1# Copyright (C) 2010, Lucian Branescu Mihaila
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
17import gtk
18import evince
19
20def get_view(uri='file:///home/lucian/test.pdf'):
21 view = evince.View()
22
23 try: # assuming evince 2.30
24 doc = evince.document_factory_get_document(uri)
25 model = evince.DocumentModel()
26 model.set_document(doc)
27
28 view.set_model(model)
29 except AttributeError: # we're probably on evince 2.28 or older
30 doc = evince.factory_get_document(uri)
31 view.set_document(doc)
32
33 return view
34
35win = gtk.Window(gtk.WINDOW_TOPLEVEL)
36win.set_size_request(400, 300)
37win.connect('destroy', gtk.main_quit)
38win.show()
39
40v = get_view()
41
42win.add(v)
43v.show()
44
45gtk.main()