diff options
author | Johan Dahlin <johan@src.gnome.org> | 2006-04-06 07:32:25 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2006-04-06 07:32:25 +0000 |
commit | a2d1f799a1aa6fa8ce8d40a9cb0da8facaa5d6a1 (patch) | |
tree | ff0de8b9e50e81d9d7621aaf612c928f9f0a2664 /gtk/gtkmodule.c | |
parent | add6950ae38d0fc2e5b2a70f26c780046016f3b3 (diff) | |
download | pygtk-a2d1f799a1aa6fa8ce8d40a9cb0da8facaa5d6a1.tar.gz |
Add log handlers here
* gtk/__init__.py (_init): Add log handlers here
* gtk/gtk.override (_wrap_remove_log_handlers): New function,
makes it possible to remove the handlers pygtk installs.
Fixes #323786
Diffstat (limited to 'gtk/gtkmodule.c')
-rw-r--r-- | gtk/gtkmodule.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c index 95f2df4b..240d31f7 100644 --- a/gtk/gtkmodule.c +++ b/gtk/gtkmodule.c @@ -48,7 +48,6 @@ extern PyMethodDef pygdk_functions[]; PyObject *PyGtkDeprecationWarning; PyObject *PyGtkWarning; - static struct _PyGtk_FunctionStruct functions = { VERSION, @@ -85,23 +84,6 @@ sink_gtkobject(GObject *object) } } -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 python_do_pending_calls(gpointer data) { @@ -193,14 +175,15 @@ g_free(aname); } #undef add_atom } -static void +static gboolean init_pycairo(void) { #ifdef HAVE_PYCAIRO Pycairo_IMPORT; if (Pycairo_CAPI == NULL) - return; + return FALSE; #endif + return TRUE; } DL_EXPORT(void) @@ -213,7 +196,8 @@ init_gtk(void) g_assert(pygobject_register_class != NULL); /* initialise pycairo */ - init_pycairo(); + if (!init_pycairo()) + return; /* initialise pygtk */ gtk_type_init(0); @@ -253,12 +237,6 @@ init_gtk(void) PyGtkWarning = PyErr_NewException("gtk.GtkWarning", PyExc_Warning, NULL); PyDict_SetItemString(d, "Warning", PyGtkWarning); - g_log_set_handler("Gtk", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, - _pygtk_log_func, NULL); - g_log_set_handler("Gdk", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, - _pygtk_log_func, NULL); - g_log_set_handler("GdkPixbuf", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, - _pygtk_log_func, NULL); /* namespace all the gdk stuff in gtk.gdk ... */ m = Py_InitModule("gtk.gdk", pygdk_functions); |