After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 639758 - Python bindings for evince are broken in 2.32
Python bindings for evince are broken in 2.32
Status: RESOLVED FIXED
Product: gnome-python-desktop
Classification: Deprecated
Component: evince
2.32.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-01-17 16:32 UTC by Gonzalo Odiard
Modified: 2011-01-26 18:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.15 KB, patch)
2011-01-18 22:17 UTC, Gonzalo Odiard
none Details | Review
New patch with more objects defined (1.72 KB, patch)
2011-01-20 20:04 UTC, Gonzalo Odiard
none Details | Review

Description Gonzalo Odiard 2011-01-17 16:32:15 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.
Comment 1 Gonzalo Odiard 2011-01-18 22:17:34 UTC
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?
Comment 2 José Aliste 2011-01-19 17:50:36 UTC
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
Comment 3 Gonzalo Odiard 2011-01-19 20:13:17 UTC
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.
Comment 4 Gonzalo Odiard 2011-01-20 20:04:30 UTC
Created attachment 178880 [details] [review]
New patch with more objects defined
Comment 5 Gonzalo Odiard 2011-01-20 20:09:03 UTC
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()
Comment 6 Daniel Drake 2011-01-26 11:45:44 UTC
Hi José, any chance of a review of Gonzalo's latest patch? Thanks for your help.
Comment 7 José Aliste 2011-01-26 12:03:57 UTC
Review of attachment 178880 [details] [review]:

Looks good to me. It would be great to have the advice of mantainers.
Comment 8 Gustavo Carneiro 2011-01-26 15:25:51 UTC
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.
Comment 9 Daniel Drake 2011-01-26 15:34:14 UTC
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.
Comment 10 Gustavo Carneiro 2011-01-26 17:14:22 UTC
OK, nevermind.
Comment 11 Daniel Drake 2011-01-26 18:16:43 UTC
Thanks Gustavo, José and Gonzalo! Pushed as fe79fd6f6a6e