[cairo-commit] pycairo/cairo pycairo-surface.c, 1.3, 1.4 pycairo-pattern.c, 1.3, 1.4 pycairo.h, 1.5, 1.6

Steve Chaplin commit at pdx.freedesktop.org
Sun Nov 14 07:19:01 PST 2004


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv5229/cairo

Modified Files:
	pycairo-surface.c pycairo-pattern.c pycairo.h 
Log Message:
SC 14/11/2004

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pycairo-surface.c	14 Nov 2003 15:32:10 -0000	1.3
+++ pycairo-surface.c	14 Nov 2004 15:18:59 -0000	1.4
@@ -92,6 +92,13 @@
 }
 
 static PyObject *
+pycairo_surface_get_filter(PyCairoSurface *self)
+{
+    return PyInt_FromLong(cairo_surface_get_filter(self->surface));
+}
+
+
+static PyObject *
 pycairo_surface_set_filter(PyCairoSurface *self, PyObject *args)
 {
     cairo_filter_t filter;
@@ -109,11 +116,17 @@
       METH_VARARGS },
     { "set_repeat", (PyCFunction)pycairo_surface_set_repeat, METH_VARARGS },
     { "set_matrix", (PyCFunction)pycairo_surface_set_matrix, METH_VARARGS },
-    { "get_matrix", (PyCFunction)pycairo_surface_get_matrix, METH_VARARGS },
     { "set_filter", (PyCFunction)pycairo_surface_set_filter, METH_VARARGS },
     { NULL, NULL, 0 }
 };
 
+static PyGetSetDef pycairo_surface_getsets[] = {
+    /* for some reason, there is no cairo_surface_get_repeat */
+    { "matrix", (getter)pycairo_surface_get_matrix, (setter)0 },
+    { "filter", (getter)pycairo_surface_get_filter, (setter)0 },
+    { NULL, }
+};
+
 PyTypeObject PyCairoSurface_Type = {
     PyObject_HEAD_INIT(NULL)
     0,                                  /* ob_size */
@@ -146,7 +159,7 @@
     (iternextfunc)0,                    /* tp_iternext */
     pycairo_surface_methods,            /* tp_methods */
     0,                                  /* tp_members */
-    0,                                  /* tp_getset */
+    pycairo_surface_getsets,            /* tp_getset */
     (PyTypeObject *)0,                  /* tp_base */
     (PyObject *)0,                      /* tp_dict */
     0,                                  /* tp_descr_get */

Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pycairo-pattern.c	14 Nov 2004 13:04:00 -0000	1.3
+++ pycairo-pattern.c	14 Nov 2004 15:18:59 -0000	1.4
@@ -46,7 +46,7 @@
 static int
 pycairo_pattern_init(PyCairoPattern *self, PyObject *args, PyObject *kwargs)
 {
-    static char *kwlist[] = { "x0", "y0", "x1", "y1", 
+    static char *kwlist[] = { "x0", "y0", "x1", "y1",
 			      "cx0", "cy0", "radius0", "cx1", "cy1", "radius1",
 			      "surface",
 			      NULL };
@@ -92,14 +92,13 @@
     return 0;
 }
 
-/* Pattern methods */
 static PyObject *
 pycairo_pattern_add_color_stop(PyCairoPattern *self, PyObject *args)
 {
     double offset, red, green, blue, alpha;
     cairo_status_t status;
 
-    if (!PyArg_ParseTuple(args, "ddddd:Pattern.add_color_stop",    
+    if (!PyArg_ParseTuple(args, "ddddd:Pattern.add_color_stop",
 			  &offset, &red, &green, &blue, &alpha))
 	return NULL;
 
@@ -112,13 +111,92 @@
     return Py_None;
 }
 
+static PyObject *
+pycairo_pattern_set_matrix(PyCairoPattern *self, PyObject *args)
+{
+    PyCairoMatrix *matrix;
+
+    if (!PyArg_ParseTuple(args, "O!:Pattern.set_matrix",
+			  &PyCairoMatrix_Type, &matrix))
+	return NULL;
+
+    /* always returns status = success */
+    cairo_pattern_set_matrix(self->pattern, matrix->matrix);
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
+pycairo_pattern_set_extend(PyCairoPattern *self, PyObject *args)
+{
+    int extend;
+
+    if (!PyArg_ParseTuple(args, "i:Pattern.set_extend", &extend))
+ 	return NULL;
+ 
+    /* always returns status = success */
+    cairo_pattern_set_extend(self->pattern, extend);
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+ 
+static PyObject *
+pycairo_pattern_set_filter(PyCairoPattern *self, PyObject *args)
+{
+    int filter;
+
+    if (!PyArg_ParseTuple(args, "i:Pattern.set_filter", &filter))
+	return NULL;
+
+    /* always returns status = success */
+    cairo_pattern_set_filter(self->pattern, filter);
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+ 
+static PyObject *
+pycairo_pattern_get_matrix(PyCairoPattern *self)
+{
+    cairo_matrix_t *matrix;
+
+    matrix = cairo_matrix_create();
+    if (!matrix)
+	return PyErr_NoMemory();
+
+    /* always returns status = success */
+    cairo_pattern_get_matrix(self->pattern, matrix);
+    return pycairo_matrix_new(matrix);
+}
+
+static PyObject *
+pycairo_pattern_get_extend(PyCairoPattern *self)
+{
+    return PyInt_FromLong(cairo_pattern_get_extend(self->pattern));
+}
+
+static PyObject *
+pycairo_pattern_get_filter(PyCairoPattern *self)
+{
+    return PyInt_FromLong(cairo_pattern_get_filter(self->pattern));
+}
 
+ 
 static PyMethodDef pycairo_pattern_methods[] = {
-    { "add_color_stop", (PyCFunction)pycairo_pattern_add_color_stop,
+    { "add_color_stop", (PyCFunction)pycairo_pattern_add_color_stop, 
       METH_VARARGS },
+    { "set_matrix", (PyCFunction)pycairo_pattern_set_matrix, METH_VARARGS },
+    { "set_extend", (PyCFunction)pycairo_pattern_set_extend, METH_VARARGS },
+    { "set_filter", (PyCFunction)pycairo_pattern_set_filter, METH_VARARGS },
     { NULL, NULL, 0 }
 };
 
+static PyGetSetDef pycairo_pattern_getsets[] = {
+    { "matrix", (getter)pycairo_pattern_get_matrix, (setter)0 },
+    { "extend", (getter)pycairo_pattern_get_extend, (setter)0 },
+    { "filter", (getter)pycairo_pattern_get_filter, (setter)0 },
+    { NULL, (getter)0, (setter)0 }
+};
+
 PyTypeObject PyCairoPattern_Type = {
     PyObject_HEAD_INIT(NULL)
     0,                                  /* ob_size */
@@ -150,7 +228,7 @@
     (iternextfunc)0,                    /* tp_iternext */
     pycairo_pattern_methods,            /* tp_methods */
     0,                                  /* tp_members */
-    0,                                  /* tp_getset */
+    pycairo_pattern_getsets,            /* tp_getset */
     (PyTypeObject *)0,                  /* tp_base */
     (PyObject *)0,                      /* tp_dict */
     0,                                  /* tp_descr_get */

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pycairo.h	14 Nov 2004 13:04:00 -0000	1.5
+++ pycairo.h	14 Nov 2004 15:18:59 -0000	1.6
@@ -62,6 +62,8 @@
 #define pycairo_font_new  (_PyCairo_API->font_new)
 #define PyCairoContext_Type *(_PyCairo_API->context_type)
 #define pycairo_context_new  (_PyCairo_API->context_new)
+#define PyCairoPattern_Type *(_PyCairo_API->pattern_type)
+#define pycairo_pattern_new  (_PyCairo_API->pattern_new)
 
 #define init_pycairo() { \
     PyObject *pycairo = PyImport_ImportModule("cairo._cairo"); \




More information about the cairo-commit mailing list