? patch
? pygobject/patch
? pygobject/tests/.deps
? pygobject/tests/.libs
? pygobject/tests/test-thread.lo
? pygobject/tests/test-unknown.lo
? pygobject/tests/testhelper.la
? pygobject/tests/testhelpermodule.lo
Index: pygobject/gobject/gobjectmodule.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygobject/gobject/gobjectmodule.c,v
retrieving revision 1.218
diff -u -p -r1.218 gobjectmodule.c
--- pygobject/gobject/gobjectmodule.c	1 May 2006 16:11:52 -0000	1.218
+++ pygobject/gobject/gobjectmodule.c	7 May 2006 07:19:28 -0000
@@ -31,6 +31,8 @@
 static PyObject *gerror_exc = NULL;
 static gboolean use_gil_state_api = FALSE;
 static PyObject *_pyg_signal_accumulator_true_handled_func;
+static GHashTable *log_handlers = NULL;
+static gboolean log_handlers_disabled = FALSE;
 
 GQuark pyginterface_type_key;
 GQuark pygobject_class_init_key;
@@ -3010,12 +3012,61 @@ _log_func(const gchar *log_domain,
           const gchar *message,
           gpointer user_data)
 {
-    PyGILState_STATE state;
-    PyObject* warning = user_data;
+    if (G_LIKELY(Py_IsInitialized()))
+    {
+	PyGILState_STATE state;
+	PyObject* warning = user_data;
 
-    state = pyg_gil_state_ensure();
-    PyErr_Warn(warning, (char *) message);
-    pyg_gil_state_release(state);
+	state = pyg_gil_state_ensure();
+	PyErr_Warn(warning, (char *) message);
+	pyg_gil_state_release(state);
+    } else
+        g_log_default_handler(log_domain, log_level, message, user_data);
+}
+
+static void
+set_log_handler(const char *domain, 
+	        PyObject   *warning)
+{
+    g_return_if_fail (domain != NULL);
+    g_return_if_fail (warning != NULL);
+
+    if (!log_handlers_disabled)
+    {
+	guint handler;
+	gpointer old_handler;
+	
+	if (!log_handlers)
+	    log_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+	if ((old_handler = g_hash_table_lookup(log_handlers, domain)))
+	    g_log_remove_handler(domain, GPOINTER_TO_UINT(old_handler));
+
+	handler = g_log_set_handler(domain, G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
+	                            _log_func, warning);
+	g_hash_table_insert(log_handlers, g_strdup (domain), GUINT_TO_POINTER (handler));
+    }
+}
+
+static void
+remove_handler(gpointer domain,
+               gpointer handler,
+	       gpointer unused)
+{
+    g_log_remove_handler(domain, GPOINTER_TO_UINT(handler));
+}
+
+static void
+disable_log_handlers(void)
+{
+    log_handlers_disabled = TRUE;
+    
+    if (log_handlers)
+    {
+	g_hash_table_foreach(log_handlers, remove_handler, NULL);
+	g_hash_table_destroy(log_handlers);
+	log_handlers = NULL;
+    }
 }
 
 /* ----------------- gobject module initialisation -------------- */
@@ -3087,7 +3138,10 @@ struct _PyGObject_Functions pygobject_ap
   pyg_closure_set_exception_handler,
   pygobject_constructv,
   pygobject_construct,
-  pyg_set_object_has_new_constructor
+  pyg_set_object_has_new_constructor,
+  
+  set_log_handler,
+  disable_log_handlers
 };
 
 #define REGISTER_TYPE(d, type, name) \
@@ -3293,12 +3347,9 @@ init_gobject(void)
 
     warning = PyErr_NewException("gobject.Warning", PyExc_Warning, NULL);
     PyDict_SetItemString(d, "Warning", warning);
-    g_log_set_handler("GLib", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-                      _log_func, warning);
-    g_log_set_handler("GLib-GObject", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-                      _log_func, warning);
-    g_log_set_handler("GThread", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-                      _log_func, warning);
+    set_log_handler("GLib", warning);
+    set_log_handler("GLib-GObject", warning);
+    set_log_handler("GThread", warning);
 
       /* signal registration recognizes this special accumulator 'constant' */
     _pyg_signal_accumulator_true_handled_func = \
Index: pygobject/gobject/pygobject.h
===================================================================
RCS file: /cvs/gnome/gnome-python/pygobject/gobject/pygobject.h,v
retrieving revision 1.58
diff -u -p -r1.58 pygobject.h
--- pygobject/gobject/pygobject.h	15 Apr 2006 16:47:06 -0000	1.58
+++ pygobject/gobject/pygobject.h	7 May 2006 07:19:28 -0000
@@ -172,6 +172,10 @@ struct _PyGObject_Functions {
                                       const char *first_property_name,
                                       ...);
     void      (*set_object_has_new_constructor) (GType type);
+
+    void      (*set_log_handler) (const char *domain,
+                                  PyObject   *warning);
+    void      (*disable_log_handlers) (void);
 };
 
 #ifndef _INSIDE_PYGOBJECT_
@@ -231,6 +235,8 @@ struct _PyGObject_Functions *_PyGObject_
 #define pygobject_construct         (_PyGObject_API->pygobject_construct)
 #define pygobject_constructv        (_PyGObject_API->pygobject_constructv)
 #define pyg_set_object_has_new_constructor (_PyGObject_API->set_object_has_new_constructor)
+#define pyg_set_log_handler	    (_PyGObject_API->set_log_handler)
+#define pyg_disable_log_handlers    (_PyGObject_API->disable_log_handlers)
 
 
 #define pyg_block_threads()   G_STMT_START {   \
Index: pygtk/pangomodule.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/pangomodule.c,v
retrieving revision 1.9
diff -u -p -r1.9 pangomodule.c
--- pygtk/pangomodule.c	1 Apr 2006 17:23:21 -0000	1.9
+++ pygtk/pangomodule.c	7 May 2006 07:19:29 -0000
@@ -86,6 +86,5 @@ initpango(void)
     /* add anything else to the module dictionary (such as constants) */
     warning = PyErr_NewException("pango.PangoWarning", PyExc_Warning, NULL);
     PyDict_SetItemString(d, "Warning", warning);
-    g_log_set_handler("Pango", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-                      _log_func, warning);
+    pyg_set_log_handler("Pango", warning);
 }
Index: pygtk/gtk/__init__.py
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gtk/__init__.py,v
retrieving revision 1.37
diff -u -p -r1.37 __init__.py
--- pygtk/gtk/__init__.py	6 Apr 2006 07:36:51 -0000	1.37
+++ pygtk/gtk/__init__.py	7 May 2006 07:19:31 -0000
@@ -108,7 +108,6 @@ def _is_pydoc():
 def _init():
     import sys
 
-
     try:
         sys_path = sys.path[:]
 
@@ -121,9 +120,6 @@ def _init():
         # which causes problems for pychecker, restore it if modified.
         if sys.path != sys_path:
             sys.path = sys_path
-
-    # install the default log handlers
-    add_log_handlers()
 
 gdk.INPUT_READ      = _gobject.IO_IN | _gobject.IO_HUP | _gobject.IO_ERR
 gdk.INPUT_WRITE     = _gobject.IO_OUT | _gobject.IO_HUP
Index: pygtk/gtk/gtk.override
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gtk/gtk.override,v
retrieving revision 1.356
diff -u -p -r1.356 gtk.override
--- pygtk/gtk/gtk.override	26 Apr 2006 13:51:58 -0000	1.356
+++ pygtk/gtk/gtk.override	7 May 2006 07:19:44 -0000
@@ -55,26 +55,6 @@ extern PyTypeObject PyGdkScreen_Type;
 extern PyTypeObject PyGdkRectangle_Type;
 extern PyTypeObject PyGdkDevice_Type;
 
-extern PyObject *PyGtkWarning;
-static guint _gtk_handler = -1, _gdk_handler = -1, _gdk_pixbuf_handler = -1;
-
-static void
-_pygtk_log_func(const gchar *log_domain,
-                GLogLevelFlags log_level,
-                const gchar *message,
-                gpointer user_data)
- {
-    if (G_LIKELY(Py_IsInitialized()))
-    {
-        PyGILState_STATE state;
-        
-        state = pyg_gil_state_ensure();
-        PyErr_Warn(PyGtkWarning, (char *) message);
-        pyg_gil_state_release(state);
-    } else
-        g_log_default_handler(log_domain, log_level, message, user_data);
-}
-
 
 static gboolean
 pygtk_util_pyobject_as_double(PyObject *obj, gdouble *value, const char *argument_name)
@@ -380,46 +360,6 @@ _wrap_gtk_init_check(PyGObject *self, Py
     Py_INCREF(Py_None);
     return Py_None;
 }
-%%
-define add_log_handlers
-static PyObject *
-_wrap_add_log_handlers(PyGObject *self, PyObject *args)
-{
-    if (!PyArg_ParseTuple(args, ":add_log_handlers"))
-	return NULL;
-
-    _gtk_handler = g_log_set_handler("Gtk",
-				     G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-				     _pygtk_log_func, NULL);
-    _gdk_handler = g_log_set_handler("Gdk",
-				     G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-				     _pygtk_log_func, NULL);
-    _gdk_pixbuf_handler = g_log_set_handler("GdkPixbuf",
-					    G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING,
-					    _pygtk_log_func, NULL);
-
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-%%
-define remove_log_handlers
-static PyObject *
-_wrap_remove_log_handlers(PyGObject *self, PyObject *args)
-{
-    if (!PyArg_ParseTuple(args, ":remove_log_handlers"))
-	return NULL;
-
-    g_log_remove_handler("Gtk", _gtk_handler);
-    _gtk_handler = -1;
-    g_log_remove_handler("Gdk", _gdk_handler);
-    _gdk_handler = -1;
-    g_log_remove_handler("GdkPixbuf", _gdk_pixbuf_handler);
-    _gdk_pixbuf_handler = -1;
-
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
 %%
 override gtk_paint_polygon kwargs
 static PyObject *
Index: pygtk/gtk/gtkmodule.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gtk/gtkmodule.c,v
retrieving revision 1.66
diff -u -p -r1.66 gtkmodule.c
--- pygtk/gtk/gtkmodule.c	16 Apr 2006 19:25:24 -0000	1.66
+++ pygtk/gtk/gtkmodule.c	7 May 2006 07:19:44 -0000
@@ -44,7 +44,6 @@ extern PyMethodDef pygtk_functions[];
 extern PyMethodDef pygdk_functions[];
 
 PyObject *PyGtkDeprecationWarning;
-PyObject *PyGtkWarning;
 
 static struct _PyGtk_FunctionStruct functions = {
     VERSION,
@@ -188,6 +187,7 @@ DL_EXPORT(void)
 init_gtk(void)
 {
     PyObject *m, *d, *tuple, *o;
+    PyObject *warning;
 
     /* initialise pygobject */
     init_pygobject();
@@ -233,8 +233,12 @@ init_gtk(void)
 						 PyExc_DeprecationWarning, NULL);
     PyDict_SetItemString(d, "DeprecationWarning", PyGtkDeprecationWarning);
 
-    PyGtkWarning = PyErr_NewException("gtk.GtkWarning", PyExc_Warning, NULL);
-    PyDict_SetItemString(d, "Warning", PyGtkWarning);
+    warning = PyErr_NewException("gtk.GtkWarning", PyExc_Warning, NULL);
+    PyDict_SetItemString(d, "Warning", warning);
+
+    pyg_set_log_handler("Gtk", warning);
+    pyg_set_log_handler("Gdk", warning);
+    pyg_set_log_handler("GdkPixbuf", warning);
 
     /* namespace all the gdk stuff in gtk.gdk ... */
     m = Py_InitModule("gtk.gdk", pygdk_functions);
@@ -243,6 +247,6 @@ init_gtk(void)
     pygdk_register_classes(d);
     pygdk_add_constants(m, "GDK_");
     pygdk_add_extra_constants(m);
-    
+
     gtk_timeout_add(100, python_do_pending_calls, NULL);
 }
