3 * Copyright (C) 2005 Edward Hervey
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Edward Hervey <edward@fluendo.com>
25 gst_object_default_deep_notify
26 gst_object_check_uniqueness
30 override-attr GstObject.__gstrefcount__
32 /* keep this attribute around even after 2.8 for compatibility reasons */
34 _wrap_gst_object__get___gstrefcount__ (PyGObject * self, void *closure)
36 return PyInt_FromLong (GST_OBJECT_REFCOUNT_VALUE (self->obj));
40 override-slot GstObject.tp_repr
42 _wrap_gst_object_tp_repr (PyObject * self)
46 GstObject *object = GST_OBJECT (pygobject_get (self));
48 repr = g_strdup_printf ("<%s object (%s) at 0x%lx>",
49 self->ob_type->tp_name,
51 GST_OBJECT_NAME (object) ? GST_OBJECT_NAME (object) : "unnamed"
54 ret = PyString_FromString (repr);
60 override-slot GstObject.tp_str
62 _wrap_gst_object_tp_str (PyObject * self)
66 GstObject *object = GST_OBJECT (pygobject_get (self));
68 pyg_begin_allow_threads;
69 path = gst_object_get_path_string (object);
70 pyg_end_allow_threads;
72 repr = g_strdup_printf ("%s (%s)", path, self->ob_type->tp_name);
73 ret = PyString_FromString (repr);
79 override gst_object_set_property args
82 * REMOVE THE FOLLOWING CODE, once pygobject has fixed the issue of not
83 * releasing the GIL when calling g_object_set_property.
85 * See bug #395048 : set_property() doesn't release the GIL
89 set_property_from_pspec(GObject *obj,
94 GValue value = { 0, };
96 if (pspec->flags & G_PARAM_CONSTRUCT_ONLY) {
97 PyErr_Format(PyExc_TypeError,
98 "property '%s' can only be set in constructor",
103 if (!(pspec->flags & G_PARAM_WRITABLE)) {
104 PyErr_Format(PyExc_TypeError,
105 "property '%s' is not writable", attr_name);
109 g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
110 /* FIXME: bug in pygtk 2.8 series; see
111 http://svn.gnome.org/viewcvs/pygobject/trunk/gobject/pygobject.h?rev=566&r1=564&r2=566 */
113 #ifndef PYGOBJECT_2_12
114 #undef pyg_param_gvalue_from_pyobject
115 #define pyg_param_gvalue_from_pyobject (_PyGObject_API->gvalue_from_param_pyobject)
118 if (pyg_param_gvalue_from_pyobject(&value, pvalue, pspec) < 0) {
119 PyErr_SetString(PyExc_TypeError,
120 "could not convert argument to correct param type");
124 pyg_begin_allow_threads;
125 g_object_set_property(obj, attr_name, &value);
126 pyg_end_allow_threads;
128 g_value_unset(&value);
134 _wrap_gst_object_set_property(PyGObject *self, PyObject *args)
140 if (!PyArg_ParseTuple(args, "sO:gst.Object.set_property", ¶m_name,
144 if (!GST_IS_OBJECT (self->obj)) {
145 PyErr_Format (PyExc_TypeError,
146 "object at %p of type %s is not initialized",
147 self, self->ob_type->tp_name);
151 pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(self->obj),
154 PyErr_Format(PyExc_TypeError,
155 "object of type `%s' does not have property `%s'",
156 g_type_name(G_OBJECT_TYPE(self->obj)), param_name);
160 if (!set_property_from_pspec(self->obj, param_name, pspec, pvalue))