2008/4/11, iain <[EMAIL PROTECTED]>:
> attached is the test program I use.
>

hi iain,

Thanks for your kind help.

I made some modifications to be more pretty.  Please refer to the
attachment for details.

Regards,
-jserv
/**
 * Simple application for using WebKit clutter backend.
 * Depends: latest clutter, clutter-cairo, o-hand -webkit branch.
 *
 * Build instructions:
 *   # gcc -o test-webkit \
 *         test-webkit2.c \
 *         `pkg-config --cflags --libs webkit-clutter-1.0 \
 *                                     cairo pangocairo clutter-cairo-0.7`
 * -jserv
 */

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

Reply via email to