
#include <stdlib.h> #include <stdio.h> #include <clutter/clutter.h> #include <webkit/webkit.h> static WebkitAdjustment *hadj, *vadj; static gboolean on_button_release (ClutterActor *rect, ClutterEvent *event, gpointer data) { ClutterTimeline *timeline = (ClutterTimeline*) data; gint x = 0, y = 0; clutter_event_get_coords (event, &x, &y); clutter_timeline_start (timeline); return TRUE; } int main (int argc, char *argv[]) { guint stageWidth, stageHeight, stage_depth; guint buttonWidth, buttonHeight; gfloat fovy, aspect, zNear, zFar; ClutterActor *stage; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_color = { 0x33, 0x22, 0x22, 0xff }; WebKitWebView *hand; if (argc < 2) return -1; clutter_init (&argc, &argv); hadj = webkit_adjustment_new (0,0,0,0,0,0); vadj = webkit_adjustment_new (0,0,0,0,0,0); hand = webkit_web_view_new (640, 480); webkit_web_view_set_scroll_adjustments (hand, hadj, vadj); stage = clutter_stage_get_default(); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_fog (CLUTTER_STAGE (stage), 1.0, 10, -50); clutter_stage_get_perspective (CLUTTER_STAGE (stage), &fovy, &aspect, &zNear, &zFar); clutter_actor_get_size (CLUTTER_ACTOR (stage), &stageWidth, &stageHeight); stage_depth = zFar; buttonWidth = stageWidth * 3 / 4; buttonHeight = stageHeight * 3 / 4; ClutterTimeline *timeline = clutter_timeline_new (60, 60); ClutterBehaviour *rotY = clutter_behaviour_rotate_new ( clutter_alpha_new_full(timeline, CLUTTER_ALPHA_RAMP_INC, NULL, NULL), CLUTTER_Y_AXIS, CLUTTER_ROTATE_CW, 0, 180); clutter_actor_set_anchor_point (hand, buttonWidth/2, buttonHeight/2); clutter_actor_set_size (hand, buttonWidth, buttonHeight); clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand); webkit_web_view_open (hand, argv[1]); clutter_actor_set_position (hand, stageWidth/2, stageHeight/2); clutter_behaviour_apply (rotY, hand); clutter_stage_set_key_focus (stage, hand); clutter_actor_set_reactive (hand, TRUE); g_signal_connect (hand, "button-release-event", G_CALLBACK (on_button_release), timeline); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }由上可見,除了作必要的初始化、加上 WebKit 這個 Clutter Actor 物件外,就是加上對應於「按鈕」的 callback,這裡指的「按鈕」,就是 WebKit 網頁輸出的畫面,拜 Clutter 簡潔的設計所賜,就這樣完成了 :-)
jserv兄, 您好
从if (argc < 2) return -1; 可以看出需要2个或2个以上参数, 请问执行test-webkit2要带哪些参数, 意义是什么呢?
我执行test-webkit2 0 0之后能看到一张能翻转的空白页, 什么内容都没有, 能指点一下哪里出问题了吗?
可秀中文嗎?...試過會有亂碼
由 legis 發表於 November 6, 2008 07:32 PM