tags:

views:

41

answers:

1

I'm trying to make embed Evince (libevview-2.30) in a Python and a C program, but it doesn't work. I'm using Ubuntu Lucid. Here is my C code:

#include <gtk/gtk.h>
#include <evince/2.30/evince-view.h>
#include <evince/2.30/evince-document.h>

int main(int argc, char *argv[]){
    GtkWidget *window;
    EvDocument *document;
    EvDocumentModel *docmodel;
    GtkWidget *view;

    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    document = EV_DOCUMENT(ev_document_factory_get_document("file:///home/user/review.pdf", NULL));
    docmodel = EV_DOCUMENT_MODEL(ev_document_model_new_with_document(EV_DOCUMENT(document)));
    view = ev_view_new();
    ev_view_set_model(EV_VIEW(view), EV_DOCUMENT_MODEL(docmodel));
    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}

And here is my Python code:

import gtk
import evince

window = gtk.Window()
window.show()

view = evince.View()
document = evince.document_factory_get_document('file:///home/user/review.pdf')
model = evince.DocumentModel()
model.set_document(document)
view.set_model(model)

window.add(view)
view.show()
gtk.main()

Both programs give the same results - an empty window. What is wrong?

A: 

I've figured it out. You need to put EvView widget inside a ScrolledWindow widget.

nikmil