如何嵌入Evince?
我试图在 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()
两个程序给出相同的结果 - 一个空窗口。怎么了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经弄清楚了。您需要将 EvView 小部件放入 ScrolledWindow 小部件内。
I've figured it out. You need to put EvView widget inside a ScrolledWindow widget.