mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
childproxy: make get_child_by_name virtual
Allows implementations to use custom name->object mappings.
This commit is contained in:
parent
bd625b8152
commit
ef48cff3d0
2 changed files with 40 additions and 21 deletions
|
@ -39,9 +39,7 @@
|
|||
* "child1" and "child2" implement the #GstChildProxy interface.
|
||||
*/
|
||||
/* FIXME-0.11:
|
||||
* it would be nice to make gst_child_proxy_get_child_by_name virtual too and
|
||||
* use GObject instead of GstObject. We could eventually provide the current
|
||||
* implementation as a default if children are GstObjects.
|
||||
* it would be nice to use GObject instead of GstObject.
|
||||
* This change would allow to propose the interface for inclusion with
|
||||
* glib/gobject. IMHO this is useful for GtkContainer and compound widgets too.
|
||||
*/
|
||||
|
@ -61,22 +59,9 @@ enum
|
|||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/**
|
||||
* gst_child_proxy_get_child_by_name:
|
||||
* @parent: the parent object to get the child from
|
||||
* @name: the childs name
|
||||
*
|
||||
* Looks up a child element by the given name.
|
||||
*
|
||||
* Implementors can use #GstObject together with gst_object_get_name()
|
||||
*
|
||||
* Returns: (transfer full): the child object or %NULL if not found. Unref
|
||||
* after usage.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
GstObject *
|
||||
gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name)
|
||||
static GstObject *
|
||||
gst_child_proxy_default_get_child_by_name (GstChildProxy * parent,
|
||||
const gchar * name)
|
||||
{
|
||||
guint count, i;
|
||||
GstObject *object, *result;
|
||||
|
@ -113,6 +98,30 @@ gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_child_proxy_get_child_by_name:
|
||||
* @parent: the parent object to get the child from
|
||||
* @name: the childs name
|
||||
*
|
||||
* Looks up a child element by the given name.
|
||||
*
|
||||
* Implementors can use #GstObject together with gst_object_get_name()
|
||||
*
|
||||
* Returns: (transfer full): the child object or %NULL if not found. Unref
|
||||
* after usage.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
GstObject *
|
||||
gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0);
|
||||
|
||||
return (GST_CHILD_PROXY_GET_INTERFACE (parent)->get_child_by_name (parent,
|
||||
name));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_child_proxy_get_child_by_index:
|
||||
* @parent: the parent object to get the child from
|
||||
|
@ -467,6 +476,14 @@ gst_child_proxy_child_removed (GstObject * object, GstObject * child)
|
|||
|
||||
/* gobject methods */
|
||||
|
||||
static void
|
||||
gst_child_proxy_class_init (gpointer g_class, gpointer class_data)
|
||||
{
|
||||
GstChildProxyInterface *iface = (GstChildProxyInterface *) g_class;
|
||||
|
||||
iface->get_child_by_name = gst_child_proxy_default_get_child_by_name;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_child_proxy_base_init (gpointer g_class)
|
||||
{
|
||||
|
@ -515,7 +532,7 @@ gst_child_proxy_get_type (void)
|
|||
sizeof (GstChildProxyInterface),
|
||||
gst_child_proxy_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
gst_child_proxy_class_init, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0,
|
||||
|
|
|
@ -44,7 +44,8 @@ typedef struct _GstChildProxyInterface GstChildProxyInterface;
|
|||
/**
|
||||
* GstChildProxyInterface:
|
||||
* @parent: parent interface type.
|
||||
* @get_child_by_index: virtual method to fetch the child
|
||||
* @get_child_by_name: virtual method to fetch the child by name
|
||||
* @get_child_by_index: virtual method to fetch the child by index
|
||||
* @get_children_count: virtual method to get the children count
|
||||
*
|
||||
* #GstChildProxy interface.
|
||||
|
@ -54,6 +55,7 @@ struct _GstChildProxyInterface
|
|||
GTypeInterface parent;
|
||||
|
||||
/* methods */
|
||||
GstObject * (*get_child_by_name) (GstChildProxy * parent, const gchar * name);
|
||||
GstObject * (*get_child_by_index) (GstChildProxy * parent, guint index);
|
||||
guint (*get_children_count) (GstChildProxy * parent);
|
||||
/*< private >*/
|
||||
|
|
Loading…
Reference in a new issue