2006-11-29 Emmanuele Bassi <ebassi@openedhand.com>

* gtk/*
	* configure.ac:
	* Makfile.am: Remove the GTK+ widget from the
	main tree; now Clutter depends just on GLib,
	XLibs, GdkPixbuf and OpenGL.
This commit is contained in:
Emmanuele Bassi 2006-11-29 22:05:33 +00:00
parent 25b8dec464
commit 11a3cabcd6
8 changed files with 8 additions and 530 deletions

View File

@ -1,3 +1,11 @@
2006-11-29 Emmanuele Bassi <ebassi@openedhand.com>
* gtk/*
* configure.ac:
* Makfile.am: Remove the GTK+ widget from the
main tree; now Clutter depends just on GLib,
XLibs, GdkPixbuf and OpenGL.
2006-11-29 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-stage.c: (clutter_stage_realize):

View File

@ -104,17 +104,6 @@ PKG_CHECK_MODULES(CLUTTER_DEPS, [$pkg_modules])
dnl ========================================================================
AC_ARG_ENABLE(gtk,
[AC_HELP_STRING([--enable-gtk], [Buld Gtk+ Clutter widget])],enable_gtk="$enableval",enable_gtk=no)
if test "x$enable_gtk" = "xyes"; then
PKG_CHECK_MODULES(GTK, [gtk+-2.0])
fi
AM_CONDITIONAL(ENABLE_GTK, test x$enable_gtk = xyes)
dnl ========================================================================
if test "x$GCC" = "xyes"; then
GCC_FLAGS="-g -Wall"
fi
@ -143,8 +132,6 @@ fi
AC_SUBST(CLUTTER_DEBUG_CFLAGS)
dnl ========================================================================
dnl = GTK Doc check ========================================================
GTK_DOC_CHECK([1.4])
@ -152,8 +139,6 @@ GTK_DOC_CHECK([1.4])
dnl ========================================================================
AC_SUBST(GCC_FLAGS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
CLUTTER_CFLAGS="$GLX_CLAGS $CLUTTER_DEPS_CFLAGS"
CLUTTER_LIBS="$GLX_LIBS $CLUTTER_DEPS_LIBS"
@ -166,8 +151,6 @@ AC_CONFIG_FILES([
clutter/pango/Makefile
clutter/Makefile
clutter/clutter-version.h
gtk/Makefile
gtk/gtk-clutter.pc
examples/Makefile
doc/Makefile
doc/reference/Makefile
@ -185,7 +168,6 @@ echo " ==================="
echo ""
echo " prefix: ${prefix}"
echo ""
echo " GTK+ Widget: ${enable_gtk}"
echo " Debug level: ${enable_debug}"
echo " Documentation: ${enable_gtk_doc}"
echo ""

View File

@ -1,33 +0,0 @@
pcfiles = gtk-clutter-@CLUTTER_MAJORMINOR@.pc
%-@CLUTTER_MAJORMINOR@.pc: %.pc
cp $< $@
pkgconfig_DATA = $(pcfiles)
pkgconfigdir = $(libdir)/pkgconfig
EXTRA_DIST = gtk-clutter.pc.in
CLEANFILES = $(pcfiles)
INCLUDES = @GCC_FLAGS@ @CLUTTER_CFLAGS@ $(GTK_CFLAGS) -I$(top_srcdir)
lib_LTLIBRARIES = libgtkclutter-@CLUTTER_MAJORMINOR@.la
libgtkclutter_@CLUTTER_MAJORMINOR@_la_SOURCES = gtk-clutter.c
libgtkclutter_@CLUTTER_MAJORMINOR@_la_LIBADD = \
@CLUTTER_LIBS@ $(GTK_LIBS)
libgtkclutter_@CLUTTER_MAJORMINOR@_la_LDFLAGS = @CLUTTER_LT_LDFLAGS@
gtkclutterheadersdir = \
$(includedir)/gtk-clutter-@CLUTTER_MAJORMINOR@/gtk-clutter
gtkclutterheaders_HEADERS = gtk-clutter.h
noinst_PROGRAMS = gtk-clutter-test
gtk_clutter_test_SOURCES = gtk-clutter-test.c
gtk_clutter_test_LDADD = libgtkclutter-@CLUTTER_MAJORMINOR@.la \
$(CLUTTER_LIBS) \
$(GTK_LIBS) \
$(top_builddir)/clutter/libclutter-@CLUTTER_MAJORMINOR@.la
gtk_clutter_test_CFLAGS = $(CLUTTER_CFLAGS) $(GTK_CFLAGS)

View File

@ -1,225 +0,0 @@
#include <gtk/gtk.h>
#include <clutter/clutter.h>
#include <math.h>
#include "gtk-clutter.h"
#define TRAILS 0
#define NHANDS 2
#define WINWIDTH 800
#define WINHEIGHT 800
#define RADIUS 250
typedef struct SuperOH
{
ClutterActor *hand[NHANDS], *bgtex;
ClutterGroup *group;
GdkPixbuf *bgpixb;
} SuperOH;
gboolean fade = FALSE;
/* input handler */
void
input_cb (ClutterStage *stage,
ClutterEvent *event,
gpointer data)
{
if (event->type == CLUTTER_BUTTON_PRESS)
{
ClutterButtonEvent *bev = (ClutterButtonEvent *) event;
ClutterActor *e;
g_print ("*** button press event (button:%d) ***\n",
bev->button);
e = clutter_stage_get_actor_at_pos (stage,
clutter_button_event_x (bev),
clutter_button_event_y (bev));
if (e)
clutter_actor_hide(e);
}
else if (event->type == CLUTTER_KEY_PRESS)
{
ClutterKeyEvent *kev = (ClutterKeyEvent *) event;
g_print ("*** key press event (key:%c) ***\n",
clutter_key_event_symbol (kev));
if (clutter_key_event_symbol (kev) == CLUTTER_q)
clutter_main_quit ();
}
}
/* Timeline handler */
void
frame_cb (ClutterTimeline *timeline,
gint frame_num,
gpointer data)
{
SuperOH *oh = (SuperOH *)data;
gint i;
#if TRAILS
oh->bgpixb = clutter_stage_snapshot (CLUTTER_STAGE (stage),
0, 0,
WINWIDTH,
WINHEIGHT);
clutter_texture_set_pixbuf (CLUTTER_TEXTURE (oh->bgtex), oh->bgpixb);
g_object_unref (G_OBJECT (oh->bgpixb));
g_object_unref (stage);
#endif
/* Rotate everything clockwise about stage center*/
clutter_actor_rotate_z (CLUTTER_ACTOR(oh->group),
frame_num,
WINWIDTH/2,
WINHEIGHT/2);
for (i = 0; i < NHANDS; i++)
{
/* rotate each hand around there centers */
clutter_actor_rotate_z (oh->hand[i],
- 6.0 * frame_num,
clutter_actor_get_width (oh->hand[i])/2,
clutter_actor_get_height (oh->hand[i])/2);
if (fade == TRUE) {
clutter_actor_set_opacity (oh->hand[i], (255 - (frame_num % 255)));
}
}
/*
clutter_actor_rotate_x (CLUTTER_ACTOR(oh->group),
75.0,
WINHEIGHT/2, 0);
*/
}
static void
clickity (GtkButton *button,
gpointer ud)
{
fade = !fade;
}
int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
GtkWidget *window, *clutter;
GtkWidget *label, *button, *vbox;
GdkPixbuf *pixbuf;
SuperOH *oh;
gint i;
clutter_init (&argc, &argv);
gtk_init (&argc, &argv);
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
if (!pixbuf)
g_error("pixbuf load failed");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
clutter = g_object_new (GTK_TYPE_CLUTTER, NULL);
stage = gtk_clutter_get_stage (GTK_CLUTTER (clutter));
gtk_container_add (GTK_CONTAINER (vbox), clutter);
/* Set our stage size */
/* clutter_actor_set_size (stage, WINWIDTH, WINHEIGHT); */
label = gtk_label_new ("This is a label");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("This is a button...clicky");
g_signal_connect (button, "clicked",
G_CALLBACK (clickity), NULL);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
/* and its background color */
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
oh = g_new(SuperOH, 1);
#if TRAILS
oh->bgtex = clutter_texture_new();
clutter_actor_set_size (oh->bgtex, WINWIDTH, WINHEIGHT);
clutter_actor_set_opacity (oh->bgtex, 0x99);
clutter_group_add (CLUTTER_GROUP (stage), oh->bgtex);
#endif
/* create a new group to hold multiple actors in a group */
oh->group = CLUTTER_GROUP (clutter_group_new());
for (i = 0; i < NHANDS; i++)
{
gint x, y, w, h;
#if 1
/* Create a texture from pixbuf, then clone in to same resources */
if (i == 0)
oh->hand[i] = clutter_texture_new_from_pixbuf (pixbuf);
else
oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0]));
#else
ClutterColor colour = { 255, 0, 0, 255 };
oh->hand[i] = clutter_rectangle_new_with_color (&colour);
clutter_actor_set_size (oh->hand[i], 50, 50);
#endif
/* Place around a circle */
w = clutter_actor_get_width (oh->hand[0]);
h = clutter_actor_get_height (oh->hand[0]);
x = WINWIDTH/2 + RADIUS * cos (i * M_PI / (NHANDS/2)) - w/2;
y = WINHEIGHT/2 + RADIUS * sin (i * M_PI / (NHANDS/2)) - h/2;
clutter_actor_set_position (oh->hand[i], x, y);
/* Add to our group group */
clutter_group_add (oh->group, oh->hand[i]);
}
/* Add the group to the stage */
clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR(oh->group));
/* Show everying ( and map window ) */
clutter_group_show_all (oh->group);
g_signal_connect (stage, "button-press-event",
G_CALLBACK (input_cb),
oh);
g_signal_connect (stage, "key-release-event",
G_CALLBACK (input_cb),
oh);
gtk_widget_show_all (window);
/* Create a timeline to manage animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */
g_object_set(timeline, "loop", TRUE, NULL); /* have it loop */
/* fire a callback for frame change */
g_signal_connect(timeline, "new-frame", G_CALLBACK (frame_cb), oh);
/* and start it */
clutter_timeline_start (timeline);
gtk_main();
return 0;
}

View File

@ -1,163 +0,0 @@
/*
* GTK-Clutter.
*
* GTK+ widget for Clutter.
*
* Authored By Iain Holmes <iain@openedhand.com>
*
* Copyright (C) 2006 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:gtk-clutter
* @short_description: GTK+ widget displaying a #ClutterStage.
*
* #GtkClutter is a GTK+ widget, derived from #GtkDrawingArea that contains a
* #ClutterStage, allowing it to be used in a GTK+ based program like any
* normal GTK+ widget.
*/
#include "config.h"
#include <gdk/gdkx.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkwidget.h>
#include <clutter/clutter-main.h>
#include <clutter/clutter-stage.h>
#include "gtk-clutter.h"
#define GTK_CLUTTER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CLUTTER, GtkClutterPrivate))
struct _GtkClutterPrivate {
ClutterActor *stage;
};
static GtkDrawingAreaClass *parent_class;
static void
dispose (GObject *object)
{
GtkClutter *clutter;
GtkClutterPrivate *priv;
clutter = GTK_CLUTTER (object);
priv = GTK_CLUTTER_GET_PRIVATE (clutter);
if (priv->stage) {
g_object_unref (G_OBJECT (priv->stage));
priv->stage = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
size_request (GtkWidget *widget,
GtkRequisition *req)
{
GtkClutter *clutter;
GtkClutterPrivate *priv;
clutter = GTK_CLUTTER (widget);
priv = GTK_CLUTTER_GET_PRIVATE (clutter);
req->width = 800;
req->height = 600;
}
static void
realize (GtkWidget *widget)
{
GtkClutter *clutter;
GtkClutterPrivate *priv;
const XVisualInfo *xvinfo;
GdkVisual *visual;
GdkColormap *colormap;
clutter = GTK_CLUTTER (widget);
priv = GTK_CLUTTER_GET_PRIVATE (clutter);
/* We need to use the colormap from the Clutter visual */
xvinfo = clutter_stage_get_xvisual (CLUTTER_STAGE (priv->stage));
visual = gdk_x11_screen_lookup_visual (gdk_screen_get_default (),
xvinfo->visualid);
colormap = gdk_colormap_new (visual, FALSE);
gtk_widget_set_colormap (widget, colormap);
/* And turn off double buffering, cos GL doesn't like it */
gtk_widget_set_double_buffered (widget, FALSE);
GTK_WIDGET_CLASS (parent_class)->realize (widget);
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
clutter = GTK_CLUTTER (widget);
priv = GTK_CLUTTER_GET_PRIVATE (clutter);
clutter_stage_set_xwindow_foreign (CLUTTER_STAGE (priv->stage),
GDK_WINDOW_XID (widget->window));
}
static void
gtk_clutter_class_init (GtkClutterClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
gobject_class->dispose = dispose;
widget_class->size_request = size_request;
widget_class->realize = realize;
g_type_class_add_private (gobject_class, sizeof (GtkClutterPrivate));
parent_class = g_type_class_peek_parent (klass);
}
static void
gtk_clutter_init (GtkClutter *clutter)
{
GtkClutterPrivate *priv;
clutter->priv = priv = GTK_CLUTTER_GET_PRIVATE (clutter);
gtk_widget_set_double_buffered (GTK_WIDGET (clutter), FALSE);
priv->stage = clutter_stage_get_default ();
}
G_DEFINE_TYPE (GtkClutter, gtk_clutter, GTK_TYPE_DRAWING_AREA);
/**
* gtk_clutter_get_stage:
* @clutter: A #GtkClutter object.
*
* Obtains the #ClutterStage associated with this object.
*
* Return value: A #ClutterActor.
*/
ClutterActor *
gtk_clutter_get_stage (GtkClutter *clutter)
{
g_return_val_if_fail (GTK_IS_CLUTTER (clutter), NULL);
return clutter->priv->stage;
}

View File

@ -1,80 +0,0 @@
/*
* GTK-Clutter.
*
* GTK+ widget for Clutter.
*
* Authored By Iain Holmes <iain@openedhand.com>
*
* Copyright (C) 2006 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _HAVE_GTK_CLUTTER_H
#define _HAVE_GTK_CLUTTER_H
#include <gtk/gtkdrawingarea.h>
#include <clutter/clutter-actor.h>
G_BEGIN_DECLS
#define GTK_TYPE_CLUTTER gtk_clutter_get_type ()
#define GTK_CLUTTER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
GTK_TYPE_CLUTTER, GtkClutter))
#define GTK_CLUTTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CASE ((klass), \
GTK_TYPE_CLUTTER, GtkClutterClass))
#define GTK_IS_CLUTTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
GTK_TYPE_CLUTTER))
#define GTK_IS_CLUTTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
GTK_TYPE_CLUTTER))
#define GTK_CLUTTER_STAGE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
GTK_TYPE_CLUTTER, GtkClutterClass))
typedef struct _GtkClutterPrivate GtkClutterPrivate;
typedef struct _GtkClutter GtkClutter;
typedef struct _GtkClutterClass GtkClutterClass;
struct _GtkClutter
{
GtkDrawingArea parent;
/*< private >*/
GtkClutterPrivate *priv;
};
struct _GtkClutterClass
{
GtkDrawingAreaClass parent_class;
};
GType gtk_clutter_get_type (void);
ClutterActor *gtk_clutter_get_stage (GtkClutter *clutter);
G_END_DECLS
#endif

View File

@ -1,11 +0,0 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: gtk-clutter-@CLUTTER_MAJORMINOR@
Description: Gtk widget for Clutter
Version: @VERSION@
Libs: -L${libdir} -lgtk-clutter-@CLUTTER_MAJORMINOR@
Cflags: -I${includedir}/gtk-clutter-@CLUTTER_MAJORMINOR@
Requires: clutter-@CLUTTER_MAJORMINOR@ pangoft2 glib-2.0 >= 2.8 gthread-2.0 gdk-pixbuf-2.0 gdk-pixbuf-xlib-2.0 gstreamer-0.10 gstreamer-plugins-base-0.10

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB