~ubuntu-branches/ubuntu/quantal/pyclutter/quantal

« back to all changes in this revision

Viewing changes to clutter-cairo/cluttercairo.override

  • Committer: Bazaar Package Importer
  • Author(s): Rob Bradford
  • Date: 2008-10-15 15:25:57 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081015152557-qv1xzqtng4iqgwfd
Tags: 0.8.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
 
2
body
 
3
 
 
4
static PyTypeObject *_PyPangoCairoContext_Type;
 
5
#define PyPangoCairoContext_Type (*_PyPangoCairoContext_Type)
 
6
 
 
7
static PyObject *
 
8
_wrap_clutter_cairo_set_source_color (PyObject *self,
 
9
                                      PyObject *args,
 
10
                                      PyObject *kwargs)
 
11
{
 
12
    static char *kwlist[] = { "color", NULL };
 
13
    PyObject *py_color;
 
14
    ClutterColor *color = NULL;
 
15
 
 
16
    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
 
17
                                      "O:cluttercairo.CairoContext.set_source_color",
 
18
                                      kwlist, &py_color))
 
19
      return NULL;
 
20
 
 
21
    if (pyg_boxed_check (py_color, CLUTTER_TYPE_COLOR))
 
22
      color = pyg_boxed_get (py_color, ClutterColor);
 
23
    else
 
24
      {
 
25
        PyErr_SetString (PyExc_TypeError, "color should be a clutter.Color");
 
26
        return NULL;
 
27
      }
 
28
 
 
29
    clutter_cairo_set_source_color (PycairoContext_GET (self), color);
 
30
 
 
31
    Py_INCREF(Py_None);
 
32
    return Py_None;
 
33
}
 
34
 
 
35
static PyMethodDef _PyClutterCairoContext_methods[] = {
 
36
  { "set_source_color", (PyCFunction)_wrap_clutter_cairo_set_source_color, METH_VARARGS | METH_KEYWORDS },
 
37
  { NULL, NULL, 0 }
 
38
};
 
39
 
 
40
PyTypeObject PyClutterCairoContext_Type = {
 
41
    PyObject_HEAD_INIT(NULL)
 
42
    0,                                  /* ob_size */
 
43
    "cluttercairo.CairoContext",        /* tp_name */
 
44
    0,                                  /* tp_basicsize */
 
45
    0,                                  /* tp_itemsize */
 
46
    /* methods */
 
47
    (destructor)0,                      /* tp_dealloc */
 
48
    (printfunc)0,                       /* tp_print */
 
49
    (getattrfunc)0,                     /* tp_getattr */
 
50
    (setattrfunc)0,                     /* tp_setattr */
 
51
    (cmpfunc)0,                         /* tp_compare */
 
52
    (reprfunc)0,                        /* tp_repr */
 
53
    0,                                  /* tp_as_number */
 
54
    0,                                  /* tp_as_sequence */
 
55
    0,                                  /* tp_as_mapping */
 
56
    (hashfunc)0,                        /* tp_hash */
 
57
    (ternaryfunc)0,                     /* tp_call */
 
58
    (reprfunc)0,                        /* tp_str */
 
59
    (getattrofunc)0,                    /* tp_getattro */
 
60
    (setattrofunc)0,                    /* tp_setattro */
 
61
    0,                                  /* tp_as_buffer */
 
62
    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
 
63
    "A pangocairo.CairoContext enhanced with some additional clutter methods", /* Documentation string */
 
64
    (traverseproc)0,                    /* tp_traverse */
 
65
    (inquiry)0,                         /* tp_clear */
 
66
    (richcmpfunc)0,                     /* tp_richcompare */
 
67
    0,                                  /* tp_weaklistoffset */
 
68
    (getiterfunc)0,                     /* tp_iter */
 
69
    (iternextfunc)0,                    /* tp_iternext */
 
70
    _PyClutterCairoContext_methods,     /* tp_methods */
 
71
    0,                                  /* tp_members */
 
72
    0,                                  /* tp_getset */
 
73
    (PyTypeObject *)0,                  /* tp_base */
 
74
    (PyObject *)0,                      /* tp_dict */
 
75
    0,                                  /* tp_descr_get */
 
76
    0,                                  /* tp_descr_set */
 
77
    0,                                  /* tp_dictoffset */
 
78
    (initproc)0,                        /* tp_init */
 
79
    0,                                  /* tp_alloc */
 
80
    0,                                  /* tp_new */
 
81
    0,                                  /* tp_free */
 
82
    (inquiry)0,                         /* tp_is_gc */
 
83
    (PyObject *)0,                      /* tp_bases */
 
84
};
 
85
 
 
86
%%
2
87
headers
3
88
#define NO_IMPORT_PYGOBJECT
4
89
#include "pygobject.h"
14
99
%%
15
100
ignore-glob
16
101
  *_get_type
 
102
  clutter_cairo_set_source_color
 
103
 
 
104
%%
 
105
init
 
106
  if ((module = PyImport_ImportModule ("pangocairo")) != NULL) {
 
107
    PyObject *moddict = PyModule_GetDict (module);
 
108
 
 
109
    _PyPangoCairoContext_Type = (PyTypeObject *) PyDict_GetItemString (moddict, "CairoContext");
 
110
    if (_PyPangoCairoContext_Type == NULL) {
 
111
      PyErr_SetString (PyExc_ImportError, "cannot import name CairoContext from pangocairo");
 
112
      return;
 
113
    }
 
114
  }
 
115
  else {
 
116
    return;
 
117
  }
 
118
 
 
119
  PyClutterCairoContext_Type.tp_base = &PyPangoCairoContext_Type;
 
120
  if (PyType_Ready (&PyClutterCairoContext_Type) < 0) {
 
121
    g_return_if_reached ();
 
122
  }
 
123
  if (PyDict_SetItemString (d, "CairoContext", (PyObject *) &PyClutterCairoContext_Type) < 0) {
 
124
    g_return_if_reached ();
 
125
  }
 
126
 
17
127
%%
18
128
override clutter_cairo_create noargs
19
129
static PyObject *
20
130
_wrap_clutter_cairo_create (PyGObject *self)
21
131
{
 
132
  cairo_t *ret;
 
133
 
 
134
  ret = clutter_cairo_create (CLUTTER_CAIRO (self->obj));
 
135
  return PycairoContext_FromContext (ret, &PyClutterCairoContext_Type, NULL);
 
136
}
 
137
%%
 
138
override clutter_cairo_create_region kwargs
 
139
static PyObject *
 
140
_wrap_clutter_cairo_create_region (PyGObject *self,
 
141
                                   PyObject  *args,
 
142
                                   PyObject  *kwargs)
 
143
{
 
144
    static char *kwlist[] = { "x_offset", "y_offset", "width", "height", NULL };
 
145
    int x_offset, y_offset;
 
146
    PyObject *py_width = NULL, *py_height = NULL;
22
147
    cairo_t *ret;
23
 
 
24
 
    ret = clutter_cairo_create (CLUTTER_CAIRO (self->obj));
25
 
    return PycairoContext_FromContext(ret, NULL, NULL);
 
148
    guint width = 0, height = 0;
 
149
 
 
150
    if (!PyArg_ParseTupleAndKeywords (args, kwargs,"iiOO:ClutterCairo.cairo_create_region", kwlist, &x_offset, &y_offset, &py_width, &py_height))
 
151
      return NULL;
 
152
 
 
153
    if (py_width) {
 
154
        if (PyLong_Check(py_width))
 
155
            width = PyLong_AsUnsignedLong(py_width);
 
156
        else if (PyInt_Check(py_width))
 
157
            width = PyInt_AsLong(py_width);
 
158
        else
 
159
            PyErr_SetString(PyExc_TypeError, "Parameter 'width' must be an int or a long");
 
160
        if (PyErr_Occurred())
 
161
            return NULL;
 
162
    }
 
163
 
 
164
    if (py_height) {
 
165
        if (PyLong_Check(py_height))
 
166
            height = PyLong_AsUnsignedLong(py_height);
 
167
        else if (PyInt_Check(py_height))
 
168
            height = PyInt_AsLong(py_height);
 
169
        else
 
170
            PyErr_SetString(PyExc_TypeError, "Parameter 'height' must be an int or a long");
 
171
        if (PyErr_Occurred())
 
172
            return NULL;
 
173
    }
 
174
    
 
175
    ret = clutter_cairo_create_region (CLUTTER_CAIRO (self->obj),
 
176
                                       x_offset, y_offset,
 
177
                                       width, height);
 
178
    return PycairoContext_FromContext (ret, &PyClutterCairoContext_Type, NULL);
26
179
}