Hi,

The attached patch adds ClutterX11TexturePixmap and
ClutterGLXTexturePixmap support to pyclutter.

Currently there is no configure test for x11 and glx clutter backends.
I've never really grokked autoconf, so I'm hoping someone would know the
best way to implement that. 

Window types are implement as guint32.  Looking through the X headers,
Window is a CARD32, which is an unsigned 32-bit quantity.  Pixmaps are a
bit trickier, so I figured the most convenient and compatible approach
would be to accept PyCObjects.

Please review, and let me know what changes are needed in order to be
commit-worthy.  We're going to be needing this functionality for Freevo,
so I'm keen to get this into trunk.

Thanks much,
Jason.
Index: pyclutter/clutter/pyclutter.h
===================================================================
--- pyclutter/clutter/pyclutter.h	(revision 3220)
+++ pyclutter/clutter/pyclutter.h	(working copy)
@@ -12,6 +12,8 @@
 #include <Python.h>
 #include <clutter/clutter.h>
 #include <clutter/clutter-feature.h>
+#include <clutter/x11/clutter-x11-texture-pixmap.h>
+#include <clutter/glx/clutter-glx-texture-pixmap.h>
 
 G_BEGIN_DECLS
 
Index: pyclutter/clutter/clutter.override
===================================================================
--- pyclutter/clutter/clutter.override	(revision 3220)
+++ pyclutter/clutter/clutter.override	(working copy)
@@ -820,3 +820,48 @@
   Py_INCREF(Py_None);
   return Py_None;
 }
+%%
+override clutter_x11_texture_pixmap_new_with_pixmap
+static PyObject *
+_wrap_clutter_x11_texture_pixmap_new_with_pixmap (PyGObject *self, 
+                                                  PyObject *args)
+{
+    ClutterActor *actor;
+    PyObject *pixmap;
+
+    if (!PyArg_ParseTuple (args, "O!", &PyCObject_Type, &pixmap))
+        return NULL;
+    actor = clutter_x11_texture_pixmap_new_with_pixmap (
+                    (Pixmap)PyCObject_AsVoidPtr (pixmap));
+    return pygobject_new((GObject *)actor);
+}
+%%
+override clutter_x11_texture_pixmap_set_pixmap
+static PyObject *
+_wrap_clutter_x11_texture_pixmap_set_pixmap (PyGObject *self, 
+                                             PyObject *args)
+{
+    PyObject *pixmap;
+
+    if (!PyArg_ParseTuple (args, "O!", &PyCObject_Type, &pixmap))
+        return NULL;
+    clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (self->obj),
+                                           (Pixmap)PyCObject_AsVoidPtr(pixmap));
+    Py_INCREF (Py_None);
+    return Py_None;
+}
+%%
+override clutter_glx_texture_pixmap_new_with_pixmap
+static PyObject *
+_wrap_clutter_glx_texture_pixmap_new_with_pixmap (PyGObject *self, 
+                                                  PyObject *args)
+{
+    ClutterActor *actor;
+    PyObject *pixmap;
+
+    if (!PyArg_ParseTuple (args, "O!", &PyCObject_Type, &pixmap))
+        return NULL;
+    actor = clutter_glx_texture_pixmap_new_with_pixmap (
+                    (Pixmap)PyCObject_AsVoidPtr (pixmap));
+    return pygobject_new((GObject *)actor);
+}
Index: pyclutter/clutter/clutter-base.defs
===================================================================
--- pyclutter/clutter/clutter-base.defs	(revision 3220)
+++ pyclutter/clutter/clutter-base.defs	(working copy)
@@ -5307,3 +5307,112 @@
     '("gint" "value")
   )
 )
+
+
+;; From clutter-x11-texture-pixmap.h
+
+(define-function x11_texture_pixmap_get_type
+  (c-name "clutter_x11_texture_pixmap_get_type")
+  (return-type "GType")
+)
+
+(define-function x11_texture_pixmap_new
+  (c-name "clutter_x11_texture_pixmap_new")
+  (is-constructor-of "ClutterX11TexturePixmap")
+  (return-type "ClutterActor*")
+)
+
+(define-function x11_texture_pixmap_new_with_pixmap
+  (c-name "clutter_x11_texture_pixmap_new_with_pixmap")
+  (return-type "ClutterActor*")
+  (parameters
+    '("PyObject *" "pixmap")
+  )
+)
+(define-function x11_texture_pixmap_new_with_window
+  (c-name "clutter_x11_texture_pixmap_new_with_window")
+  (return-type "ClutterActor*")
+  (parameters
+    '("guint32" "window")
+  )
+)
+
+(define-method set_pixmap
+  (of-object "ClutterX11TexturePixmap")
+  (c-name "clutter_x11_texture_pixmap_set_pixmap")
+  (return-type "none")
+  (parameters
+    '("PyObject *" "pixmap")
+  )
+)
+
+(define-method set_window
+  (of-object "ClutterX11TexturePixmap")
+  (c-name "clutter_x11_texture_pixmap_set_window")
+  (return-type "none")
+  (parameters
+    '("guint32" "window")
+    '("gboolean" "automatic")
+  )
+)
+
+(define-method sync_window
+  (of-object "ClutterX11TexturePixmap")
+  (c-name "clutter_x11_texture_pixmap_sync_window")
+  (return-type "none")
+)
+
+(define-method update_area
+  (of-object "ClutterX11TexturePixmap")
+  (c-name "clutter_x11_texture_pixmap_update_area")
+  (return-type "none")
+  (parameters
+    '("gint" "x")
+    '("gint" "y")
+    '("gint" "width")
+    '("gint" "height")
+  )
+)
+
+(define-method set_automatic
+  (of-object "ClutterX11TexturePixmap")
+  (c-name "clutter_x11_texture_pixmap_set_automatic")
+  (return-type "none")
+  (parameters
+    '("gboolean" "setting")
+  )
+)
+
+;; From clutter-glx-texture-pixmap.h
+
+(define-function glx_texture_pixmap_get_type
+  (c-name "clutter_glx_texture_pixmap_get_type")
+  (return-type "GType")
+)
+
+(define-function clutter_glx_texture_pixmap_new
+  (c-name "clutter_glx_texture_pixmap_new")
+  (is-constructor-of "ClutterGLXTexturePixmap")
+  (return-type "ClutterActor*")
+)
+
+(define-function glx_texture_pixmap_new_with_pixmap
+  (c-name "clutter_glx_texture_pixmap_new_with_pixmap")
+  (return-type "ClutterActor*")
+  (parameters
+    '("PyObject *" "pixmap")
+  )
+)
+(define-function glx_texture_pixmap_new_with_window
+  (c-name "clutter_glx_texture_pixmap_new_with_window")
+  (return-type "ClutterActor*")
+  (parameters
+    '("guint32" "window")
+  )
+)
+(define-method using_extension
+  (of-object "ClutterGLXTexturePixmap")
+  (c-name "clutter_glx_texture_pixmap_using_extension")
+  (return-type "gboolean")
+)
+
Index: pyclutter/clutter/clutter-base-types.defs
===================================================================
--- pyclutter/clutter/clutter-base-types.defs	(revision 3220)
+++ pyclutter/clutter/clutter-base-types.defs	(working copy)
@@ -287,6 +287,20 @@
   (gtype-id "CLUTTER_TYPE_CHILD_META")
 )
 
+(define-object X11TexturePixmap
+  (in-module "Clutter")
+  (parent "ClutterTexture")
+  (c-name "ClutterX11TexturePixmap")
+  (gtype-id "CLUTTER_X11_TYPE_TEXTURE_PIXMAP")
+)
+
+(define-object GLXTexturePixmap
+  (in-module "Clutter")
+  (parent "ClutterX11TexturePixmap")
+  (c-name "ClutterGLXTexturePixmap")
+  (gtype-id "CLUTTER_GLX_TYPE_TEXTURE_PIXMAP")
+)
+
 ;; Enumerations and flags ...
 
 (define-flags EventFlags

Reply via email to