关闭

cikada-0.1---一款linux 平台阅读器移植记录

775人阅读 评论(1) 收藏 举报

由于要在一款嵌入式平台上移植一款pdf阅读器,所以在网上想找找有没有开源的,然后找来研究研究,所以遇到cikada.

由于cikada所用的clutter版本比较高,而我现在用的才是clutter-1.0.

而且我是用命令行编译的,用它自带的编译方法编译不通过.

所以有以下几个地方要修改:

一.在cikada.c文件中:

以下代码要注释掉:

bindtextdomain (PACKAGE, LOCALEDIR);
bind_textdomain_codeset (PACKAGE, "UTF-8");
textdomain (PACKAGE);
        
context = g_option_context_new (_("- Cikada is a presentation tool for PDF slides"));
g_option_context_add_main_entries (context, _ckd_entries, PACKAGE);

if (!g_option_context_parse (context, &argc, &argv, NULL))
    return -1;
if (argv[1] == NULL) {
    g_print (_("You should input PDF file name!\n"));
    return -1;
}

二.在ckd-page.c中,

修改以下几处:

1.将static gboolean ckd_page_render (ClutterCairoTexture *actor, cairo_t *cr, gpointer user_data)函数删除. 相应的,将static void ckd_page_set_property (GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec)函数中的g_signal_connect (priv->cairo_texture, "draw", G_CALLBACK (ckd_page_render), self);这一句删除

因为在clutter-1.0中,clutter_cairo_texture还没有draw信号.

2.在static void ckd_page_set_property (GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec)函数中,case PROP_PDF_PAGE: 代码块中,有w, h只定义,但没有取得数据,而且在priv->cairo_texture = clutter_cairo_texture_new (priv->quality * w, priv->quality * h);中就使用了.此处存疑.
作以下修改:

在priv->cairo_texture = clutter_cairo_texture_new (w, h);語句前,添加

w = priv->pdf_width;
h = priv->pdf_height;

3.在static void ckd_page_paint (ClutterActor *actor)中,在clutter_actor_paint (priv->cairo_texture);这条語句后面添加以下代码:

guint w, h;
clutter_cairo_texture_clear ( CLUTTER_CAIRO_TEXTURE (priv->cairo_texture));
cairo_t *cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (priv->cairo_texture));
w = priv->pdf_width * priv->quality;
h = priv->pdf_height * priv->quality;
cairo_rectangle (cr, 0, 0, w, h);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
cairo_fill (cr);
cairo_scale (cr, priv->quality, priv->quality);
poppler_page_render (priv->pdf_page, cr);
cairo_destroy(cr);

4.为了让cairo_texture自绘,要实现actor_class的map和unmap函数.故在ckd-page.c文件中添加以下两个函数实现:

static void
ckd_page_map (ClutterActor *actor)
{
	g_debug ("Enter ckd_page_map.");
	CkdPagePriv *priv = CKD_PAGE_GET_PRIVATE (actor);

	CLUTTER_ACTOR_CLASS (ckd_page_parent_class)->map(actor);

	if (CLUTTER_IS_ACTOR (priv->cairo_texture))
		clutter_actor_map (priv->cairo_texture);
}

static void
ckd_page_unmap (ClutterActor *actor)
{
	g_debug ("Enter ckd_page_unmap.");
	CkdPagePriv *priv = CKD_PAGE_GET_PRIVATE (actor);

	if (CLUTTER_IS_ACTOR (priv->cairo_texture))
		clutter_actor_unmap (priv->cairo_texture);

	CLUTTER_ACTOR_CLASS (ckd_page_parent_class)->unmap(actor);
}

5.在static void ckd_page_class_init (CkdPageClass *klass)函数中,map和unmap函数指针赋于它它的父类虚函数.

故在actor_class->allocate = ckd_page_allocate;語句后面添加以下两句:

actor_class->map = ckd_page_map;
actor_class->unmap = ckd_page_unmap;


作如上修改后,就可以使用命令行编译运行了:

gcc ckd-page.c ckd-slides.c ckd-page-fade.c ckd-page-manager.c cikada.c -o cikada `pkg-config --cflags --libs clutter-1.0 poppler-glib`



致谢:http://garfileo.is-programmer.com/tag/clutter

原作者的代码也可以此网站上找到下载链接.

如有疑問联系:huangxiaobo.routon@gmail.com

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:216931次
    • 积分:2832
    • 等级:
    • 排名:第12610名
    • 原创:54篇
    • 转载:33篇
    • 译文:10篇
    • 评论:28条
    文章分类
    最新评论