diff options
author | John Ehresman <jpe@wingware.com> | 2005-09-16 20:22:45 +0000 |
---|---|---|
committer | John Ehresman <jpe@src.gnome.org> | 2005-09-16 20:22:45 +0000 |
commit | 8ac845e3999ba1e721e32944e3f25d566cd0e72e (patch) | |
tree | c1c0d3acfcba51b2a8a0d33b5af87b3c3d730a17 /pangomodule.c | |
parent | ef50d5b693af2145f8037896bf577740816d713b (diff) | |
download | pygtk-8ac845e3999ba1e721e32944e3f25d566cd0e72e.tar.gz |
Add gobject.Warning Warning subclass and redirect all g_log messages for
2005-09-16 John Ehresman <jpe@wingware.com>
* gobjectmodule.c (initgobject): Add gobject.Warning Warning subclass
and redirect all g_log messages for the "GLib", "Glib-GObject", and
"GThread" domains to the python warning system
* pangomodule.c (initpango): Add pango.Warning Warning subclass
and redirect all g_log messages for the "Pango" domain to the
python warning system
* gtkmodule.c (initgtk): Move gtk Warning subclass from the gdk
module to the gtk module and added redirections for g_log messages
for the "Gdk" and "GdkPixbuf" domains to the python warning system
* gtk/__init__.py: Set gdk.Warning = gtk.Warning for backward
compatibility
Diffstat (limited to 'pangomodule.c')
-rw-r--r-- | pangomodule.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pangomodule.c b/pangomodule.c index b1652217..c8e72b60 100644 --- a/pangomodule.c +++ b/pangomodule.c @@ -33,10 +33,25 @@ void pypango_register_classes(PyObject *d); void pypango_add_constants(PyObject *module, const gchar *strip_prefix); extern PyMethodDef pypango_functions[]; +static void +_log_func(const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + PyGILState_STATE state; + PyObject* warning = user_data; + + state = pyg_gil_state_ensure(); + PyErr_Warn(warning, (char *) message); + pyg_gil_state_release(state); +} + DL_EXPORT(void) initpango(void) { PyObject *m, *d; + PyObject *warning; /* perform any initialisation required by the library here */ @@ -66,5 +81,8 @@ initpango(void) PyInt_FromLong(PANGO_SCALE)); /* 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); } |