Commit b9d07e13e6e3238712c66c156aed6b7219c773d2
- Diff rendering mode:
- inline
- side by side
src/gve-video-effects.c
(38 / 3)
|   | |||
| 43 | 43 | G_DEFINE_TYPE (GVEVideoEffect, gve_video_effect, G_TYPE_OBJECT); | |
| 44 | 44 | ||
| 45 | 45 | static GParamSpec * | |
| 46 | create_bool_param (GKeyFile *key_file, const gchar *group_name, struct param_internal *config) | ||
| 47 | { | ||
| 48 | gint default_value; | ||
| 49 | GError *error = NULL; | ||
| 50 | GParamSpec *pspec; | ||
| 51 | |||
| 52 | default_value = g_key_file_get_integer (key_file, group_name, "Default", &error); | ||
| 53 | if (error != NULL) | ||
| 54 | { | ||
| 55 | g_warning ("Could not get '%s': %s", "Default", error->message); | ||
| 56 | g_error_free (error); | ||
| 57 | error = NULL; | ||
| 58 | } | ||
| 59 | pspec = g_param_spec_boolean (config->name, config->name, config->comment, | ||
| 60 | default_value, G_PARAM_READABLE | G_PARAM_WRITABLE); | ||
| 61 | return pspec; | ||
| 62 | } | ||
| 63 | |||
| 64 | static GParamSpec * | ||
| 46 | 65 | create_int_param (GKeyFile *key_file, const gchar *group_name, struct param_internal *config) | |
| 47 | 66 | { | |
| 48 | 67 | gint min; | |
| … | … | ||
| 180 | 180 | pspec = create_int_param (key_file, group_name, &config); | |
| 181 | 181 | else if (!g_strcmp0 (type, "double")) | |
| 182 | 182 | pspec = create_double_param (key_file, group_name, &config); | |
| 183 | else if (!g_strcmp0 (type, "bool")) | ||
| 184 | pspec = create_bool_param (key_file, group_name, &config); | ||
| 183 | 185 | else | |
| 184 | g_warning ("Property '%s' type cannot be handled"); | ||
| 186 | g_warning ("Property '%s' type cannot be handled", config.name); | ||
| 185 | 187 | ||
| 186 | 188 | g_param_spec_set_qdata (pspec, g_quark_from_static_string ("Element"), config.element); | |
| 187 | 189 | g_param_spec_set_qdata (pspec, g_quark_from_static_string ("Property"), config.property); | |
| … | … | ||
| 317 | 317 | g_value_init (&value, G_TYPE_INT); | |
| 318 | 318 | g_value_set_int (&value, G_PARAM_SPEC_INT (pspec)->default_value); | |
| 319 | 319 | } | |
| 320 | if (G_IS_PARAM_SPEC_DOUBLE (pspec)) | ||
| 320 | else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) | ||
| 321 | 321 | { | |
| 322 | 322 | g_value_init (&value, G_TYPE_DOUBLE); | |
| 323 | 323 | g_value_set_double (&value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); | |
| 324 | 324 | } | |
| 325 | else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) | ||
| 326 | { | ||
| 327 | g_value_init (&value, G_TYPE_BOOLEAN); | ||
| 328 | g_value_set_boolean (&value, G_PARAM_SPEC_BOOLEAN (pspec)->default_value); | ||
| 329 | } | ||
| 330 | else | ||
| 331 | { | ||
| 332 | g_warning ("Could not set default value for %s: type mismatch", (char *)item->data); | ||
| 333 | return; | ||
| 334 | } | ||
| 325 | 335 | gve_video_effect_set_property (effect, item->data, &value); | |
| 326 | 336 | item = g_list_next (item); | |
| 327 | 337 | } | |
| … | … | ||
| 363 | 363 | g_warning ("Could not get element %s", element_name); | |
| 364 | 364 | if (G_VALUE_HOLDS_INT (value)) | |
| 365 | 365 | g_object_set (element, property_name, g_value_get_int (value), NULL); | |
| 366 | if (G_VALUE_HOLDS_DOUBLE (value)) | ||
| 366 | else if (G_VALUE_HOLDS_DOUBLE (value)) | ||
| 367 | 367 | g_object_set (element, property_name, g_value_get_double (value), NULL); | |
| 368 | else if (G_VALUE_HOLDS_BOOLEAN (value)) | ||
| 369 | g_object_set (element, property_name, g_value_get_boolean (value), NULL); | ||
| 370 | else | ||
| 371 | g_warning ("Property '%s' was not set: Type mismatch", property); | ||
| 368 | 372 | } | |
| 369 | 373 | ||
| 370 | 374 | GstElement * |

