[cairo-commit] pycairo/cairo pycairo-pattern.c, 1.29, 1.30 pycairo-context.c, 1.67, 1.68 pycairo-private.h, 1.34, 1.35 pycairo.h, 1.44, 1.45

Steve Chaplin commit at pdx.freedesktop.org
Sat Mar 4 02:36:16 PST 2006


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv19137/cairo

Modified Files:
	pycairo-pattern.c pycairo-context.c pycairo-private.h 
	pycairo.h 
Log Message:
'SC'

Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- pycairo-pattern.c	4 Mar 2006 08:06:21 -0000	1.29
+++ pycairo-pattern.c	4 Mar 2006 10:36:14 -0000	1.30
@@ -39,18 +39,17 @@
 /* Class Pattern ---------------------------------------------------------- */
 
 /* PycairoPattern_FromPattern
- * Create a new PycairoPattern from a cairo_pattern_t
+ * Create a new PycairoSolidPattern, PycairoSurfacePattern,
+ * PycairoLinearGradient or PycairoRadialGradient from a cairo_pattern_t.
  * pattern - a cairo_pattern_t to 'wrap' into a Python object.
  *           pattern is unreferenced if the PycairoPattern creation fails, or
  *           if the pattern is in an error status.
- * type - the type of the object to instantiate; it can be NULL,
- *        meaning a base cairo.Pattern type, or it can be a subclass of
- *        cairo.Pattern
  * Return value: New reference or NULL on failure
  */
 PyObject *
-PycairoPattern_FromPattern (cairo_pattern_t *pattern, PyTypeObject *type)
+PycairoPattern_FromPattern (cairo_pattern_t *pattern)
 {
+    PyTypeObject *type;
     PyObject *o;
 
     assert (pattern != NULL);
@@ -60,9 +59,22 @@
 	return NULL;
     }
 
-    if (type == NULL)
-        type = &PycairoPattern_Type;
-    o = PycairoPattern_Type.tp_alloc (type, 0);
+    switch (cairo_pattern_get_type (pattern)) {
+    case CAIRO_PATTERN_TYPE_SOLID:
+	type = &PycairoSolidPattern_Type;
+	break;
+    case CAIRO_PATTERN_TYPE_SURFACE:
+	type = &PycairoSurfacePattern_Type;
+	break;
+    case CAIRO_PATTERN_TYPE_LINEAR:
+	type = &PycairoLinearGradient_Type;
+	break;
+    case CAIRO_PATTERN_TYPE_RADIAL:
+	type = &PycairoRadialGradient_Type;
+	break;
+    }
+
+    o = type->tp_alloc(type, 0);
     if (o == NULL)
 	cairo_pattern_destroy (pattern);
     else

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- pycairo-context.c	22 Jan 2006 07:31:41 -0000	1.67
+++ pycairo-context.c	4 Mar 2006 10:36:14 -0000	1.68
@@ -400,10 +400,7 @@
 {
     cairo_pattern_t *pattern = cairo_get_source (o->ctx);
     cairo_pattern_reference (pattern);
-    /* bug #2765 - "How do we identify surface (and pattern) types?"
-     * should pass pattern type as arg2
-     */
-    return PycairoPattern_FromPattern (pattern, NULL);
+    return PycairoPattern_FromPattern (pattern);
 }
 
 static PyObject *

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- pycairo-private.h	14 Dec 2005 04:47:02 -0000	1.34
+++ pycairo-private.h	4 Mar 2006 10:36:14 -0000	1.35
@@ -64,8 +64,7 @@
 extern PyTypeObject PycairoGradient_Type;
 extern PyTypeObject PycairoLinearGradient_Type;
 extern PyTypeObject PycairoRadialGradient_Type;
-PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern,
-				      PyTypeObject *type);
+PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern);
 
 extern PyTypeObject PycairoScaledFont_Type;
 PyObject *PycairoScaledFont_FromScaledFont (cairo_scaled_font_t *scaled_font);

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- pycairo.h	23 Jan 2006 03:59:18 -0000	1.44
+++ pycairo.h	4 Mar 2006 10:36:14 -0000	1.45
@@ -115,8 +115,7 @@
     PyTypeObject *Gradient_Type;
     PyTypeObject *LinearGradient_Type;
     PyTypeObject *RadialGradient_Type;
-    PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern,
-				     PyTypeObject *type);
+    PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern);
 
     PyTypeObject *ScaledFont_Type;
     PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font);



More information about the cairo-commit mailing list