Index: pygmainloop.c =================================================================== RCS file: /cvs/gnome/gnome-python/pygtk/gobject/pygmainloop.c,v retrieving revision 1.4 diff -u -p -r1.4 pygmainloop.c --- pygmainloop.c 4 Aug 2004 14:52:52 -0000 1.4 +++ pygmainloop.c 31 Jan 2005 15:01:36 -0000 @@ -27,6 +27,23 @@ #include "pygobject-private.h" +static gboolean +pyg_main_loop_do_pending_calls(GMainLoop *main_loop) +{ + PyGILState_STATE state; + + state = pyg_gil_state_ensure(); + + if (PyErr_CheckSignals() == -1) { + PyErr_SetNone(PyExc_KeyboardInterrupt); + g_main_loop_quit (main_loop); + } + + pyg_gil_state_release(state); + + return TRUE; +} + static int pyg_main_loop_new(PyGMainLoop *self, PyObject *args, PyObject *kwargs) { @@ -35,6 +52,7 @@ pyg_main_loop_new(PyGMainLoop *self, PyO PyObject *py_context = Py_None; int is_running; GMainContext *context; + GSource *timeout; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ob:GMainLoop.__init__", @@ -55,6 +73,14 @@ pyg_main_loop_new(PyGMainLoop *self, PyO } self->loop = g_main_loop_new(context, is_running); + + timeout = g_timeout_source_new (100); + g_source_set_callback (timeout, + (GSourceFunc) pyg_main_loop_do_pending_calls, + self->loop, NULL); + g_source_attach (timeout, context); + g_source_unref (timeout); + return 0; }