? codegen/check-oldstyle-constructors.py
? examples/gtk/log
Index: gobject/gobjectmodule.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gobject/gobjectmodule.c,v
retrieving revision 1.153
diff -u -p -r1.153 gobjectmodule.c
--- gobject/gobjectmodule.c	29 Sep 2004 16:26:28 -0000	1.153
+++ gobject/gobjectmodule.c	6 Oct 2004 23:20:29 -0000
@@ -1550,6 +1550,65 @@ pyg_threads_init (PyObject *unused, PyOb
     return Py_None;
 }
 
+struct _PyGChildData {
+    PyObject *func;
+    PyObject *data;
+};
+
+static void
+child_watch_func(GPid pid, gint status, gpointer data)
+{
+    struct _PyGChildData *child_data = (struct _PyGChildData *) data;
+    PyObject *retval;
+
+    if (child_data->data)
+        retval = PyObject_CallFunction(child_data->func, "iiO", pid, status,
+                                       child_data->data);
+    else
+        retval = PyObject_CallFunction(child_data->func, "ii", pid, status);
+    Py_XDECREF(retval);
+}
+
+static void
+child_watch_dnotify(gpointer data)
+{
+    struct _PyGChildData *child_data = (struct _PyGChildData *) data;
+    Py_DECREF(child_data->func);
+    Py_XDECREF(child_data->data);
+    g_free(child_data);
+}
+
+
+static PyObject *
+pyg_child_watch_add(PyObject *unused, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "pid", "function", "data", "priority", NULL };
+    guint id;
+    gint priority = G_PRIORITY_DEFAULT;
+    int pid;
+    PyObject *func, *user_data = NULL;
+    struct _PyGChildData *child_data;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO|Oi:gobject.child_watch_add", kwlist,
+                                     &pid, &func, &user_data, &priority))
+        return NULL;
+    if (!PyCallable_Check(func)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "gobject.child_watch_add: second argument must be callable");
+        return NULL;
+    }
+
+    child_data = g_new(struct _PyGChildData, 1);
+    child_data->func = func;
+    child_data->data = user_data;
+    Py_INCREF(child_data->func);
+    if (child_data->data)
+        Py_INCREF(child_data->data);
+    id = g_child_watch_add_full(priority, pid, child_watch_func,
+                                child_data, child_watch_dnotify);
+    return PyInt_FromLong(id);
+}
+
 static PyMethodDef pygobject_functions[] = {
     { "type_name", pyg_type_name, METH_VARARGS },
     { "type_from_name", pyg_type_from_name, METH_VARARGS },
@@ -1568,6 +1627,8 @@ static PyMethodDef pygobject_functions[]
     { "source_remove", pyg_source_remove, METH_VARARGS },
     { "main_context_default", (PyCFunction)pyg_main_context_default, METH_NOARGS },
     { "threads_init", (PyCFunction)pyg_threads_init, METH_VARARGS|METH_KEYWORDS },
+    { "child_watch_add", (PyCFunction)pyg_child_watch_add, METH_VARARGS|METH_KEYWORDS },
+
     { NULL, NULL, 0 }
 };
 
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/tests/Makefile.am,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile.am
--- tests/Makefile.am	27 Sep 2004 23:53:32 -0000	1.9
+++ tests/Makefile.am	6 Oct 2004 23:20:29 -0000
@@ -15,6 +15,7 @@ testhelper_la_LIBADD = $(GLIB_LIBS)
 testhelper_la_SOURCES = testhelpermodule.c
 
 tests =  \
+	test_child_watch.py \
 	conversion.py \
 	enum.py \
 	gtype.py \
Index: tests/test_child_watch.py
===================================================================
RCS file: tests/test_child_watch.py
diff -N tests/test_child_watch.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/test_child_watch.py	6 Oct 2004 23:20:29 -0000
@@ -0,0 +1,26 @@
+# -*- Mode: Python -*-
+
+import gc
+import unittest
+import os
+import time
+import sys
+
+from common import gobject
+
+class TestChildWatch(unittest.TestCase):
+
+    def _child_watch_cb(self, pid, condition, data):
+        self.data = data
+        self.loop.quit()
+
+    def testChildWatch(self):
+        self.data = None
+        self.loop = gobject.MainLoop()
+        pid = os.spawnl(os.P_NOWAIT, sys.executable, 'python', '-c', 'import time; time.sleep(1)')
+        gobject.child_watch_add(pid, self._child_watch_cb, 12345)
+        self.loop.run()
+        self.assertEqual(self.data, 12345)
+
+if __name__ == '__main__':
+    unittest.main()
