From 7cad9a7ca0bdb1a75713658013aa8b55d0ee6844 Mon Sep 17 00:00:00 2001 From: Marina Zhurakhinskaya Date: Fri, 21 Nov 2008 00:39:14 +0000 Subject: [PATCH] Add a convenience function for setting an image for ClutterTexture based on GdkPixbuf. svn path=/trunk/; revision=67 --- src/shell-global.c | 25 +++++++++++++++++++++++++ src/shell-global.h | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/src/shell-global.c b/src/shell-global.c index 4652e92fe..0ae6372a3 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -168,6 +168,31 @@ shell_global_class_init (ShellGlobalClass *klass) G_PARAM_READABLE)); } +/** + * shell_clutter_texture_set_from_pixbuf: + * texture: #ClutterTexture to be modified + * pixbuf: #GdkPixbuf to set as an image for #ClutterTexture + * + * Convenience function for setting an image for #ClutterTexture based on #GdkPixbuf. + * Copied from an example posted by hp in this thread http://mail.gnome.org/archives/gtk-devel-list/2008-September/msg00218.html + * + * Return value: %TRUE on success, %FALSE on failure + */ +gboolean +shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture, + GdkPixbuf *pixbuf) +{ + return 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), + gdk_pixbuf_get_has_alpha (pixbuf) + ? 4 : 3, + 0, NULL); +} + /** * shell_global_get: * diff --git a/src/shell-global.h b/src/shell-global.h index 6f59b811d..d85796234 100644 --- a/src/shell-global.h +++ b/src/shell-global.h @@ -4,6 +4,7 @@ #include "mutter-plugin.h" #include #include +#include G_BEGIN_DECLS @@ -29,6 +30,10 @@ struct _ShellGlobalClass GType shell_global_get_type (void) G_GNUC_CONST; +gboolean +shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture, + GdkPixbuf *pixbuf); + ShellGlobal *shell_global_get (void); void shell_global_set_stage_input_area (ShellGlobal *global,