+2008-07-04 Emmanuele Bassi <ebassi@openedhand.com>
+
+ * clutter-gtk.pc.in: Fix the inclusion directory
+
+ * clutter-gtk/gtk-clutter-embed.c: Synch up with the stable branch
+ to handle focus. Also remove the ClutterContainer implementation.
+
+ * clutter-gtk/gtk-clutter-util.[ch]: Fully document and add the
+ gtk_clutter_texture_set_from_icon_name() helper function.
+
+ * configure.ac: Whitespace
+
+ * examples/gtk-clutter-test.c: Update.
+
2008-05-19 Tomas Frydrych <tf@openedhand.com>
* clutter-gtk/gtk-clutter-embed.c:
2008-05-07 Matthew Allum <mallum@openedhand.com>
* clutter-gtk/gtk-clutter-embed.c:
- Add motion event handling - fixes #907
+ Add motion event handling - fixes #907
2008-04-24 Emmanuele Bassi <ebassi@openedhand.com>
* examples/Makefile.am:
* examples/gtk-clutter-multistage.c:
- Add a *very* simple multiple stage example.
+ Add a *very* simple multiple stage example.
2008-04-01 Neil Roberts <neil@o-hand.com>
2008-04-01 Matthew Allum <mallum@openedhand.com>
* clutter-gtk/gtk-clutter-embed.c:
- Update for latest trunk multistage.
- Should now support multple widgets.
+ Update for latest trunk multistage.
+ Should now support multple widgets.
2008-02-29 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-gtk.pc.in:
* configure.ac:
- Bump up to unstable 0.7 version and clutter req.
+ Bump up to unstable 0.7 version and clutter req.
* clutter-gtk/gtk-clutter-embed.c:
* clutter-gtk/gtk-clutter-embed.h:
- Add clutter_gtk_init(), as to use new API to share DISPLAY and
- turn off Clutter 'automatic' event collection.
- Add methods for;
- expose - Queue a Clutter redraw.
- map - set Actor mapped flag.
- show/hide - Forward to stage also.
- Minor doc additions.
+ Add clutter_gtk_init(), as to use new API to share DISPLAY and
+ turn off Clutter 'automatic' event collection.
+ Add methods for;
+ expose - Queue a Clutter redraw.
+ map - set Actor mapped flag.
+ show/hide - Forward to stage also.
+ Minor doc additions.
* examples/gtk-clutter-events.c:
- Add some minor comments re when to call show_all().
+ Add some minor comments re when to call show_all().
* examples/gtk-clutter-test.c:
- Fix event->actor mapping.
+ Fix event->actor mapping.
2008-02-21 Emmanuele Bassi <ebassi@openedhand.com>
Description: GTK+ widget for Clutter
Version: @VERSION@
Libs: -L${libdir} -lclutter-gtk-0.7
-Cflags: -I${includedir}/clutter-0.6/clutter-gtk
+Cflags: -I${includedir}/clutter-0.7/clutter-gtk
Requires: clutter-x11-0.7 gtk+-2.0
#include "gtk-clutter-embed.h"
-static void clutter_container_iface_init (ClutterContainerIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GtkClutterEmbed,
- gtk_clutter_embed,
- GTK_TYPE_WIDGET,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
- clutter_container_iface_init));
+G_DEFINE_TYPE (GtkClutterEmbed, gtk_clutter_embed, GTK_TYPE_WIDGET);
#define GTK_CLUTTER_EMBED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_CLUTTER_EMBED, GtkClutterEmbedPrivate))
GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
/* Make sure the widget is realised before we show */
- gtk_widget_realize (widget);
-
- GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->show (widget);
+ if (!GTK_WIDGET_REALIZED (widget))
+ gtk_widget_realize (widget);
clutter_actor_show (priv->stage);
+
+ GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->show (widget);
}
static void
{
GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
- GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->hide (widget);
-
clutter_actor_hide (priv->stage);
+
+ GTK_WIDGET_CLASS (gtk_clutter_embed_parent_class)->hide (widget);
}
static void
* throtling.
*/
attributes.event_mask = gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_MOTION_NOTIFY;
-
+ | GDK_EXPOSURE_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_KEY_RELEASE_MASK
+ | GDK_MOTION_NOTIFY;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
GDK_WINDOW_HWND (widget->window));
#endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
- clutter_redraw (CLUTTER_STAGE (priv->stage));
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (priv->stage));
gtk_clutter_embed_send_configure (GTK_CLUTTER_EMBED (widget));
}
}
static gboolean
-gtk_clutter_embed_expose_event (GtkWidget *widget, GdkEventExpose *event)
+gtk_clutter_embed_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
{
GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
if (CLUTTER_ACTOR_IS_VISIBLE (priv->stage))
clutter_actor_queue_redraw (priv->stage);
- return TRUE;
+ return FALSE;
}
static gboolean
-gtk_clutter_embed_map_event (GtkWidget *widget,
- GdkEventAny *event)
+gtk_clutter_embed_map_event (GtkWidget *widget,
+ GdkEventAny *event)
{
GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
*/
CLUTTER_ACTOR_SET_FLAGS (priv->stage, CLUTTER_ACTOR_MAPPED);
- return TRUE;
-}
-
-static void
-gtk_clutter_embed_add (ClutterContainer *container,
- ClutterActor *actor)
-{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
-
- clutter_container_add_actor (stage, actor);
- g_signal_emit_by_name (container, "actor-added", actor);
-}
-
-static void
-gtk_clutter_embed_remove (ClutterContainer *container,
- ClutterActor *actor)
-{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
-
- g_object_ref (actor);
-
- clutter_container_remove_actor (stage, actor);
- g_signal_emit_by_name (container, "actor-removed", actor);
-
- g_object_unref (actor);
-}
-
-static void
-gtk_clutter_embed_foreach (ClutterContainer *container,
- ClutterCallback callback,
- gpointer callback_data)
-{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
-
- clutter_container_foreach (stage, callback, callback_data);
-}
-
-static void
-gtk_clutter_embed_raise (ClutterContainer *container,
- ClutterActor *child,
- ClutterActor *sibling)
-{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
-
- clutter_container_raise_child (stage, child, sibling);
-}
-
-static void
-gtk_clutter_embed_lower (ClutterContainer *container,
- ClutterActor *child,
- ClutterActor *sibling)
-{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
-
- clutter_container_lower_child (stage, child, sibling);
+ return FALSE;
}
-static void
-gtk_clutter_embed_sort_depth_order (ClutterContainer *container)
+static gboolean
+gtk_clutter_embed_focus_out (GtkWidget *widget,
+ GdkEventFocus *event)
{
- GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (container)->priv;
- ClutterContainer *stage = CLUTTER_CONTAINER (priv->stage);
+ GtkClutterEmbedPrivate *priv = GTK_CLUTTER_EMBED (widget)->priv;
- clutter_container_sort_depth_order (stage);
-}
+ /* give back key focus to the stage */
+ clutter_stage_set_key_focus (CLUTTER_STAGE (priv->stage), NULL);
-static void
-clutter_container_iface_init (ClutterContainerIface *iface)
-{
- iface->add = gtk_clutter_embed_add;
- iface->remove = gtk_clutter_embed_remove;
- iface->foreach = gtk_clutter_embed_foreach;
- iface->raise = gtk_clutter_embed_raise;
- iface->lower = gtk_clutter_embed_lower;
- iface->sort_depth_order = gtk_clutter_embed_sort_depth_order;
+ return FALSE;
}
static void
widget_class->motion_notify_event = gtk_clutter_embed_motion_notify_event;
widget_class->expose_event = gtk_clutter_embed_expose_event;
widget_class->map_event = gtk_clutter_embed_map_event;
+ widget_class->focus_out_event = gtk_clutter_embed_focus_out;
}
static void
embed->priv = priv = GTK_CLUTTER_EMBED_GET_PRIVATE (embed);
+ GTK_WIDGET_SET_FLAGS (embed, GTK_CAN_FOCUS);
+
/* disable double-buffering: it's automatically provided
* by OpenGL
*/
* SECTION:gtk-clutter-util
* @short_description: Utility functions for integrating Clutter in GTK+
*
- * FIXME
+ * In order to properly integrate a Clutter scene into a GTK+ applications
+ * a certain degree of state must be retrieved from GTK+ itself.
*
+ * Clutter-GTK provides API for easing the process of synchronizing colors
+ * with the current GTK+ theme and for loading image sources from #GdkPixbuf,
+ * GTK+ stock items and icon themes.
*/
static inline void
break;
}
- color->red = (guint8) ((gtk_color.red / 65535.0) * 255);
- color->green = (guint8) ((gtk_color.green / 65535.0) * 255);
- color->blue = (guint8) ((gtk_color.blue / 65535.0) * 255);
+ color->red = CLAMP (((gtk_color.red / 65535.0) * 255), 0, 255);
+ color->green = CLAMP (((gtk_color.green / 65535.0) * 255), 0, 255);
+ color->blue = CLAMP (((gtk_color.blue / 65535.0) * 255), 0, 255);
+ color->alpha = 255;
}
/**
* gtk_clutter_get_fg_color:
- * @widget:
- * @state:
- * @color:
+ * @widget: a #GtkWidget
+ * @state: a state
+ * @color: return location for a #ClutterColor
*
- * FIXME
+ * Retrieves the foreground color of @widget for the given @state and copies
+ * it into @color.
*
* Since: 0.8
*/
/**
* gtk_clutter_get_bg_color:
- * @widget:
- * @state:
- * @color:
+ * @widget: a #GtkWidget
+ * @state: a state
+ * @color: return location for a #ClutterColor
*
- * FIXME
+ * Retrieves the background color of @widget for the given @state and copies
+ * it into @color.
*
* Since: 0.8
*/
/**
* gtk_clutter_get_text_color:
- * @widget:
- * @state:
- * @color:
+ * @widget: a #GtkWidget
+ * @state: a state
+ * @color: return location for a #ClutterColor
*
- * FIXME
+ * Retrieves the text color of @widget for the given @state and copies it
+ * into @color.
*
* Since: 0.8
*/
/**
* gtk_clutter_get_base_color:
- * @widget:
- * @state:
- * @color:
+ * @widget: a #GtkWidget
+ * @state: a state
+ * @color: return location for a #ClutterColor
*
- * FIXME
+ * Retrieves the base color of @widget for the given @state and copies it
+ * into @color.
*
* Since: 0.8
*/
* gtk_clutter_texture_new_from_pixbuf:
* @pixbuf: a #GdkPixbuf
*
- * FIXME
+ * Creates a new #ClutterTexture and sets its contents with a copy
+ * of @pixbuf.
*
* Return value: the newly created #ClutterTexture
*
}
/**
+ * gtk_clutter_texture_set_from_pixbuf:
+ * @texture: a #ClutterTexture
+ * @pixbuf: a #GdkPixbuf
+ *
+ * Sets the contents of @texture with a copy of @pixbuf.
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
+ GdkPixbuf *pixbuf)
+{
+ GError *error;
+
+ g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+
+ error = NULL;
+ clutter_texture_set_from_rgb_data (texture,
+ gdk_pixbuf_get_pixels (pixbuf),
+ gdk_pixbuf_get_has_alpha (pixbuf),
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ gdk_pixbuf_get_rowstride (pixbuf),
+ 4, 0,
+ &error);
+ if (error)
+ {
+ g_warning ("Unable to set the pixbuf: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+/**
* gtk_clutter_texture_new_from_stock:
* @widget: a #GtkWidget
- * @stock_id: FIXME
- * @size: FIXME
+ * @stock_id: the stock id of the icon
+ * @size: the size of the icon, or -1
*
- * FIXME
+ * Creates a new #ClutterTexture and sets its contents using the stock
+ * icon @stock_id as rendered by @widget.
*
* Return value: the newly created #ClutterTexture
*
}
/**
- * gtk_clutter_texture_new_from_icon_name:
+ * gtk_clutter_texture_set_from_stock:
+ * @texture: a #ClutterTexture
* @widget: a #GtkWidget
- * @icon_name: FIXME
- * @size: FIXME
+ * @stock_id: the stock id of the icon
+ * @size: the size of the icon, or -1
*
- * FIXME
+ * Sets the contents of @texture using the stock icon @stock_id, as
+ * rendered by @widget.
*
- * Return value: the newly created #ClutterTexture
+ * Since: 0.8
+ */
+void
+gtk_clutter_texture_set_from_stock (ClutterTexture *texture,
+ GtkWidget *widget,
+ const gchar *stock_id,
+ GtkIconSize size)
+{
+ GdkPixbuf *pixbuf;
+
+ g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (stock_id != NULL);
+ g_return_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1);
+
+ pixbuf = gtk_widget_render_icon (widget, stock_id, size, NULL);
+ if (!pixbuf)
+ pixbuf = gtk_widget_render_icon (widget,
+ GTK_STOCK_MISSING_IMAGE, size,
+ NULL);
+
+ gtk_clutter_texture_set_from_pixbuf (texture, pixbuf);
+ g_object_unref (pixbuf);
+}
+
+/**
+ * gtk_clutter_texture_new_from_icon_name:
+ * @widget: a #GtkWidget or %NULL
+ * @icon_name: the name of the icon
+ * @size: the size of the icon, or -1
+ *
+ * Creates a new #ClutterTexture and sets its contents to be
+ * the @icon_name from the current icon theme.
+ *
+ * Return value: the newly created texture, or %NULL if @widget
+ * was %NULL and @icon_name was not found.
*
* Since: 0.8
*/
GError *error;
ClutterActor *retval;
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
- if (gtk_widget_has_screen (widget))
+ if (widget && gtk_widget_has_screen (widget))
{
GdkScreen *screen;
icon_theme = gtk_icon_theme_get_default ();
}
- if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
+ if (size == -1 ||
+ !gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
{
- g_warning ("Invalid icon size");
width = height = 48;
}
&error);
if (error)
{
+ g_warning ("Unable to load the icon `%s' from the theme: %s",
+ icon_name,
+ error->message);
+
g_error_free (error);
- return gtk_clutter_texture_new_from_stock (widget,
- GTK_STOCK_MISSING_IMAGE,
- size);
+
+ if (widget)
+ return gtk_clutter_texture_new_from_stock (widget,
+ GTK_STOCK_MISSING_IMAGE,
+ size);
+ else
+ return NULL;
}
retval = gtk_clutter_texture_new_from_pixbuf (pixbuf);
return retval;
}
+
+/**
+ * gtk_clutter_texture_set_from_icon_name:
+ * @texture: a #ClutterTexture
+ * @widget: a #GtkWidget or %NULL
+ * @icon_name: the name of the icon
+ * @size: the icon size or -1
+ *
+ * Sets the contents of @texture using the @icon_name from the
+ * current icon theme.
+ *
+ * Since: 0.8
+ */
+void
+gtk_clutter_texture_set_from_icon_name (ClutterTexture *texture,
+ GtkWidget *widget,
+ const gchar *icon_name,
+ GtkIconSize size)
+{
+ GtkSettings *settings;
+ GtkIconTheme *icon_theme;
+ gint width, height;
+ GdkPixbuf *pixbuf;
+ GError *error;
+
+ g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
+ g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
+ g_return_if_fail (icon_name != NULL);
+ g_return_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1);
+
+ if (widget && gtk_widget_has_screen (widget))
+ {
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (widget);
+ settings = gtk_settings_get_for_screen (screen);
+ icon_theme = gtk_icon_theme_get_for_screen (screen);
+ }
+ else
+ {
+ settings = gtk_settings_get_default ();
+ icon_theme = gtk_icon_theme_get_default ();
+ }
+
+ if (size == -1 ||
+ !gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
+ {
+ width = height = 48;
+ }
+
+ error = NULL;
+ pixbuf = gtk_icon_theme_load_icon (icon_theme,
+ icon_name,
+ MIN (width, height), 0,
+ &error);
+ if (error)
+ {
+ g_warning ("Unable to load the icon `%s' from the theme: %s",
+ icon_name,
+ error->message);
+
+ g_error_free (error);
+
+ if (widget)
+ gtk_clutter_texture_set_from_stock (texture,
+ widget,
+ GTK_STOCK_MISSING_IMAGE,
+ size);
+ else
+ return;
+ }
+
+ gtk_clutter_texture_set_from_pixbuf (texture, pixbuf);
+ g_object_unref (pixbuf);
+}
+/* gtk-clutter-util.h: GTK+ integration utilities
+ *
+ * Copyright (C) 2008 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 see <http://www.fsf.org/licensing>.
+ *
+ * Authors:
+ * Emmanuele Bassi <ebassi@openedhand.com>
+ */
+
#ifndef __GTK_CLUTTER_UTIL_H__
#define __GTK_CLUTTER_UTIL_H__
G_BEGIN_DECLS
-void gtk_clutter_get_fg_color (GtkWidget *widget,
- GtkStateType state,
- ClutterColor *color);
-void gtk_clutter_get_bg_color (GtkWidget *widget,
- GtkStateType state,
- ClutterColor *color);
-void gtk_clutter_get_text_color (GtkWidget *widget,
- GtkStateType state,
- ClutterColor *color);
-void gtk_clutter_get_base_color (GtkWidget *widget,
- GtkStateType state,
- ClutterColor *color);
+void gtk_clutter_get_fg_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color);
+void gtk_clutter_get_bg_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color);
+void gtk_clutter_get_text_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color);
+void gtk_clutter_get_base_color (GtkWidget *widget,
+ GtkStateType state,
+ ClutterColor *color);
-ClutterActor *gtk_clutter_texture_new_from_pixbuf (GdkPixbuf *pixbuf);
-ClutterActor *gtk_clutter_texture_new_from_stock (GtkWidget *widget,
- const gchar *stock_id,
- GtkIconSize size);
-ClutterActor *gtk_clutter_texture_new_from_icon_name (GtkWidget *widget,
- const gchar *icon_name,
- GtkIconSize size);
+ClutterActor *gtk_clutter_texture_new_from_pixbuf (GdkPixbuf *pixbuf);
+ClutterActor *gtk_clutter_texture_new_from_stock (GtkWidget *widget,
+ const gchar *stock_id,
+ GtkIconSize size);
+ClutterActor *gtk_clutter_texture_new_from_icon_name (GtkWidget *widget,
+ const gchar *icon_name,
+ GtkIconSize size);
+void gtk_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
+ GdkPixbuf *pixbuf);
+void gtk_clutter_texture_set_from_stock (ClutterTexture *texture,
+ GtkWidget *widget,
+ const gchar *stock_id,
+ GtkIconSize size);
+void gtk_clutter_texture_set_from_icon_name (ClutterTexture *texture,
+ GtkWidget *widget,
+ const gchar *icon_name,
+ GtkIconSize size);
G_END_DECLS
*)
AC_MSG_ERROR([Invalid flavour for Clutter-GTK: use x11 or win32])
;;
+
esac
AC_SUBST(CLUTTER_CFLAGS)
}
/* Add the group to the stage */
- clutter_container_add_actor (CLUTTER_CONTAINER (clutter),
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage),
CLUTTER_ACTOR (oh->group));
g_signal_connect (stage, "button-press-event",