Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/ChangeLog,v
retrieving revision 1.1115
diff -u -p -r1.1115 ChangeLog
--- ChangeLog	27 Dec 2004 05:10:14 -0000	1.1115
+++ ChangeLog	31 Dec 2004 20:14:03 -0000
@@ -1,3 +1,12 @@
+2004-12-31  Gustavo J. A. M. Carneiro  <gjc@gnome.org>
+
+	* gobject/pygobject.h, gobject/pygobject-private.h: Define
+	pyg_threads_enabled as PyEval_ThreadsInitialized() on Python 2.4,
+	so that it is no longer required to call gobject.threads_init on
+	that platform.  Also define pyg_begin|end_allow_threads as
+	Py_BEGIN|END_ALLOW_THREADS, since these functions are rarely
+	invoked, thus represent a minimal overhead.
+
 2004-12-26  John Finlay  <finlay@moeraki.com>
 
 	* gtk/gdk.override (_wrap_gdk_event_tp_setattr): Fix garbled code
Index: gobject/pygobject-private.h
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gobject/pygobject-private.h,v
retrieving revision 1.25
diff -u -p -r1.25 pygobject-private.h
--- gobject/pygobject-private.h	28 Sep 2004 15:03:43 -0000	1.25
+++ gobject/pygobject-private.h	31 Dec 2004 20:14:03 -0000
@@ -19,24 +19,20 @@ extern struct _PyGObject_Functions pygob
       (* pygobject_api_functions.unblock_threads)();      \
   } G_STMT_END
 
-#define pyg_threads_enabled (pygobject_api_functions.threads_enabled)
+#if PY_VERSION_HEX < 0x020400F0
+# define pyg_threads_enabled (pygobject_api_functions.threads_enabled)
+#else
+# define pyg_threads_enabled (PyEval_ThreadsInitialized())
+#endif
 
-
-#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0)
-#define pyg_gil_state_release(state) G_STMT_START {     \
-    if (pygobject_api_functions.threads_enabled)                \
+#define pyg_gil_state_ensure() (pyg_threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0)
+#define pyg_gil_state_release(state) G_STMT_START {             \
+    if (pyg_threads_enabled)                                    \
         pygobject_api_functions.gil_state_release(state);       \
     } G_STMT_END
 
-#define pyg_begin_allow_threads                         \
-    G_STMT_START {                                      \
-        PyThreadState *_save = NULL;                    \
-        if (pygobject_api_functions.threads_enabled)    \
-            _save = PyEval_SaveThread();
-#define pyg_end_allow_threads                           \
-        if (pygobject_api_functions.threads_enabled)    \
-            PyEval_RestoreThread(_save);                \
-    } G_STMT_END
+#define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS
+#define pyg_end_allow_threads Py_END_ALLOW_THREADS
 
 
 extern GType PY_TYPE_OBJECT;
Index: gobject/pygobject.h
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gobject/pygobject.h,v
retrieving revision 1.46
diff -u -p -r1.46 pygobject.h
--- gobject/pygobject.h	10 Dec 2004 18:14:38 -0000	1.46
+++ gobject/pygobject.h	31 Dec 2004 20:14:03 -0000
@@ -216,23 +216,21 @@ struct _PyGObject_Functions *_PyGObject_
       (* _PyGObject_API->unblock_threads)();     \
   } G_STMT_END
 
-#define pyg_threads_enabled (_PyGObject_API->threads_enabled)
 
-#define pyg_gil_state_ensure() (_PyGObject_API->threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0)
+#if PY_VERSION_HEX < 0x020400F0
+# define pyg_threads_enabled (_PyGObject_API->threads_enabled)
+#else
+# define pyg_threads_enabled (PyEval_ThreadsInitialized())
+#endif
+
+#define pyg_gil_state_ensure() (pyg_threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0)
 #define pyg_gil_state_release(state) G_STMT_START {     \
-    if (_PyGObject_API->threads_enabled)                \
+    if (pyg_threads_enabled)                            \
         _PyGObject_API->gil_state_release(state);       \
     } G_STMT_END
 
-#define pyg_begin_allow_threads                 \
-    G_STMT_START {                              \
-        PyThreadState *_save = NULL;            \
-        if (_PyGObject_API->threads_enabled)    \
-            _save = PyEval_SaveThread();
-#define pyg_end_allow_threads                   \
-        if (_PyGObject_API->threads_enabled)    \
-            PyEval_RestoreThread(_save);        \
-    } G_STMT_END
+#define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS
+#define pyg_end_allow_threads Py_END_ALLOW_THREADS
 
 #define init_pygobject() { \
     PyObject *gobject = PyImport_ImportModule("gobject"); \
