summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorPaul Pogonyshev <pogonyshev@gmx.net>2009-06-20 22:46:19 +0300
committerPaul Pogonyshev <pogonyshev@gmx.net>2009-06-20 23:38:13 +0300
commit6562cd8fb5e0d930463c98ab29a209bd33db7f60 (patch)
treef43ad4405b511df366db256f55d02f8557625896 /gtk
parent727ce3bc0050ac5021a1b824e17c8443f385fbc0 (diff)
downloadpygtk-6562cd8fb5e0d930463c98ab29a209bd33db7f60.tar.gz
Add backward compatibility to gtk.gdk.Pixbuf.add_alpha
Accept chars in addition to integers to avoid breaking existing uses. Noticed while testing bug #583658.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gdkpixbuf.override39
1 files changed, 39 insertions, 0 deletions
diff --git a/gtk/gdkpixbuf.override b/gtk/gdkpixbuf.override
index 3e62e988..39341194 100644
--- a/gtk/gdkpixbuf.override
+++ b/gtk/gdkpixbuf.override
@@ -768,3 +768,42 @@ _wrap_gdk_pixbuf_get_from_drawable2(PyObject *self,
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
+%%
+override gdk_pixbuf_add_alpha kwargs
+/* Old declaration accepted characters as 'r', 'g' and 'b' arguments.
+ * However, that is flawed, as GTK+ in this case meant '8-bit
+ * integers', not 'characters'. Override is needed to provide
+ * backward compatibility for already existing uses. */
+static PyObject *
+_wrap_gdk_pixbuf_add_alpha(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "substitute_color", "r", "g", "b", NULL };
+ int substitute_color, r, g, b;
+ PyObject *py_ret;
+ GdkPixbuf *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiii:gdk.Pixbuf.add_alpha", kwlist,
+ &substitute_color, &r, &g, &b)) {
+ /* Backward compatibility. */
+ PyObject *exc_type, *exc_value, *exc_traceback;
+
+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iccc:gdk.Pixbuf.add_alpha", kwlist,
+ &substitute_color, &r, &g, &b)) {
+ PyErr_Restore(exc_type, exc_value, exc_traceback);
+ return NULL;
+ }
+
+ Py_XDECREF(exc_type);
+ Py_XDECREF(exc_value);
+ Py_XDECREF(exc_traceback);
+ }
+
+ ret = gdk_pixbuf_add_alpha(GDK_PIXBUF(self->obj), substitute_color, r, g, b);
+
+ py_ret = pygobject_new((GObject *)ret);
+ if (ret != NULL)
+ g_object_unref(ret);
+ return py_ret;
+}