summaryrefslogtreecommitdiff
path: root/atkrectangle.override
diff options
context:
space:
mode:
authorJohn Finlay <finlay@src.gnome.org>2006-07-06 07:26:54 +0000
committerJohn Finlay <finlay@src.gnome.org>2006-07-06 07:26:54 +0000
commit96ec5d0af9354d536f1d56fafd53dd92d42cbe5c (patch)
tree2a34c55daaaa7354eb1a40d85cdca1937097d4e8 /atkrectangle.override
parent4ecf6350c933ac2a0f83177dae701a9e5db45fe5 (diff)
downloadpygtk-96ec5d0af9354d536f1d56fafd53dd92d42cbe5c.tar.gz
Add call to _pyatk_register_boxed_types()
* atkmodule.c (initatk): Add call to _pyatk_register_boxed_types() * Makefile.am (ATK_OVERRIDES): Add atkrectangle.override * atkrectangle.override: Add. * atk.override (_wrap_atk_text_get_text_at_offset) (_wrap_atk_text_get_text_before_offset) (_wrap_atk_text_get_character_extents) (_wrap_atk_text_get_run_attributes) (_wrap_atk_text_get_default_attributes) (_wrap_atk_text_get_bounded_ranges, _wrap_atk_text_get_selection) (_wrap_atk_text_get_range_extents): Add, * atk.defs (atk_rectangle_new): Add.
Diffstat (limited to 'atkrectangle.override')
-rw-r--r--atkrectangle.override263
1 files changed, 263 insertions, 0 deletions
diff --git a/atkrectangle.override b/atkrectangle.override
new file mode 100644
index 00000000..66ce3bff
--- /dev/null
+++ b/atkrectangle.override
@@ -0,0 +1,263 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygtk- Python bindings for the GTK toolkit.
+ * Copyright (C) 2006 John Finlay
+ *
+ * atkrectangle.override: atk.Rectangle overrides
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+%%
+headers
+
+gboolean
+pyatk_rectangle_from_pyobject(PyObject *object, AtkRectangle *rectangle)
+{
+ g_return_val_if_fail(rectangle != NULL, FALSE);
+
+ if (pyg_boxed_check(object, ATK_TYPE_RECTANGLE)) {
+ *rectangle = *pyg_boxed_get(object, AtkRectangle);
+ return TRUE;
+ }
+ if (PyArg_ParseTuple(object, "iiii", &rectangle->x, &rectangle->y,
+ &rectangle->width, &rectangle->height)) {
+ return TRUE;
+ }
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "could not convert to AtkRectangle");
+ return FALSE;
+}
+
+static PyObject *
+PyAtkRectangle_from_value(const GValue *value)
+{
+ AtkRectangle *rect = (AtkRectangle *)g_value_get_boxed(value);
+
+ return pyg_boxed_new(ATK_TYPE_RECTANGLE, rect, TRUE, TRUE);
+}
+static int
+PyAtkRectangle_to_value(GValue *value, PyObject *object)
+{
+ AtkRectangle rect;
+
+ if (!pyatk_rectangle_from_pyobject(object, &rect))
+ return -1;
+
+ g_value_set_boxed(value, &rect);
+ return 0;
+}
+
+void
+_pyatk_register_boxed_types(void)
+{
+ pyg_register_boxed_custom(ATK_TYPE_RECTANGLE,
+ PyAtkRectangle_from_value,
+ PyAtkRectangle_to_value);
+}
+%%
+override atk_rectangle_new kwargs
+static int
+_wrap_atk_rectangle_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", "width", "height", NULL };
+ AtkRectangle rect = {0, 0, 0, 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|iiii:AtkRectangle.__init__",
+ kwlist, &(rect.x), &(rect.y),
+ &(rect.width), &(rect.height)))
+ return -1;
+
+ self->boxed = g_boxed_copy(ATK_TYPE_RECTANGLE, &rect);
+ self->free_on_dealloc = TRUE;
+ self->gtype = ATK_TYPE_RECTANGLE;
+
+ return 0;
+}
+%%
+override-slot AtkRectangle.tp_as_sequence
+static int
+_wrap_atk_rectangle_length(PyGBoxed *self)
+{
+ return 4;
+}
+static PyObject *
+_wrap_atk_rectangle_getitem(PyGBoxed *self, int pos)
+{
+ AtkRectangle *rect;
+
+ if (pos < 0) pos += 4;
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+ rect = pyg_boxed_get(self, AtkRectangle);
+ switch (pos) {
+ case 0: return PyInt_FromLong(rect->x);
+ case 1: return PyInt_FromLong(rect->y);
+ case 2: return PyInt_FromLong(rect->width);
+ case 3: return PyInt_FromLong(rect->height);
+ default:
+ g_assert_not_reached();
+ return NULL;
+ }
+}
+static int
+_wrap_atk_rectangle_setitem(PyGBoxed *self, int pos, PyObject *value)
+{
+ AtkRectangle *rect;
+ gint val;
+
+ if (pos < 0) pos += 4;
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+ rect = pyg_boxed_get(self, AtkRectangle);
+ val = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+ switch(pos) {
+ case 0: rect->x = val; break;
+ case 1: rect->y = val; break;
+ case 2: rect->width = val; break;
+ case 3: rect->height = val; break;
+ default:
+ g_assert_not_reached();
+ return -1;
+ }
+ return 0;
+}
+static PySequenceMethods _wrap_atk_rectangle_tp_as_sequence = {
+ (inquiry)_wrap_atk_rectangle_length,
+ (binaryfunc)0,
+ (intargfunc)0,
+ (intargfunc)_wrap_atk_rectangle_getitem,
+ (intintargfunc)0,
+ (intobjargproc)_wrap_atk_rectangle_setitem,
+ (intintobjargproc)0
+};
+%%
+override-attr AtkRectangle.x
+static int
+_wrap_atk_rectangle__set_x(PyGBoxed *self, PyObject *value, void *closure)
+{
+ gint val;
+
+ val = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+ pyg_boxed_get(self, AtkRectangle)->x = val;
+ return 0;
+}
+%%
+override-attr AtkRectangle.y
+static int
+_wrap_atk_rectangle__set_y(PyGBoxed *self, PyObject *value, void *closure)
+{
+ gint val;
+
+ val = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+ pyg_boxed_get(self, AtkRectangle)->y = val;
+ return 0;
+}
+%%
+override-attr AtkRectangle.width
+static int
+_wrap_atk_rectangle__set_width(PyGBoxed *self, PyObject *value, void *closure)
+{
+ gint val;
+
+ val = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+ pyg_boxed_get(self, AtkRectangle)->width = val;
+ return 0;
+}
+%%
+override-attr AtkRectangle.height
+static int
+_wrap_atk_rectangle__set_height(PyGBoxed *self, PyObject *value, void *closure)
+{
+ gint val;
+
+ val = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+ pyg_boxed_get(self, AtkRectangle)->height = val;
+ return 0;
+}
+%%
+override atk_rectangle_intersect kwargs
+static PyObject *
+_wrap_atk_rectangle_intersect(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "src", NULL };
+ PyObject *py_src;
+ AtkRectangle src, dest = {0, 0, 0, 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:AtkRectangle.intersect",
+ kwlist, &py_src)) {
+ return NULL;
+ }
+
+ if (!pyg_boxed_check(py_src, ATK_TYPE_RECTANGLE)) {
+ if (!pyatk_rectangle_from_pyobject(py_src, &src)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "src must be a AtkRectangle or 4-tuple");
+ return NULL;
+ }
+ } else {
+ src = *pyg_boxed_get(py_src, AtkRectangle);
+ }
+
+ atk_rectangle_intersect(pyg_boxed_get(self, AtkRectangle), &src, &dest);
+
+ return pyg_boxed_new(ATK_TYPE_RECTANGLE, &dest, TRUE, TRUE);
+}
+%%
+override atk_rectangle_union kwargs
+static PyObject *
+_wrap_atk_rectangle_union(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "src", NULL };
+ PyObject *py_src;
+ AtkRectangle src, dest;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:AtkRectangle.union",
+ kwlist, &py_src)) {
+ return NULL;
+ }
+
+ if (!pyg_boxed_check(py_src, ATK_TYPE_RECTANGLE)) {
+ if (!pyatk_rectangle_from_pyobject(py_src, &src)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "src must be a AtkRectangle or 4-tuple");
+ return NULL;
+ }
+ } else {
+ src = *pyg_boxed_get(py_src, AtkRectangle);
+ }
+
+ atk_rectangle_union(pyg_boxed_get(self, AtkRectangle), &src, &dest);
+
+ return pyg_boxed_new(ATK_TYPE_RECTANGLE, &dest, TRUE, TRUE);
+}