GNOME Bugzilla – Bug 639758
Python bindings for evince are broken in 2.32
Last modified: 2011-01-26 18:16:43 UTC
With old python bindings for evince you can do: import evince import gtk w = gtk.Window() w.show() e = evince.View() w.add(e) e.show() document = evince.factory_get_document('file:///home/tomeu/Desktop/comic.pdf') e.set_document(document) gtk.main() Now I know the evince API has changed, I can see a definition for EvView in evince.defs: (define-function view_new (c-name "ev_view_new") (is-constructor-of "EvView") (return-type "GtkWidget*") ) but I can't use it in python. All this is tested in Fedora 14, the following packages are installed: evince.x86_64 2.32.0-3.fc14 evince-devel.x86_64 2.32.0-3.fc14 evince-libs.x86_64 2.32.0-3.fc14 gnome-python2-evince.x86_64 2.32.0-1.fc14 I am trying to update the Read activity for the Sugar desktop. Is very important for us, have it usable in Fedira 14. I have talked in irc with jaliste, and he asked me to fill this bug.
Created attachment 178674 [details] [review] Proposed patch With this patch I can see the objects in python. Now I can do: import evince import gtk def main(): win = gtk.Window() win.connect('destroy', gtk.main_quit) win.set_default_size(450, 550) view = evince.EvView() win.add(view) doc = evince.document_factory_get_document('file:///home/gonzalo/Desktop/Resume.pdf') model = evince.EvDocumentModel() model.set_document(doc) view.set_model(model) model.set_page(1) view.show_all() win.show_all() gtk.main() if __name__ == '__main__': main() But I can't see the viewer or the document. What I am doing wrong?
Review of attachment 178674 [details] [review]: Just two knitpicks... Btw, I've tried regenerating the .def using the h2def script but for some reason I could not understand, the .def ended up without defining the View and DocumentModel Objects... Since I guess that gnome-python-desktop is going away in 3.0, it maybe makes sense to add this to the .def by hand as Gonzalo propose. ::: evince/evince.defs @@ +2850,3 @@ ) +(define-object EvDocumentModel should be define-object DocumentModel @@ +3584,3 @@ ) +(define-object EvView should be define-object View
This works adding a ScrolledWindow containing the viewer, but I have found other problems with the bindings. I will continue and update the ticket with a more complete patch when ready.
Created attachment 178880 [details] [review] New patch with more objects defined
I have found more objects without definition. With the new patch all the functionality needed to the Read activity is enabled. To test the bindings can use this simple example: import evince import gtk def main(): #evince.init() win = gtk.Window() win.connect('destroy', gtk.main_quit) win.set_default_size(450, 550) scroll = gtk.ScrolledWindow() view = evince.View() win.add(scroll) scroll.add(view) doc = evince.document_factory_get_document('file:///home/gonzalo/Desktop/Resume.pdf') model = evince.DocumentModel() model.set_document(doc) view.set_model(model) win.show_all() gtk.main() if __name__ == '__main__': main()
Hi José, any chance of a review of Gonzalo's latest patch? Thanks for your help.
Review of attachment 178880 [details] [review]: Looks good to me. It would be great to have the advice of mantainers.
Hi. Sorry, I don't have much time right now for GNOME hacking. The patch looks ok in principle; if it builds with the patch, just commit it. But please make sure a new branch for the older GNOME version is created first in GIT.
Thanks, I will double check and commit. I don't quite understand your comment about the branches. This patch is appropriate for master and GNOME 2.32. There is currently no gnome-2.32 branch. I could create one at the same time as committing this to master, but it would (at least for now) point to the same commit.
OK, nevermind.
Thanks Gustavo, José and Gonzalo! Pushed as fe79fd6f6a6e