summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--gobject/gobjectmodule.c26
-rw-r--r--gtk/__init__.py3
-rw-r--r--gtk/gtkmodule.c14
-rw-r--r--pangomodule.c20
5 files changed, 74 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b65b8954..78d3b1bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+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
+
2005-09-13 Johan Dahlin <jdahlin@async.com.br>
* gtk/gdk.defs:
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 0a844883..0bcc98ea 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -2615,6 +2615,20 @@ pyg_set_object_has_new_constructor(GType type)
g_type_set_qdata(type, pygobject_has_updated_constructor_key, GINT_TO_POINTER(1));
}
+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);
+}
+
/* ----------------- gobject module initialisation -------------- */
struct _PyGObject_Functions pygobject_api_functions = {
@@ -2706,6 +2720,8 @@ initgobject(void)
{
PyObject *m, *d, *o, *tuple;
PyObject *descr;
+ PyObject *warning;
+
PyGParamSpec_Type.ob_type = &PyType_Type;
m = Py_InitModule("gobject", pygobject_functions);
@@ -2884,4 +2900,14 @@ initgobject(void)
pyg_register_gtype_custom(G_TYPE_STRV,
_pyg_strv_from_gvalue,
_pyg_strv_to_gvalue);
+
+ 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);
+
}
diff --git a/gtk/__init__.py b/gtk/__init__.py
index 222b8bf4..5ed3bca2 100644
--- a/gtk/__init__.py
+++ b/gtk/__init__.py
@@ -123,4 +123,7 @@ FALSE = _DeprecatedConstant(False, 'gtk.FALSE', 'False')
_gobject = _GObjectWrapper('gtk._gobject')
+# Can't figure out how to deprecate gdk.Warning
+gdk.Warning = Warning
+
del _Deprecated, _DeprecatedConstant, _GObjectWrapper, _module,
diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c
index 05b4153c..3082f534 100644
--- a/gtk/gtkmodule.c
+++ b/gtk/gtkmodule.c
@@ -255,6 +255,15 @@ init_gtk(void)
g_slist_free_1(cur);
}
+ 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);
d = PyModule_GetDict(m);
@@ -283,11 +292,6 @@ g_free(aname); }
add_atom(SELECTION_TYPE_WINDOW);
add_atom(SELECTION_TYPE_STRING);
#undef add_atom
-
- 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);
gtk_timeout_add(100, python_do_pending_calls, NULL);
}
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);
}