2005-10-27 15:54:32 +00:00
|
|
|
/* -*- Mode: C -*- */
|
2005-09-28 14:34:52 +00:00
|
|
|
/* gst-python
|
|
|
|
* Copyright (C) 2005 Edward Hervey
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Author: Edward Hervey <edward@fluendo.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
%%
|
|
|
|
ignore
|
|
|
|
gst_object_default_deep_notify
|
|
|
|
gst_object_check_uniqueness
|
|
|
|
gst_object_replace
|
|
|
|
|
|
|
|
%%
|
|
|
|
override-attr GstObject.__gstrefcount__
|
|
|
|
|
|
|
|
/* keep this attribute around even after 2.8 for compatibility reasons */
|
|
|
|
static PyObject *
|
2005-10-27 15:54:32 +00:00
|
|
|
_wrap_gst_object__get___gstrefcount__ (PyGObject * self, void *closure)
|
2005-09-28 14:34:52 +00:00
|
|
|
{
|
2005-10-27 15:54:32 +00:00
|
|
|
return PyInt_FromLong (GST_OBJECT_REFCOUNT_VALUE (self->obj));
|
2005-09-28 14:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override-slot GstObject.tp_repr
|
|
|
|
static PyObject *
|
2005-10-27 15:54:32 +00:00
|
|
|
_wrap_gst_object_tp_repr (PyObject * self)
|
2005-09-28 14:34:52 +00:00
|
|
|
{
|
2005-10-27 15:54:32 +00:00
|
|
|
gchar *repr;
|
|
|
|
PyObject *ret;
|
|
|
|
GstObject *object = GST_OBJECT (pygobject_get (self));
|
|
|
|
|
|
|
|
repr = g_strdup_printf ("<%s object (%s) at 0x%lx>",
|
|
|
|
self->ob_type->tp_name,
|
|
|
|
GST_OBJECT_NAME (object) ? GST_OBJECT_NAME (object) : "unnamed",
|
|
|
|
(long) self);
|
|
|
|
ret = PyString_FromString (repr);
|
|
|
|
g_free (repr);
|
|
|
|
return ret;
|
2005-09-28 14:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override-slot GstObject.tp_str
|
|
|
|
static PyObject *
|
2005-10-27 15:54:32 +00:00
|
|
|
_wrap_gst_object_tp_str (PyObject * self)
|
2005-09-28 14:34:52 +00:00
|
|
|
{
|
2005-10-27 15:54:32 +00:00
|
|
|
gchar *repr, *path;
|
|
|
|
PyObject *ret;
|
|
|
|
GstObject *object = GST_OBJECT (pygobject_get (self));
|
|
|
|
|
2007-10-13 16:32:52 +00:00
|
|
|
pyg_begin_allow_threads;
|
2005-10-27 15:54:32 +00:00
|
|
|
path = gst_object_get_path_string (object);
|
2007-10-13 16:32:52 +00:00
|
|
|
pyg_end_allow_threads;
|
|
|
|
|
2005-10-27 15:54:32 +00:00
|
|
|
repr = g_strdup_printf ("%s (%s)", path, self->ob_type->tp_name);
|
|
|
|
ret = PyString_FromString (repr);
|
|
|
|
g_free (repr);
|
|
|
|
g_free (path);
|
|
|
|
return ret;
|
2005-09-28 14:34:52 +00:00
|
|
|
}
|
2007-01-11 17:45:46 +00:00
|
|
|
%%
|
|
|
|
override gst_object_set_property args
|
|
|
|
|
|
|
|
/*
|
|
|
|
* REMOVE THE FOLLOWING CODE, once pygobject has fixed the issue of not
|
|
|
|
* releasing the GIL when calling g_object_set_property.
|
|
|
|
*
|
|
|
|
* See bug #395048 : set_property() doesn't release the GIL
|
|
|
|
**/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
set_property_from_pspec(GObject *obj,
|
|
|
|
char *attr_name,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
PyObject *pvalue)
|
|
|
|
{
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
|
|
|
if (pspec->flags & G_PARAM_CONSTRUCT_ONLY) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"property '%s' can only be set in constructor",
|
|
|
|
attr_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pspec->flags & G_PARAM_WRITABLE)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"property '%s' is not writable", attr_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
|
2007-01-17 06:15:33 +00:00
|
|
|
/* FIXME: bug in pygtk 2.8 series; see
|
|
|
|
http://svn.gnome.org/viewcvs/pygobject/trunk/gobject/pygobject.h?rev=566&r1=564&r2=566 */
|
|
|
|
|
|
|
|
#ifndef PYGOBJECT_2_12
|
|
|
|
#undef pyg_param_gvalue_from_pyobject
|
|
|
|
#define pyg_param_gvalue_from_pyobject (_PyGObject_API->gvalue_from_param_pyobject)
|
|
|
|
#endif
|
|
|
|
|
2007-01-11 17:45:46 +00:00
|
|
|
if (pyg_param_gvalue_from_pyobject(&value, pvalue, pspec) < 0) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"could not convert argument to correct param type");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pyg_begin_allow_threads;
|
|
|
|
g_object_set_property(obj, attr_name, &value);
|
|
|
|
pyg_end_allow_threads;
|
|
|
|
|
|
|
|
g_value_unset(&value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_object_set_property(PyGObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
gchar *param_name;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
PyObject *pvalue;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "sO:gst.Object.set_property", ¶m_name,
|
|
|
|
&pvalue))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!GST_IS_OBJECT (self->obj)) {
|
|
|
|
PyErr_Format (PyExc_TypeError,
|
|
|
|
"object at %p of type %s is not initialized",
|
|
|
|
self, self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(self->obj),
|
|
|
|
param_name);
|
|
|
|
if (!pspec) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"object of type `%s' does not have property `%s'",
|
|
|
|
g_type_name(G_OBJECT_TYPE(self->obj)), param_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!set_property_from_pspec(self->obj, param_name, pspec, pvalue))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|