Commit b9d07e13e6e3238712c66c156aed6b7219c773d2

libgve: Handling boolean properties
  
4343G_DEFINE_TYPE (GVEVideoEffect, gve_video_effect, G_TYPE_OBJECT);
4444
4545static GParamSpec *
46create_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
64static GParamSpec *
4665create_int_param (GKeyFile *key_file, const gchar *group_name, struct param_internal *config)
4766{
4867 gint min;
180180 pspec = create_int_param (key_file, group_name, &config);
181181 else if (!g_strcmp0 (type, "double"))
182182 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);
183185 else
184 g_warning ("Property '%s' type cannot be handled");
186 g_warning ("Property '%s' type cannot be handled", config.name);
185187
186188 g_param_spec_set_qdata (pspec, g_quark_from_static_string ("Element"), config.element);
187189 g_param_spec_set_qdata (pspec, g_quark_from_static_string ("Property"), config.property);
317317 g_value_init (&value, G_TYPE_INT);
318318 g_value_set_int (&value, G_PARAM_SPEC_INT (pspec)->default_value);
319319 }
320 if (G_IS_PARAM_SPEC_DOUBLE (pspec))
320 else if (G_IS_PARAM_SPEC_DOUBLE (pspec))
321321 {
322322 g_value_init (&value, G_TYPE_DOUBLE);
323323 g_value_set_double (&value, G_PARAM_SPEC_DOUBLE (pspec)->default_value);
324324 }
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 }
325335 gve_video_effect_set_property (effect, item->data, &value);
326336 item = g_list_next (item);
327337 }
363363 g_warning ("Could not get element %s", element_name);
364364 if (G_VALUE_HOLDS_INT (value))
365365 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))
367367 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);
368372}
369373
370374GstElement *