rendered paste bodydiff --git a/gnt.override b/gnt.override
index 0e0894e..4cbb243 100644
--- a/gnt.override
+++ b/gnt.override
@@ -282,17 +282,67 @@ _wrap_get_text_bound(PyGObject *self, PyObject *args)
}
%%
override gnt_main noargs
+static gboolean
+gnt_main_watch_prepare(GSource *source,
+ int *timeout)
+{
+ *timeout = 100;
+
+ return FALSE;
+}
+
+static gboolean
+gnt_main_watch_check(GSource *source)
+{
+ PyGILState_STATE state;
+
+ state = pyg_gil_state_ensure();
+
+ pyg_gil_state_release(state);
+
+ return FALSE;
+}
+
+static gboolean
+gnt_main_watch_dispatch(GSource *source,
+ GSourceFunc callback,
+ gpointer user_data)
+{
+ /* We should never be dispatched */
+ g_assert_not_reached();
+ return TRUE;
+}
+
+static GSourceFuncs gnt_main_watch_funcs =
+static GSourceFuncs gnt_main_watch_funcs =
+{
+ gnt_main_watch_prepare,
+ gnt_main_watch_check,
+ gnt_main_watch_dispatch,
+ NULL
+};
+
+static GSource *
+gnt_main_watch_new(void)
+{
+ return g_source_new(&gnt_main_watch_funcs, sizeof(GSource));
+}
+
static PyObject *
_wrap_gnt_main(PyObject *self)
{
+ GSource *main_watch;
+
if (pyg_threads_enabled)
pyg_enable_threads();
+
+ main_watch = gnt_main_watch_new();
pyg_begin_allow_threads;
+ g_source_attach(main_watch, NULL);
gnt_main();
+ g_source_destroy(main_watch);
pyg_end_allow_threads;
Py_INCREF(Py_None);
return Py_None;
}