Added a utility function in gstutils to set an object argument as a string. gstparse.c and gstelement.c now use this ...

Original commit message from CVS:
Added a utility function in gstutils to set an object argument as a
string. gstparse.c and gstelement.c now use this function.
This commit is contained in:
Wim Taymans 2001-03-03 16:30:10 +00:00
parent ca4e87219c
commit 2fd9de4142
3 changed files with 6 additions and 72 deletions

View file

@ -972,78 +972,8 @@ gst_element_load_thyself (xmlNodePtr self, GstObject *parent)
}
child = child->next;
}
if (name && value) {
GtkType type = GTK_OBJECT_TYPE (element);
GtkArgInfo *info;
gchar *result;
result = gtk_object_arg_get_info (type, name, &info);
if (result) {
g_print("gstelement: %s\n", result);
}
else if (info->arg_flags & GTK_ARG_WRITABLE) {
switch (info->type) {
case GTK_TYPE_STRING:
gtk_object_set (GTK_OBJECT (element), name, value, NULL);
break;
case GTK_TYPE_INT: {
gint i;
sscanf (value, "%d", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_LONG: {
glong i;
sscanf (value, "%ld", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_ULONG: {
gulong i;
sscanf (value, "%lu", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_BOOL: {
gboolean i = FALSE;
if (!strcmp ("true", value)) i = TRUE;
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_CHAR: {
gchar i;
sscanf (value, "%c", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_UCHAR: {
guchar i;
sscanf (value, "%c", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_FLOAT: {
gfloat i;
sscanf (value, "%f", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_DOUBLE: {
gdouble i;
sscanf (value, "%g", (float *)&i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
default:
if (info->type == GST_TYPE_FILENAME) {
gtk_object_set (GTK_OBJECT (element), name, value, NULL);
}
break;
}
}
}
gst_util_set_object_arg (GTK_OBJECT (element), name, value);
}
children = children->next;
}

View file

@ -30,6 +30,7 @@
#include "gstparse.h"
#include "gstpipeline.h"
#include "gstthread.h"
#include "gstutils.h"
typedef struct _gst_parse_priv gst_parse_priv;
struct _gst_parse_priv {
@ -180,7 +181,8 @@ if (GST_IS_GHOST_PAD(srcpad)) GST_DEBUG(0,"it's a ghost pad\n");
argval = pos+1;
DEBUG("attempting to set argument '%s' to '%s' on element '%s'\n",
argname,argval,GST_ELEMENT_NAME(previous));
gtk_object_set(GTK_OBJECT(previous),argname,argval,NULL);
//gtk_object_set(GTK_OBJECT(previous),argname,argval,NULL);
gst_util_set_object_arg (GTK_OBJECT(previous), argname, argval);
g_free(argname);
// element or argument, or beginning of bin or thread

View file

@ -39,6 +39,8 @@ guchar* gst_util_get_string_arg (GtkObject *object, guchar *argname);
gpointer gst_util_get_pointer_arg (GtkObject *object, guchar *argname);
GtkWidget* gst_util_get_widget_arg (GtkObject *object, guchar *argname);
void gst_util_set_object_arg (GtkObject *object, guchar *name, gchar *value);
void gst_util_dump_mem (guchar *mem, guint size);
#ifdef __cplusplus