pygtk r3012 - in trunk: . docs/reference gtk
- From: paulp svn gnome org
- To: svn-commits-list gnome org
- Subject: pygtk r3012 - in trunk: . docs/reference gtk
- Date: Sat, 26 Jul 2008 19:02:34 +0000 (UTC)
Author: paulp
Date: Sat Jul 26 19:02:33 2008
New Revision: 3012
URL: http://svn.gnome.org/viewvc/pygtk?rev=3012&view=rev
Log:
2008-07-26 Paul Pogonyshev <pogonyshev gmx net>
* gtk/gtkbuilder.override (PyGCustomSignalNotify): Add
'missing_handlers' (Python list) and 'exception_pending' (boolean)
fields.
(connect_many, _wrap_gtk_builder_connect_signals): Warn user on
missing handlers and set/modify new fields as appropriate (bug
#543768).
2008-07-26 Paul Pogonyshev <pogonyshev gmx net>
* pygtk-gtkbuilder.xml (connect_signals): Fix signature and
document changes in 2.14.
Modified:
trunk/ChangeLog
trunk/docs/reference/ChangeLog
trunk/docs/reference/pygtk-gtkbuilder.xml
trunk/gtk/gtkbuilder.override
Modified: trunk/docs/reference/pygtk-gtkbuilder.xml
==============================================================================
--- trunk/docs/reference/pygtk-gtkbuilder.xml (original)
+++ trunk/docs/reference/pygtk-gtkbuilder.xml Sat Jul 26 19:02:33 2008
@@ -29,6 +29,7 @@
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkbuilder--connect-signals">connect_signals</link></methodname>
+ <methodparam><parameter role="keyword">object</parameter></methodparam>
<methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<!-- NOT YET IMPLEMENTED <methodsynopsis language="python">
@@ -395,7 +396,19 @@
and tries to match them with the signal handler names given in the interface description.
The callbacks referenced by each matched key or attribute are connected to their matching signals.
</para>
- </refsect2>
+
+ <para>
+ For each of handlers that cannot be found, a <classname>RuntimeWarning</classname>
+ is issued. Also, if there is at least one such missing handler,
+ <methodname>connect_signals</methodname> will return a list of their names,
+ else return value is None.
+ </para>
+
+ <note>
+ <para><classname>RuntimeWarning</classname> and return value for missing
+ handlers was added in PyGTK 2.14.</para>
+ </note>
+ </refsect2>
<refsect2 id="method-gtkbuilder--get-object">
<title>gtk.Builder.get_object</title>
Modified: trunk/gtk/gtkbuilder.override
==============================================================================
--- trunk/gtk/gtkbuilder.override (original)
+++ trunk/gtk/gtkbuilder.override Sat Jul 26 19:02:33 2008
@@ -26,6 +26,8 @@
typedef struct{
PyObject *obj;
PyObject *data;
+ PyObject *missing_handlers;
+ gboolean exception_pending;
} PyGCustomSignalNotify;
%%
@@ -40,12 +42,33 @@
PyObject *tuple, *self;
GClosure *closure = NULL;
+ if (notify->exception_pending)
+ return;
+
tuple = PyMapping_GetItemString(handler_dict, (gchar *)handler_name);
if (!tuple) {
PyErr_Clear();
tuple = PyObject_GetAttrString(handler_dict, (gchar *)handler_name);
if (!tuple) {
+ gchar *error_message;
+ PyObject *name_obj;
+
PyErr_Clear();
+
+ name_obj = PyString_FromString(handler_name);
+ PyList_Append(notify->missing_handlers, name_obj);
+ Py_DECREF(name_obj);
+
+ error_message = g_strdup_printf("missing handler '%s'", handler_name);
+ if (PyErr_Warn(NULL, error_message)) {
+ /* PyErr_Warn requests us to raise the warning as exception. That can
+ * happen when user explicitly used warnings.filterwarnings('error'...).
+ * So, we will not call any Python code anymore and raise the exception
+ * from connect_signals(). */
+ notify->exception_pending = TRUE;
+ }
+
+ g_free(error_message);
return;
}
}
@@ -94,12 +117,27 @@
notify.obj = object;
notify.data = user_data;
+ notify.missing_handlers = PyList_New(0);
+ notify.exception_pending = FALSE;
+
+ if (!notify.missing_handlers)
+ return NULL;
gtk_builder_connect_signals_full(GTK_BUILDER(self->obj),
connect_many,
¬ify);
- Py_INCREF(Py_None);
- return Py_None;
+
+ if (notify.exception_pending) {
+ Py_DECREF(notify.missing_handlers);
+ return NULL;
+ }
+ else if (PyObject_IsTrue(notify.missing_handlers))
+ return notify.missing_handlers;
+ else {
+ Py_DECREF(notify.missing_handlers);
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
}
%%
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]