Commit 40a28eee4d6156b4e52caebaf06c7bbd79aaf078
- Diff rendering mode:
- inline
- side by side
src/gve-video-effects.c
(30 / 2)
|   | |||
| 35 | 35 | G_DEFINE_TYPE (GVEVideoEffect, gve_video_effect, G_TYPE_OBJECT); | |
| 36 | 36 | ||
| 37 | 37 | static GParamSpec * | |
| 38 | create_string_param (GKeyFile *key_file, const gchar *group_name, struct param_internal *config) | ||
| 39 | { | ||
| 40 | gchar *default_value; | ||
| 41 | GError *error = NULL; | ||
| 42 | GParamSpec *pspec; | ||
| 43 | |||
| 44 | default_value = g_key_file_get_string (key_file, group_name, "Default", &error); | ||
| 45 | if (error != NULL) | ||
| 46 | { | ||
| 47 | g_warning ("Could not get 'Default': %s", error->message); | ||
| 48 | g_error_free (error); | ||
| 49 | error = NULL; | ||
| 50 | } | ||
| 51 | pspec = g_param_spec_string (config->name, config->name, config->comment, | ||
| 52 | default_value, G_PARAM_READABLE | G_PARAM_WRITABLE); | ||
| 53 | return pspec; | ||
| 54 | } | ||
| 55 | |||
| 56 | static GParamSpec * | ||
| 38 | 57 | create_bool_param (GKeyFile *key_file, const gchar *group_name, struct param_internal *config) | |
| 39 | 58 | { | |
| 40 | gint default_value; | ||
| 59 | gboolean default_value; | ||
| 41 | 60 | GError *error = NULL; | |
| 42 | 61 | GParamSpec *pspec; | |
| 43 | 62 | ||
| 44 | default_value = g_key_file_get_integer (key_file, group_name, "Default", &error); | ||
| 63 | default_value = g_key_file_get_boolean (key_file, group_name, "Default", &error); | ||
| 45 | 64 | if (error != NULL) | |
| 46 | 65 | { | |
| 47 | 66 | g_warning ("Could not get '%s': %s", "Default", error->message); | |
| … | … | ||
| 193 | 193 | pspec = create_double_param (key_file, group_name, &config); | |
| 194 | 194 | else if (!g_strcmp0 (type, "bool")) | |
| 195 | 195 | pspec = create_bool_param (key_file, group_name, &config); | |
| 196 | else if (!g_strcmp0 (type, "string")) | ||
| 197 | pspec = create_string_param (key_file, group_name, &config); | ||
| 196 | 198 | else | |
| 197 | 199 | g_warning ("Property '%s' type cannot be handled", config.name); | |
| 198 | 200 | ||
| … | … | ||
| 341 | 341 | g_value_init (&value, G_TYPE_BOOLEAN); | |
| 342 | 342 | g_value_set_boolean (&value, G_PARAM_SPEC_BOOLEAN (pspec)->default_value); | |
| 343 | 343 | } | |
| 344 | else if (G_IS_PARAM_SPEC_STRING (pspec)) | ||
| 345 | { | ||
| 346 | g_value_init (&value, G_TYPE_STRING); | ||
| 347 | g_value_set_string (&value, G_PARAM_SPEC_STRING (pspec)->default_value); | ||
| 348 | } | ||
| 344 | 349 | else | |
| 345 | 350 | { | |
| 346 | 351 | g_warning ("Could not set default value for %s: type mismatch", (char *)item->data); | |
| … | … | ||
| 386 | 386 | g_object_set (element, property_name, g_value_get_double (value), NULL); | |
| 387 | 387 | else if (G_VALUE_HOLDS_BOOLEAN (value)) | |
| 388 | 388 | g_object_set (element, property_name, g_value_get_boolean (value), NULL); | |
| 389 | else if (G_VALUE_HOLDS_STRING (value)) | ||
| 390 | g_object_set (element, property_name, g_value_get_string (value), NULL); | ||
| 389 | 391 | else | |
| 390 | 392 | g_warning ("Property '%s' was not set: Type mismatch", property); | |
| 391 | 393 | } |

