Commit 764caf77 authored by Erik Walthinsen's avatar Erik Walthinsen

added shim for g_object_class_list_properties and converted -inspect and -compprep to use it

Original commit message from CVS:
added shim for g_object_class_list_properties and converted -inspect and -compprep to use it
parent 01e05ff1
......@@ -108,6 +108,28 @@ g_object_class_find_property(GtkObjectClass *class,gchar *name)
return spec;
}
GParamSpec **
g_object_class_list_properties(GtkObjectClass *oclass,guint *n_properties) {
GType type = G_OBJECT_CLASS_TYPE (oclass);
guint32 *flags;
GtkArg *args;
gint num_args;
GParamSpec **params;
int i;
args = gtk_object_query_args (type, &flags, &num_args);
params = g_new0(GParamSpec *,num_args);
for (i=0;i<num_args;i++) {
params[i] = g_new0(GParamSpec,1);
params[i]->name = args[i].name;
params[i]->value_type = args[i].type;
params[i]->flags = flags[i];
}
return params;
}
GParamSpec *
g_param_spec_boolean(gchar *name,gchar *nick,gchar *blurb,gboolean def,gint flags) {
GParamSpec *spec = g_new(GParamSpec,1);
......
......@@ -189,6 +189,7 @@ struct _GParamSpec {
void g_object_class_install_property(GtkObjectClass *oclass,guint property_id,GParamSpec *pspec);
GParamSpec *g_object_class_find_property(GtkObjectClass *oclass,gchar *name);
GParamSpec **g_object_class_list_properties(GtkObjectClass *oclass,guint *n_properties);
#define G_IS_PARAM_SPEC_ENUM(pspec) (GTK_FUNDAMENTAL_TYPE(pspec->value_type) == GTK_TYPE_ENUM)
......
......@@ -11,7 +11,6 @@ int main(int argc,char *argv[]) {
GstPad *pad;
GstPadTemplate *padtemplate;
GParamSpec **property_specs;
guint32 *flags;
gint num_properties,i;
gst_debug_set_categories(0);
......@@ -64,24 +63,9 @@ int main(int argc,char *argv[]) {
}
// write out the args
#ifdef USE_GLIB2
// FIXME accessing private data of GObjectClass !!!
num_properties = G_OBJECT_GET_CLASS (element)->n_property_specs;
property_specs = G_OBJECT_GET_CLASS (element)->property_specs;
#else
property_specs = (GParamSpec **)gtk_object_query_args (GTK_OBJECT_TYPE (element), &flags, &num_properties);
#endif
property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
for (i=0;i<num_properties;i++) {
#ifdef USE_GLIB2
GParamSpec *param = property_specs[i];
#else
// gtk doesn't have a paramspec, so we create one here
GParamSpec rparm, *param = &rparm;
GtkArg *args = (GtkArg *)property_specs; // ugly typecast here
param->value_type = args[i].type;
param->name = args[i].name;
#endif
argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
if (param->value_type == GST_TYPE_FILENAME) {
xmlNewChild (argnode, NULL, "filename", NULL);
......
......@@ -80,7 +80,6 @@ print_element_info (GstElementFactory *factory)
GstPad *pad;
GstRealPad *realpad;
GstPadTemplate *padtemplate;
guint32 *flags;
gint num_properties,i;
GParamSpec **property_specs;
GList *children;
......@@ -254,27 +253,12 @@ print_element_info (GstElementFactory *factory)
} else
printf(" none\n");
#ifdef USE_GLIB2
// FIXME accessing private data of GObjectClass !!!
num_properties = G_OBJECT_GET_CLASS (element)->n_property_specs;
property_specs = G_OBJECT_GET_CLASS (element)->property_specs;
#else
property_specs = (GParamSpec **)gtk_object_query_args (GTK_OBJECT_TYPE (element), &flags, &num_properties);
#endif
property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
printf("\nElement Arguments:\n");
for (i=0;i<num_properties;i++) {
GValue value = { 0, };
#ifdef USE_GLIB2
GParamSpec *param = property_specs[i];
#else
// gtk doesn't have a paramspec, so we create one here
GParamSpec rparm, *param = &rparm;
GtkArg *args = (GtkArg *)property_specs; // ugly typecast here
param->value_type = args[i].type;
param->name = args[i].name;
#endif
g_value_init (&value, param->value_type);
g_object_get_property (G_OBJECT (element), param->name, &value);
......
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