Also handle WRITEONLY properties

Original commit message from CVS:
Also handle WRITEONLY properties
This commit is contained in:
Wim Taymans 2002-09-19 18:14:09 +00:00
parent 1e17763c6e
commit c4f01ba01e

View file

@ -8,7 +8,7 @@ print_prop (GstPropsEntry *prop, gboolean showname, const gchar *pfx)
GstPropsType type; GstPropsType type;
if (showname) if (showname)
g_print("%s%s: ", pfx, gst_props_entry_get_name (prop)); g_print("%s%-20.20s: ", pfx, gst_props_entry_get_name (prop));
else else
g_print(pfx); g_print(pfx);
@ -54,7 +54,7 @@ print_prop (GstPropsEntry *prop, gboolean showname, const gchar *pfx)
{ {
const gchar *val; const gchar *val;
gst_props_entry_get_string (prop, &val); gst_props_entry_get_string (prop, &val);
g_print("String: %s\n", val); g_print("String: \"%s\"\n", val);
break; break;
} }
case GST_PROPS_FOURCC_TYPE: case GST_PROPS_FOURCC_TYPE:
@ -247,6 +247,8 @@ print_element_properties (GstElement *element)
{ {
GParamSpec **property_specs; GParamSpec **property_specs;
gint num_properties,i; gint num_properties,i;
gboolean readable;
property_specs = g_object_class_list_properties property_specs = g_object_class_list_properties
(G_OBJECT_GET_CLASS (element), &num_properties); (G_OBJECT_GET_CLASS (element), &num_properties);
@ -255,10 +257,12 @@ print_element_properties (GstElement *element)
for (i = 0; i < num_properties; i++) { for (i = 0; i < num_properties; i++) {
GValue value = { 0, }; GValue value = { 0, };
GParamSpec *param = property_specs[i]; GParamSpec *param = property_specs[i];
readable = FALSE;
if (param->flags & G_PARAM_READABLE) {
g_value_init (&value, param->value_type); g_value_init (&value, param->value_type);
if (param->flags & G_PARAM_READABLE) {
g_object_get_property (G_OBJECT (element), param->name, &value); g_object_get_property (G_OBJECT (element), param->name, &value);
readable = TRUE;
} }
g_print(" %-20s: %s\n", g_param_spec_get_name (param), g_print(" %-20s: %s\n", g_param_spec_get_name (param),
@ -266,50 +270,58 @@ print_element_properties (GstElement *element)
switch (G_VALUE_TYPE (&value)) { switch (G_VALUE_TYPE (&value)) {
case G_TYPE_STRING: case G_TYPE_STRING:
g_print ("%-23.23s String (Default \"%s\")", "", g_value_get_string (&value)); g_print ("%-23.23s String. ", "");
if (readable) g_print ("(Default \"%s\")", g_value_get_string (&value));
break; break;
case G_TYPE_BOOLEAN: case G_TYPE_BOOLEAN:
g_print ("%-23.23s Boolean (Default %s)", "", (g_value_get_boolean (&value) ? "true" : "false")); g_print ("%-23.23s Boolean. ", "");
if (readable) g_print ("(Default %s)", (g_value_get_boolean (&value) ? "true" : "false"));
break; break;
case G_TYPE_ULONG: case G_TYPE_ULONG:
{ {
GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
g_print("%-23.23s Unsigned Long. Range: %lu - %lu (Default %lu)", "", g_print("%-23.23s Unsigned Long. ", "");
if (readable) g_print("Range: %lu - %lu (Default %lu)",
pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
break; break;
} }
case G_TYPE_LONG: case G_TYPE_LONG:
{ {
GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
g_print("%-23.23s Long. Range: %ld - %ld (Default %ld)", "", g_print("%-23.23s Long. ", "");
if (readable) g_print("Range: %ld - %ld (Default %ld)",
plong->minimum, plong->maximum, g_value_get_long (&value)); plong->minimum, plong->maximum, g_value_get_long (&value));
break; break;
} }
case G_TYPE_UINT: case G_TYPE_UINT:
{ {
GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
g_print("%-23.23s Unsigned Integer. Range: %u - %u (Default %u)", "", g_print("%-23.23s Unsigned Integer. ", "");
if (readable) g_print("Range: %u - %u (Default %u)",
puint->minimum, puint->maximum, g_value_get_uint (&value)); puint->minimum, puint->maximum, g_value_get_uint (&value));
break; break;
} }
case G_TYPE_INT: case G_TYPE_INT:
{ {
GParamSpecInt *pint = G_PARAM_SPEC_INT (param); GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
g_print("%-23.23s Integer. Range: %d - %d (Default %d)", "", g_print("%-23.23s Integer. ", "");
if (readable) g_print("Range: %d - %d (Default %d)",
pint->minimum, pint->maximum, g_value_get_int (&value)); pint->minimum, pint->maximum, g_value_get_int (&value));
break; break;
} }
case G_TYPE_UINT64: case G_TYPE_UINT64:
{ {
GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
g_print("%-23.23s Unsigned Integer64. Range: %llu - %llu (Default %llu)", "", g_print("%-23.23s Unsigned Integer64. ", "");
if (readable) g_print("Range: %llu - %llu (Default %llu)",
puint64->minimum, puint64->maximum, g_value_get_uint64 (&value)); puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
break; break;
} }
case G_TYPE_INT64: case G_TYPE_INT64:
{ {
GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
g_print("%-23.23s Integer64. Range: %lld - %lld (Default %lld)", "", g_print("%-23.23s Integer64. ", "");
if (readable) g_print("Range: %lld - %lld (Default %lld)",
pint64->minimum, pint64->maximum, g_value_get_int64 (&value)); pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
break; break;
} }
@ -405,10 +417,15 @@ print_element_properties (GstElement *element)
if (flags) if (flags)
g_string_free (flags, TRUE); g_string_free (flags, TRUE);
} }
else else {
g_print ("unknown type %ld \"%s\"", param->value_type, g_type_name(param->value_type)); g_print ("%-23.23s Unknown type %ld \"%s\"", "",param->value_type,
g_type_name(param->value_type));
}
break; break;
} }
if (!readable)
g_print ("Write only\n");
else
g_print ("\n"); g_print ("\n");
} }
if (num_properties == 0) if (num_properties == 0)