[pygtk/gtk-3.0: 19/55] Remove old PyGdk commented out code
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygtk/gtk-3.0: 19/55] Remove old PyGdk commented out code
- Date: Sat, 17 Jul 2010 00:26:00 +0000 (UTC)
commit 597ce300924d54304ed351cb4505e5f05287865c
Author: John Stowers <john stowers gmail com>
Date: Sat Jul 10 19:53:29 2010 +1200
Remove old PyGdk commented out code
gtk/gtk-types.c | 503 -------------------------------------------------------
1 files changed, 0 insertions(+), 503 deletions(-)
---
diff --git a/gtk/gtk-types.c b/gtk/gtk-types.c
index 8e40df2..2fa9d70 100644
--- a/gtk/gtk-types.c
+++ b/gtk/gtk-types.c
@@ -383,509 +383,6 @@ static PyTypeObject PyGtkRcStyleHelper_Type = {
NULL
};
-#if 0
-static void
-PyGdkWindow_Dealloc(PyGdkWindow_Object *self)
-{
- if (gdk_drawable_get_type(self->obj) == GDK_WINDOW_PIXMAP)
- g_object_unref(self->obj);
- else
- g_object_unref(self->obj);
- PyObject_DEL(self);
-}
-
-static int
-PyGdkWindow_Compare(PyGdkWindow_Object *self, PyGdkWindow_Object *v)
-{
- if (self->obj == v->obj) return 0;
- if (self->obj > v->obj) return -1;
- return 1;
-}
-
-static long
-PyGdkWindow_Hash(PyGdkWindow_Object *self)
-{
- return (long)self->obj;
-}
-
-static PyObject *
-PyGdkWindow_Repr(PyGdkWindow_Object *self)
-{
- char buf[100];
- if (gdk_drawable_get_type(self->obj) == GDK_WINDOW_PIXMAP)
- sprintf(buf, "<GdkPixmap at %lx>", (long)PyGdkWindow_Get(self));
- else
- sprintf(buf, "<GdkWindow at %lx>", (long)PyGdkWindow_Get(self));
- return PyString_FromString(buf);
-}
-
-static PyObject *
-PyGdkWindow_NewGC(PyGdkWindow_Object *self, PyObject *args, PyObject *kws)
-{
- int i = 0;
- PyObject *key, *value;
- char *strkey;
- GdkGCValues values;
- GdkGCValuesMask mask = 0;
- GdkGC *gc;
-
- if (kws != NULL)
- while (PyDict_Next(kws, &i, &key, &value)) {
- strkey = PyString_AsString(key);
- if (!strcmp(strkey, "foreground")) {
- if (!PyGdkColor_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "foreground argument takes a GdkColor");
- return NULL;
- }
- mask |= GDK_GC_FOREGROUND;
- values.foreground.red = PyGdkColor_Get(value)->red;
- values.foreground.green = PyGdkColor_Get(value)->green;
- values.foreground.blue = PyGdkColor_Get(value)->blue;
- values.foreground.pixel = PyGdkColor_Get(value)->pixel;
- } else if (!strcmp(strkey, "background")) {
- if (!PyGdkColor_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "background argument takes a GdkColor");
- return NULL;
- }
- mask |= GDK_GC_BACKGROUND;
- values.background.red = PyGdkColor_Get(value)->red;
- values.background.green = PyGdkColor_Get(value)->green;
- values.background.blue = PyGdkColor_Get(value)->blue;
- values.background.pixel = PyGdkColor_Get(value)->pixel;
- } else if (!strcmp(strkey, "font")) {
- if (!PyGdkFont_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "font argument takes a GdkFont");
- return NULL;
- }
- mask |= GDK_GC_FONT;
- values.font = PyGdkFont_Get(value);
- } else if (!strcmp(strkey, "tile")) {
- if (!PyGdkWindow_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "tile argument takes a GdkPixmap");
- return NULL;
- }
- mask |= GDK_GC_TILE;
- values.tile = PyGdkWindow_Get(value);
- } else if (!strcmp(strkey, "stipple")) {
- if (!PyGdkWindow_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "stipple argument takes a GdkPixmap");
- return NULL;
- }
- mask |= GDK_GC_STIPPLE;
- values.stipple = PyGdkWindow_Get(value);
- } else if (!strcmp(strkey, "clip_mask")) {
- if (!PyGdkWindow_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "clip_mask argument takes a GdkPixmap");
- return NULL;
- }
- mask |= GDK_GC_CLIP_MASK;
- values.clip_mask = PyGdkWindow_Get(value);
- } else {
- int i = 0;
-#ifndef offsetof
-#define offsetof(type, member) ( (int) &((type*)0)->member)
-#endif
-#define OFF(x) offsetof(GdkGCValues, x)
- static struct {char *name;GdkGCValuesMask mask;int offs; } others[] = {
- {"function", GDK_GC_FUNCTION, OFF(function)},
- {"fill", GDK_GC_FILL, OFF(fill)},
- {"subwindow_mode", GDK_GC_SUBWINDOW, OFF(subwindow_mode)},
- {"ts_x_origin", GDK_GC_TS_X_ORIGIN, OFF(ts_x_origin)},
- {"ts_y_origin", GDK_GC_TS_Y_ORIGIN, OFF(ts_y_origin)},
- {"clip_x_origin", GDK_GC_CLIP_X_ORIGIN, OFF(clip_x_origin)},
- {"clip_y_origin", GDK_GC_CLIP_Y_ORIGIN, OFF(clip_y_origin)},
- {"graphics_exposures", GDK_GC_EXPOSURES, OFF(graphics_exposures)},
- {"line_width", GDK_GC_LINE_WIDTH, OFF(line_width)},
- {"line_style", GDK_GC_LINE_STYLE, OFF(line_style)},
- {"cap_style", GDK_GC_CAP_STYLE, OFF(cap_style)},
- {"join_style", GDK_GC_JOIN_STYLE, OFF(join_style)},
- {NULL, 0, 0}
- };
-#undef OFF
- while (others[i].name != NULL) {
- if (!strcmp(strkey, others[i].name)) {
- if (!PyInt_Check(value)) {
- char buf[80];
- g_snprintf(buf, sizeof(buf),
- "%s argument expects an integer",
- others[i].name);
- PyErr_SetString(PyExc_TypeError, buf);
- return NULL;
- }
- mask |= others[i].mask;
- *((int *)((char *)&values + others[i].offs)) =
- PyInt_AsLong(value);
- break;
- }
- i++;
- }
- if (others[i].name == NULL) {
- PyErr_SetString(PyExc_TypeError, "unknown argument");
- return NULL;
- }
- }
- }
- if (!PyArg_ParseTuple(args, ":GdkWindow.new_gc"))
- return NULL;
- gc = gdk_gc_new_with_values(PyGdkWindow_Get(self), &values, mask);
- value = PyGdkGC_New(gc);
- g_object_unref(gc);
- return value;
-}
-
-static PyObject *
-PyGdkWindow_SetCursor(PyGdkWindow_Object *self, PyObject *args)
-{
- PyObject *cursor;
-
- if (!PyArg_ParseTuple(args, "O!:GdkWindow.set_cursor", &PyGdkCursor_Type,
- &cursor))
- return NULL;
- gdk_window_set_cursor(self->obj, PyGdkCursor_Get(cursor));
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-PyGdkWindow_PropertyGet(PyGdkWindow_Object *self, PyObject *args)
-{
- PyObject *py_property, py_type = NULL;
- gint pdelete = FALSE;
-
- GdkAtom atype, property, type;
- gint aformat, alength;
- guchar *data;
-
- if (!PyArg_ParseTuple(args, "O|Oi:GdkWindow.property_get", &py_property,
- &py_type, &pdelete)) {
- return NULL;
- }
-
- property = pygdk_atom_from_pyobject(py_property);
- if (Pyerr_Occurred())
- return NULL;
-
- type = pygdk_atom_from_pyobject(py_type);
- if (Pyerr_Occurred())
- return NULL;
-
- if (gdk_property_get(self->obj, property, type, 0, G_MAXLONG,
- pdelete, &atype, &aformat, &alength, &data)) {
- /* success */
- PyObject *pdata = NULL;
- gint i;
- guint16 *data16;
- guint32 *data32;
- switch (aformat) {
- case 8:
- if ((pdata = PyString_FromStringAndSize(data, alength)) == NULL)
- return NULL;
- break;
- case 16:
- data16 = (guint16 *)data;
- if ((pdata = PyTuple_New(alength)) == NULL)
- return NULL;
- for (i = 0; i < alength; i++)
- PyTuple_SetItem(pdata, i, PyInt_FromLong(data16[i]));
- break;
- case 32:
- data32 = (guint32 *)data;
- if ((pdata = PyTuple_New(alength)) == NULL)
- return NULL;
- for (i = 0; i < alength; i++)
- PyTuple_SetItem(pdata, i, PyInt_FromLong(data32[i]));
- break;
- default:
- g_warning("got a property format != 8, 16 or 32");
- g_assert_not_reached();
- }
- g_free(data);
- return Py_BuildValue("(NiN)", PyGdkAtom_New(atype), aformat, pdata);
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
-}
-
-static PyObject *
-PyGdkWindow_PropertyChange(PyGdkWindow_Object *self, PyObject *args)
-{
- PyObject *py_property, *py_type;
- GdkAtom property, type;
- gint format;
- PyObject *py_mode, *pdata;
- GdkPropMode mode;
- guchar *data = NULL;
- gint nelements;
-
- if (!PyArg_ParseTuple(args, "OOiOO:GdkWindow.property_change",
- &py_property, &py_type, &format, &py_mode, &pdata)) {
- return NULL;
- }
-
- property = pygdk_atom_from_pyobject(py_property);
- if (Pyerr_Occurred())
- return NULL;
-
- type = pygdk_atom_from_pyobject(py_type);
- if (Pyerr_Occurred())
- return NULL;
-
- if (pygtk_enum_get_value(GDK_TYPE_PROP_MODE, py_mode, (gint *)&mode))
- return NULL;
- switch (format) {
- case 8:
- if (!PyString_Check(pdata)) {
- PyErr_SetString(PyExc_TypeError, "data not a string and format=8");
- return NULL;
- }
- data = PyString_AsString(pdata);
- nelements = PyString_Size(pdata);
- break;
- case 16:
- {
- guint16 *data16;
- gint i;
-
- if (!PySequence_Check(pdata)) {
- PyErr_SetString(PyExc_TypeError,
- "data not a sequence and format=16");
- return NULL;
- }
- nelements = PySequence_Length(pdata);
- data16 = g_new(guint16, nelements);
- data = (guchar *)data16;
- for (i = 0; i < nelements; i++) {
- PyObject *item = PySequence_GetItem(pdata, i);
- Py_DECREF(item);
- item = PyNumber_Int(item);
- if (!item) {
- g_free(data16);
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError,"data element not an int");
- return NULL;
- }
- data16[i] = PyInt_AsLong(item);
- Py_DECREF(item);
- }
- }
- break;
- case 32:
- {
- guint32 *data32;
- gint i;
-
- if (!PySequence_Check(pdata)) {
- PyErr_SetString(PyExc_TypeError,
- "data not a sequence and format=32");
- return NULL;
- }
- nelements = PySequence_Length(pdata);
- data32 = g_new(guint32, nelements);
- data = (guchar *)data32;
- for (i = 0; i < nelements; i++) {
- PyObject *item = PySequence_GetItem(pdata, i);
- Py_DECREF(item);
- item = PyNumber_Int(item);
- if (!item) {
- g_free(data32);
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError,"data element not an int");
- return NULL;
- }
- data32[i] = PyInt_AsLong(item);
- Py_DECREF(item);
- }
- }
- break;
- default:
- PyErr_SetString(PyExc_TypeError, "format must be 8, 16 or 32");
- return NULL;
- break;
- }
- gdk_property_change(self->obj, property, type, format, mode, data,
- nelements);
- if (format != 8)
- g_free(data);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-PyGdkWindow_PropertyDelete(PyGdkWindow_Object *self, PyObject *args)
-{
- PyObject py_property;
- GdkAtom property;
-
- if (!PyArg_ParseTuple(args, "O:GdkWindow.property_delete", &property)) {
- return NULL;
- }
-
- property = pygdk_atom_from_pyobject(py_property);
- if (Pyerr_Occurred())
- return NULL;
-
- gdk_property_delete(self->obj, property);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-PyGdkWindow_Raise(PyGdkWindow_Object *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":GdkWindow._raise"))
- return NULL;
- gdk_window_raise(self->obj);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-PyGdkWindow_Lower(PyGdkWindow_Object *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":GdkWindow.lower"))
- return NULL;
- gdk_window_lower(self->obj);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-PyGdkWindow_InputGetPointer(PyGdkWindow_Object *self, PyObject *args)
-{
- guint32 deviceid;
- gdouble x = 0.0, y = 0.0, pressure = 0.0, xtilt = 0.0, ytilt = 0.0;
- GdkModifierType mask = 0;
-
- if (!PyArg_ParseTuple(args, "i:GdkWindow.input_get_pointer", &deviceid))
- return NULL;
- gdk_input_window_get_pointer(self->obj, deviceid, &x, &y, &pressure,
- &xtilt, &ytilt, &mask);
- return Py_BuildValue("(dddddi)", x, y, pressure, xtilt, ytilt, mask);
-}
-
-static PyMethodDef PyGdkWindow_methods[] = {
- {"new_gc", (PyCFunction)PyGdkWindow_NewGC, METH_VARARGS|METH_KEYWORDS, NULL},
- {"set_cursor", (PyCFunction)PyGdkWindow_SetCursor, METH_VARARGS, NULL},
- {"property_get", (PyCFunction)PyGdkWindow_PropertyGet, METH_VARARGS, NULL},
- {"property_change", (PyCFunction)PyGdkWindow_PropertyChange, METH_VARARGS, NULL},
- {"property_delete", (PyCFunction)PyGdkWindow_PropertyDelete, METH_VARARGS, NULL},
- {"_raise", (PyCFunction)PyGdkWindow_Raise, METH_VARARGS, NULL},
- {"lower", (PyCFunction)PyGdkWindow_Lower, METH_VARARGS, NULL},
- {"input_get_pointer", (PyCFunction)PyGdkWindow_InputGetPointer, METH_VARARGS, NULL},
- {NULL, 0, 0, NULL}
-};
-
-static PyObject *
-PyGdkWindow_GetAttr(PyGdkWindow_Object *self, char *key)
-{
- GdkWindow *win = PyGdkWindow_Get(self);
- gint x, y;
- GdkModifierType p_mask;
-
- if (!strcmp(key, "__members__"))
- return Py_BuildValue("[sssssssssssss]", "children", "colormap", "depth",
- "height", "parent", "pointer", "pointer_state",
- "toplevel", "type", "width", "x", "xid", "y");
- if (!strcmp(key, "width")) {
- gdk_drawable_get_size(win, &x, NULL);
- return PyInt_FromLong(x);
- }
- if (!strcmp(key, "height")) {
- gdk_drawable_get_size(win, NULL, &y);
- return PyInt_FromLong(y);
- }
- if (!strcmp(key, "x")) {
- gdk_window_get_position(win, &x, NULL);
- return PyInt_FromLong(x);
- }
- if (!strcmp(key, "y")) {
- gdk_window_get_position(win, NULL, &y);
- return PyInt_FromLong(y);
- }
- if (!strcmp(key, "colormap"))
- return PyGdkColormap_New(gdk_drawable_get_colormap(win));
- if (!strcmp(key, "pointer")) {
- gdk_window_get_pointer(win, &x, &y, NULL);
- return Py_BuildValue("(ii)", x, y);
- }
- if (!strcmp(key, "pointer_state")) {
- gdk_window_get_pointer(win, NULL, NULL, &p_mask);
- return PyInt_FromLong(p_mask);
- }
- if (!strcmp(key, "parent")) {
- GdkWindow *par = gdk_window_get_parent(win);
- if (par)
- return PyGdkWindow_New(par);
- Py_INCREF(Py_None);
- return Py_None;
- }
- if (!strcmp(key, "toplevel"))
- return PyGdkWindow_New(gdk_window_get_toplevel(win));
- if (!strcmp(key, "children")) {
- GList *children, *tmp;
- PyObject *ret;
- children = gdk_window_get_children(win);
- if ((ret = PyList_New(0)) == NULL)
- return NULL;
- for (tmp = children; tmp != NULL; tmp = tmp->next) {
- PyObject *win = PyGdkWindow_New(tmp->data);
- if (win == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- PyList_Append(ret, win);
- Py_DECREF(win);
- }
- g_list_free(children);
- return ret;
- }
- if (!strcmp(key, "type"))
- return PyInt_FromLong(gdk_drawable_get_type(win));
- if (!strcmp(key, "depth")) {
- gdk_window_get_geometry(win, NULL, NULL, NULL, NULL, &x);
- return PyInt_FromLong(x);
- }
-#ifdef WITH_XSTUFF
- if (!strcmp(key, "xid"))
- return PyInt_FromLong(GDK_WINDOW_XWINDOW(win));
-#endif
-
- return Py_FindMethod(PyGdkWindow_methods, (PyObject *)self, key);
-}
-
-PyTypeObject PyGdkWindow_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "GdkWindow",
- sizeof(PyGdkWindow_Object),
- 0,
- (destructor)PyGdkWindow_Dealloc,
- (printfunc)0,
- (getattrfunc)PyGdkWindow_GetAttr,
- (setattrfunc)0,
- (cmpfunc)PyGdkWindow_Compare,
- (reprfunc)PyGdkWindow_Repr,
- 0,
- 0,
- 0,
- (hashfunc)PyGdkWindow_Hash,
- (ternaryfunc)0,
- (reprfunc)0,
- (getattrofunc)0,
- (setattrofunc)0,
- 0,
- Py_TPFLAGS_DEFAULT,
- NULL
-};
-#endif
-
GdkAtom
pygdk_atom_from_pyobject(PyObject *object)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]