Commit 98d6484e authored by Johan Dahlin's avatar Johan Dahlin Committed by Edward Hervey

New 'fancy' constructor for gst.Element, allows creating elements in a more...

New 'fancy' constructor for gst.Element, allows creating elements in a more pythonic way (i.e. myelement = gst.Elemen...

Original commit message from CVS:
Patch by: Johan Dahlin  <johan at gnome dot org>
* gst/__init__.py:
* gst/gstelement.override:
* testsuite/test_element.py:
New 'fancy' constructor for gst.Element, allows creating elements in a
more pythonic way (i.e. myelement = gst.Element("oggmux")).
Fixes #530417
parent 5119268c
2008-05-08 Edward Hervey <edward.hervey@collabora.co.uk>
Patch by: Johan Dahlin <johan at gnome dot org>
* gst/__init__.py:
* gst/gstelement.override:
* testsuite/test_element.py:
New 'fancy' constructor for gst.Element, allows creating elements in a
more pythonic way (i.e. myelement = gst.Element("oggmux")).
Fixes #530417
2008-05-08 Edward Hervey <edward.hervey@collabora.co.uk>
* gst/__init__.py:
......
......@@ -148,6 +148,14 @@ if RTLD_GLOBAL != -1 and RTLD_LAZY != -1:
except:
pass
import gobject
from _gst import _install_element_meta
_GstElementBaseMeta = getattr(gobject, 'GObjectMeta', type)
class _GstElementMeta(_GstElementBaseMeta):
__call__ = element_factory_make
_install_element_meta(_GstElementMeta)
version = get_gst_version
sys.setdlopenflags(dlsave)
......
......@@ -26,6 +26,22 @@ ignore
gst_element_get_property
gst_element_set_property
%%
define _install_element_meta
static PyObject *
_wrap__install_element_meta(PyObject *self, PyObject *args)
{
PyObject *metaclass;
if (!PyArg_ParseTuple(args, "O", &metaclass))
return NULL;
Py_INCREF(metaclass);
PyGstElement_Type.ob_type = (PyTypeObject*)metaclass;
Py_INCREF(Py_None);
return Py_None;
}
%%
override gst_element_get_pad_template args
static PyObject *
_wrap_gst_element_get_pad_template(PyGObject *self, PyObject *args)
......
......@@ -40,6 +40,12 @@ class ElementTest(TestCase):
assert isinstance(element, gst.Element)
assert element.get_name() == self.alias
def testFancyConstructor(self):
element = gst.Element(self.name, self.alias)
self.failUnless(element, 'element is None')
self.failUnless(isinstance(element, gst.Element))
self.assertEquals(element.get_name(), self.alias)
## FIXME : Make a new test for state changes, using bus signals
## class FakeSinkTest(ElementTest):
......@@ -147,6 +153,7 @@ class NonExistentTest(ElementTest):
testGoodConstructor = lambda s: None
testGoodConstructor2 = lambda s: None
testFancyConstructor = lambda s: None
class FileSrcTest(ElementTest):
name = 'filesrc'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment