summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-08-21 17:16:31 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2014-08-21 17:18:58 -0700
commit983276fb1cbc261d062ef93ba2266d08a5a6f423 (patch)
tree92275681206f6c51a70c8091bc5997ce4e51e5c6
parentb7a4e68a224ab66f67e45667023f74dd743e6177 (diff)
downloadpygobject-983276fb1cbc261d062ef93ba2266d08a5a6f423.tar.gz
Revert "Replace statically bound GLib.Variant.new_tuple() with GI"
This was accidentally pushed. Revert commit 35c6540c42a01e1155f44533cc09e6c9f94b6613.
-rw-r--r--gi/gimodule.c39
-rw-r--r--gi/overrides/GLib.py12
2 files changed, 46 insertions, 5 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index de9b787f..a18c477f 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -470,6 +470,44 @@ _wrap_pyg_has_vfunc_implementation (PyObject *self, PyObject *args)
#endif
static PyObject *
+_wrap_pyg_variant_new_tuple (PyObject *self, PyObject *args)
+{
+ PyObject *py_values;
+ GVariant **values = NULL;
+ GVariant *variant = NULL;
+ PyObject *py_variant = NULL;
+ PyObject *py_type;
+ gssize i;
+
+ if (!PyArg_ParseTuple (args, "O!:variant_new_tuple",
+ &PyTuple_Type, &py_values)) {
+ return NULL;
+ }
+
+ py_type = _pygi_type_import_by_name ("GLib", "Variant");
+
+ values = g_newa (GVariant*, PyTuple_Size (py_values));
+
+ for (i = 0; i < PyTuple_Size (py_values); i++) {
+ PyObject *value = PyTuple_GET_ITEM (py_values, i);
+
+ if (!PyObject_IsInstance (value, py_type)) {
+ PyErr_Format (PyExc_TypeError, "argument %" G_GSSIZE_FORMAT " is not a GLib.Variant", i);
+ return NULL;
+ }
+
+ values[i] = pyg_pointer_get (value, GVariant);
+ }
+
+ variant = g_variant_new_tuple (values, PyTuple_Size (py_values));
+ g_variant_ref_sink (variant);
+
+ py_variant = _pygi_struct_new ( (PyTypeObject *) py_type, variant, FALSE);
+
+ return py_variant;
+}
+
+static PyObject *
_wrap_pyg_variant_type_from_string (PyObject *self, PyObject *args)
{
char *type_string;
@@ -579,6 +617,7 @@ static PyMethodDef _gi_functions[] = {
{ "register_interface_info", (PyCFunction) _wrap_pyg_register_interface_info, METH_VARARGS },
{ "hook_up_vfunc_implementation", (PyCFunction) _wrap_pyg_hook_up_vfunc_implementation, METH_VARARGS },
+ { "variant_new_tuple", (PyCFunction) _wrap_pyg_variant_new_tuple, METH_VARARGS },
{ "variant_type_from_string", (PyCFunction) _wrap_pyg_variant_type_from_string, METH_VARARGS },
{ "source_new", (PyCFunction) _wrap_pyg_source_new, METH_NOARGS },
{ "source_set_callback", (PyCFunction) pyg_source_set_callback, METH_VARARGS },
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index ce15da1f..e72ed36c 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -24,7 +24,7 @@ import warnings
import sys
from ..module import get_introspection_module
-from .._gi import (variant_type_from_string, source_new,
+from .._gi import (variant_new_tuple, variant_type_from_string, source_new,
source_set_callback, io_channel_read)
from ..overrides import override, deprecated
from gi import PyGIDeprecationWarning, version_info
@@ -243,10 +243,6 @@ class Variant(GLib.Variant):
v.format_string = format_string
return v
- @staticmethod
- def new_tuple(*elements):
- return GLib.Variant.new_tuple(elements)
-
def __del__(self):
self.unref()
@@ -461,10 +457,16 @@ class Variant(GLib.Variant):
return res
+@classmethod
+def new_tuple(cls, *elements):
+ return variant_new_tuple(elements)
+
+
def get_string(self):
value, length = GLib.Variant.get_string(self)
return value
+setattr(Variant, 'new_tuple', new_tuple)
setattr(Variant, 'get_string', get_string)
__all__.append('Variant')