如何嵌入Evince?

时间:2010-09-09 00:03:30

标签: python c gnome

我正在尝试在Python和C程序中嵌入Evince(libevview-2.30),但它不起作用。我正在使用Ubuntu Lucid。这是我的C代码:

#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;
}

这是我的Python代码:

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()

两个程序都给出相同的结果 - 一个空窗口。有什么问题?

1 个答案:

答案 0 :(得分:2)

我已经弄清楚了。您需要将EvView小部件放在ScrolledWindow小部件中。