summaryrefslogtreecommitdiff
path: root/gtk/gtk-types.c
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>2001-06-30 15:26:15 +0000
committerJames Henstridge <jamesh@src.gnome.org>2001-06-30 15:26:15 +0000
commit2ae353672ee1ab747dee396c332d2ccce97bd0ec (patch)
tree8a0559148bf705a99d1e1a8ba263bc923cf70598 /gtk/gtk-types.c
parent590b26013f6162a1af244b8b285b3c7bbf9db797 (diff)
downloadpygtk-2ae353672ee1ab747dee396c332d2ccce97bd0ec.tar.gz
fix up to use PyGBoxed version of GdkEvent.
2001-06-30 James Henstridge <james@daa.com.au> * gtk/gtk.override (_wrap_gtk_selection_add_targets): fix up to use PyGBoxed version of GdkEvent. * gtk/gtk-types.c: remove GdkEvent stuff from here. Also delete the commented out GdkDragContext code, as the current GObject implementation has the same features now. * gtk/gtk.override (_wrap_gdk_event_getattr): implement the getattr method for GdkEvents. * gtk/gdk.defs (Event): add boxed type here.
Diffstat (limited to 'gtk/gtk-types.c')
-rw-r--r--gtk/gtk-types.c522
1 files changed, 0 insertions, 522 deletions
diff --git a/gtk/gtk-types.c b/gtk/gtk-types.c
index d439b84b..ff65eace 100644
--- a/gtk/gtk-types.c
+++ b/gtk/gtk-types.c
@@ -67,20 +67,6 @@ PyGdkColormap_New(GdkColormap *cmap)
gdk_colormap_ref(self->obj);
return (PyObject *)self;
}
-
-PyObject *
-PyGdkDragContext_New(GdkDragContext *ctx)
-{
- PyGdkDragContext_Object *self;
-
- self = (PyGdkDragContext_Object *)PyObject_NEW(PyGdkDragContext_Object,
- &PyGdkDragContext_Type);
- if (self == NULL)
- return NULL;
- self->obj = ctx;
- gdk_drag_context_ref(self->obj);
- return (PyObject *)self;
-}
#endif
PyObject *
@@ -456,401 +442,7 @@ PyTypeObject PyGtkStyle_Type = {
0L,0L,0L,0L,
NULL
};
-#endif
-
-PyObject *
-PyGdkEvent_New(GdkEvent *obj)
-{
- PyGdkEvent_Object *self;
- PyObject *v;
- guint i;
-
- if (obj == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- if ((self = (PyGdkEvent_Object *)
- PyObject_NEW(PyGdkEvent_Object,&PyGdkEvent_Type)) == NULL)
- return NULL;
- self->obj = obj;
- if ((self->attrs = PyDict_New()) == NULL)
- return NULL;
- if ((v = PyInt_FromLong(obj->type)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "type", v);
- Py_DECREF(v);
- if (obj->any.window) {
- if ((v = pygobject_new((GObject *)obj->any.window)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "window", v);
- Py_DECREF(v);
- } else
- PyDict_SetItemString(self->attrs, "window", Py_None);
- if ((v = PyInt_FromLong(obj->any.send_event)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "send_event", v);
- Py_DECREF(v);
- /* XXX Does anyone need the window attribute?? */
- switch(obj->type) {
- case GDK_NOTHING: break;
- case GDK_DELETE: break;
- case GDK_DESTROY: break;
- case GDK_EXPOSE: /*GdkEventExpose expose*/
- if ((v = Py_BuildValue("(iiii)",
- obj->expose.area.x,
- obj->expose.area.y,
- obj->expose.area.width,
- obj->expose.area.height)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "area", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->expose.count)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "count", v);
- Py_DECREF(v);
- break;
- case GDK_MOTION_NOTIFY: /*GdkEventMotion motion*/
- if ((v = PyInt_FromLong(obj->motion.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->motion.x)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs,"x", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->motion.y)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs,"y", v);
- Py_DECREF(v);
- if (obj->motion.axes) {
- v = PyTuple_New(obj->motion.device->num_axes);
- if (!v) return NULL;
- for (i = 0; i < obj->motion.device->num_axes; i++)
- PyTuple_SetItem(v, i, PyFloat_FromDouble(obj->motion.axes[i]));
- } else {
- Py_INCREF(Py_None);
- v = Py_None;
- }
- PyDict_SetItemString(self->attrs,"axes", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->motion.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->motion.is_hint)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "is_hint", v);
- Py_DECREF(v);
- if ((v = PyGdkDevice_New(obj->motion.device)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "device", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->motion.x_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x_root", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->motion.y_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y_root", v);
- Py_DECREF(v);
- break;
- case GDK_BUTTON_PRESS: /*GdkEventButton button*/
- case GDK_2BUTTON_PRESS: /*GdkEventButton button*/
- case GDK_3BUTTON_PRESS: /*GdkEventButton button*/
- case GDK_BUTTON_RELEASE: /*GdkEventButton button*/
- if ((v = PyInt_FromLong(obj->button.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->button.x)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs,"x", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->button.y)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs,"y", v);
- Py_DECREF(v);
- if (obj->button.axes) {
- v = PyTuple_New(obj->button.device->num_axes);
- if (!v) return NULL;
- for (i = 0; i < obj->button.device->num_axes; i++)
- PyTuple_SetItem(v, i, PyFloat_FromDouble(obj->button.axes[i]));
- } else {
- Py_INCREF(Py_None);
- v = Py_None;
- }
- PyDict_SetItemString(self->attrs,"axes", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->button.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->button.button)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "button", v);
- Py_DECREF(v);
- if ((v = PyGdkDevice_New(obj->button.device)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "device", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->button.x_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x_root", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->button.y_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y_root", v);
- Py_DECREF(v);
- break;
- case GDK_KEY_PRESS: /*GdkEventKey key*/
- case GDK_KEY_RELEASE: /*GdkEventKey key*/
- if ((v = PyInt_FromLong(obj->key.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->key.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->key.keyval)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "keyval", v);
- Py_DECREF(v);
- if ((v = PyString_FromStringAndSize(obj->key.string,
- obj->key.length)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "string", v);
- Py_DECREF(v);
- break;
- case GDK_ENTER_NOTIFY: /*GdkEventCrossing crossing*/
- case GDK_LEAVE_NOTIFY: /*GdkEventCrossing crossing*/
- if (obj->crossing.subwindow) {
- if ((v = pygobject_new((GObject*)obj->crossing.subwindow)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "subwindow", v);
- Py_DECREF(v);
- } else
- PyDict_SetItemString(self->attrs, "subwindow", Py_None);
- if ((v = PyInt_FromLong(obj->crossing.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->crossing.x)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->crossing.y)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->crossing.x_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x_root", v);
- Py_DECREF(v);
- if ((v = PyFloat_FromDouble(obj->crossing.y_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y_root", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->crossing.mode)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "mode", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->crossing.detail)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "detail", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->crossing.focus)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "focus", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->crossing.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- break;
- case GDK_FOCUS_CHANGE: /*GdkEventFocus focus_change*/
- if ((v = PyInt_FromLong(obj->focus_change.in)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "_in", v);
- Py_DECREF(v);
- break;
- case GDK_CONFIGURE: /*GdkEventConfigure configure*/
- if ((v = PyInt_FromLong(obj->configure.x)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->configure.y)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->configure.width)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "width", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->configure.height)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "height", v);
- Py_DECREF(v);
- break;
- case GDK_MAP: break;
- case GDK_UNMAP: break;
- case GDK_PROPERTY_NOTIFY: /*GdkEventProperty property*/
- if ((v = PyGdkAtom_New(obj->property.atom)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "atom", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->property.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->property.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- break;
- case GDK_SELECTION_CLEAR: /*GdkEventSelection selection*/
- case GDK_SELECTION_REQUEST: /*GdkEventSelection selection*/
- case GDK_SELECTION_NOTIFY: /*GdkEventSelection selection*/
- if ((v = PyGdkAtom_New(obj->selection.selection)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "selection", v);
- Py_DECREF(v);
- if ((v = PyGdkAtom_New(obj->selection.target)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "target", v);
- Py_DECREF(v);
- if ((v = PyGdkAtom_New(obj->selection.property)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "property", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->selection.requestor)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "requestor", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->selection.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- break;
- case GDK_PROXIMITY_IN: /*GdkEventProximity proximity*/
- case GDK_PROXIMITY_OUT: /*GdkEventProximity proximity*/
- if ((v = PyInt_FromLong(obj->proximity.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyGdkDevice_New(obj->proximity.device)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "device", v);
- Py_DECREF(v);
- break;
- case GDK_DRAG_ENTER: /*GdkEventDND dnd*/
- case GDK_DRAG_LEAVE: /*GdkEventDND dnd*/
- case GDK_DRAG_MOTION: /*GdkEventDND dnd*/
- case GDK_DRAG_STATUS: /*GdkEventDND dnd*/
- case GDK_DROP_START: /*GdkEventDND dnd*/
- case GDK_DROP_FINISHED: /*GdkEventDND dnd*/
- if ((v = pygobject_new((GObject *)obj->dnd.context)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "context", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->dnd.time)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "time", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->dnd.x_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "x_root", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->dnd.y_root)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "y_root", v);
- Py_DECREF(v);
- break;
- case GDK_CLIENT_EVENT: /*GdkEventClient client*/
- if ((v = PyGdkAtom_New(obj->client.message_type)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "message_type", v);
- Py_DECREF(v);
- if ((v = PyInt_FromLong(obj->client.data_format)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "data_format", v);
- Py_DECREF(v);
- if ((v = PyString_FromStringAndSize(obj->client.data.b, 20)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "data", v);
- Py_DECREF(v);
- break;
- case GDK_VISIBILITY_NOTIFY: /*GdkEventVisibility visibility*/
- if ((v = PyInt_FromLong(obj->visibility.state)) == NULL)
- return NULL;
- PyDict_SetItemString(self->attrs, "state", v);
- Py_DECREF(v);
- break;
- case GDK_NO_EXPOSE: /*GdkEventNoExpose no_expose*/
- break;
- default:
- break;
- }
- return (PyObject *)self;
-}
-
-static void
-pygdk_event_dealloc(PyGdkEvent_Object *self)
-{
- Py_XDECREF(self->attrs);
- PyMem_DEL(self);
-}
-
-static PyObject *
-pygdk_event_getattr(PyGdkEvent_Object *self, char *attr)
-{
- PyObject *ret;
- ret = PyDict_GetItemString(self->attrs, attr);
- if (ret != NULL) {
- Py_INCREF(ret);
- return ret;
- }
- PyErr_SetString(PyExc_AttributeError, attr);
- return NULL;
-}
-
-static int
-pygdk_event_compare(PyGdkEvent_Object *self, PyGdkEvent_Object *v)
-{
- if (self->obj == v->obj) return 0;
- if (self->obj > v->obj) return -1;
- return 1;
-}
-
-static long
-pygdk_event_hash(PyGdkEvent_Object *self)
-{
- return (long)self->obj;
-}
-
-PyTypeObject PyGdkEvent_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "GdkEvent",
- sizeof(PyGdkEvent_Object),
- 0,
- (destructor)pygdk_event_dealloc,
- (printfunc)0,
- (getattrfunc)pygdk_event_getattr,
- (setattrfunc)0,
- (cmpfunc)pygdk_event_compare,
- (reprfunc)0,
- 0,
- 0,
- 0,
- (hashfunc)pygdk_event_hash,
- (ternaryfunc)0,
- (reprfunc)0,
- 0L,0L,0L,0L,
- NULL
-};
-#if 0
static void
PyGdkWindow_Dealloc(PyGdkWindow_Object *self)
{
@@ -1658,102 +1250,6 @@ PyTypeObject PyGdkColormap_Type = {
0L,0L,0L,0L,
NULL
};
-
-static void
-PyGdkDragContext_Dealloc(PyGdkDragContext_Object *self)
-{
- gdk_drag_context_unref(self->obj);
- PyMem_DEL(self);
-}
-
-static int
-PyGdkDragContext_Compare(PyGdkDragContext_Object *self,
- PyGdkDragContext_Object *v)
-{
- if (self->obj == v->obj) return 0;
- if (self->obj > v->obj) return -1;
- return 1;
-}
-
-static long
-PyGdkDragContext_Hash(PyGdkDragContext_Object *self)
-{
- return (long)self->obj;
-}
-
-static PyObject *
-PyGdkDragContext_GetAttr(PyGdkDragContext_Object *self, char *key)
-{
- if (!strcmp(key, "__members__"))
- return Py_BuildValue("[sssssssss]", "action", "actions", "dest_window",
- "is_source", "protocol", "source_window",
- "start_window", "suggested_action", "targets");
- else if (!strcmp(key, "protocol"))
- return PyInt_FromLong(self->obj->protocol);
- else if (!strcmp(key, "is_source"))
- return PyInt_FromLong(self->obj->is_source);
- else if (!strcmp(key, "source_window"))
- if (self->obj->source_window)
- return PyGdkWindow_New(self->obj->source_window);
- else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- else if (!strcmp(key, "dest_window"))
- if (self->obj->dest_window)
- return PyGdkWindow_New(self->obj->dest_window);
- else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- else if (!strcmp(key, "targets")) {
- PyObject *atom, *ret = PyList_New(0);
- GList *tmp;
-
- if (ret == NULL)
- return NULL;
- for (tmp = self->obj->targets; tmp != NULL; tmp = tmp->next) {
- if ((atom = PyGdkAtom_New(GPOINTER_TO_INT(tmp->data))) == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- PyList_Append(ret, atom);
- Py_DECREF(atom);
- }
- return ret;
- } else if (!strcmp(key, "actions"))
- return PyInt_FromLong(self->obj->actions);
- else if (!strcmp(key, "suggested_action"))
- return PyInt_FromLong(self->obj->suggested_action);
- else if (!strcmp(key, "action"))
- return PyInt_FromLong(self->obj->action);
- else if (!strcmp(key, "start_time"))
- return PyInt_FromLong(self->obj->start_time);
- PyErr_SetString(PyExc_AttributeError, key);
- return NULL;
-}
-
-PyTypeObject PyGdkDragContext_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
- "GdkDragContext",
- sizeof(PyGdkDragContext_Object),
- 0,
- (destructor)PyGdkDragContext_Dealloc,
- (printfunc)0,
- (getattrfunc)PyGdkDragContext_GetAttr,
- (setattrfunc)0,
- (cmpfunc)PyGdkDragContext_Compare,
- (reprfunc)0,
- 0,
- 0,
- 0,
- (hashfunc)PyGdkDragContext_Hash,
- (ternaryfunc)0,
- (reprfunc)0,
- 0L,0L,0L,0L,
- NULL
-};
#endif
static void
@@ -2276,20 +1772,6 @@ pygtk_tree_path_from_pyobject(PyObject *object)
/* marshalers for the boxed types. Uses uppercase notation so that
* the macro below can automatically install them. */
static PyObject *
-PyGdkEvent_from_value(const GValue *value)
-{
- return PyGdkEvent_New(g_value_get_boxed(value));
-}
-static int
-PyGdkEvent_to_value(GValue *value, PyObject *object)
-{
- if (PyGdkEvent_Check(object)) {
- g_value_set_boxed(value, PyGdkEvent_Get(object));
- return 0;
- }
- return -1;
-}
-static PyObject *
PyGtkTreePath_from_value(const GValue *value)
{
GtkTreePath *path = (GtkTreePath *)g_value_get_boxed(value);
@@ -2325,13 +1807,9 @@ _pygtk_register_boxed_types(PyObject *moddict)
#if 0
register_tp(GtkStyle);
PyGtkStyleHelper_Type.ob_type = &PyType_Type;
-#endif
- register_tp2(GdkEvent, GDK_TYPE_EVENT);
-#if 0
register_tp(GdkWindow);
register_tp(GdkGC);
register_tp(GdkColormap);
- register_tp(GdkDragContext);
#endif
register_tp(GdkAtom);
register_tp(GtkCTreeNode);