[grilo] core: Extend supported keys in the filters



commit 51e7a16031a0f5b31cd7a840bb4cfb995af64086
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Tue Nov 13 23:13:14 2012 +0000

    core: Extend supported keys in the filters
    
    Include gboolean, gfloat and GDateTime keys in the supported keys for defining
    filters.

 src/grl-operation-options.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/grl-operation-options.c b/src/grl-operation-options.c
index c878732..9d1f4e4 100644
--- a/src/grl-operation-options.c
+++ b/src/grl-operation-options.c
@@ -608,6 +608,10 @@ grl_operation_options_set_key_filters (GrlOperationOptions *options,
       g_value_set_string (&value, va_arg (args, gchar *));
     } else if (key_type == G_TYPE_INT) {
       g_value_set_int (&value, va_arg (args, gint));
+    } else if (key_type == G_TYPE_BOOLEAN) {
+      g_value_set_boolean (&value, va_arg (args, gboolean));
+    } else if (key_type == G_TYPE_DATE_TIME) {
+      g_value_set_boxed (&value, va_arg (args, gconstpointer));
     } else {
       GRL_WARNING ("Unexpected key type when setting up the filter");
       success = FALSE;
@@ -762,10 +766,14 @@ grl_operation_options_set_key_range_filter (GrlOperationOptions *options,
   GValue *min_p_value;
   gint min_int_value;
   gchar *min_str_value;
+  gfloat min_float_value;
+  gconstpointer min_date_value;
   GValue max_value = { 0 };
   GValue *max_p_value;
   gint max_int_value;
   gchar *max_str_value;
+  gfloat max_float_value;
+  gconstpointer max_date_value;
   GrlKeyID next_key;
   gboolean skip;
   gboolean success = TRUE;
@@ -802,6 +810,28 @@ grl_operation_options_set_key_range_filter (GrlOperationOptions *options,
         g_value_set_int (&max_value, max_int_value);
         max_p_value = &max_value;
       }
+    } else if (key_type == G_TYPE_FLOAT) {
+      min_float_value = va_arg (args, gdouble);
+      max_float_value = va_arg (args, gdouble);
+      if (min_float_value > G_MINFLOAT) {
+        g_value_set_float (&min_value, min_float_value);
+        min_p_value = &min_value;
+      }
+      if (max_float_value < G_MAXFLOAT) {
+        g_value_set_float (&max_value, max_float_value);
+        max_p_value = &max_value;
+      }
+    } else if (key_type == G_TYPE_DATE_TIME) {
+      min_date_value = va_arg (args, gconstpointer);
+      max_date_value = va_arg (args, gconstpointer);
+      if (min_date_value) {
+        g_value_set_boxed (&min_value, min_date_value);
+        min_p_value = &min_value;
+      }
+      if (max_date_value) {
+        g_value_set_boxed (&max_value, max_date_value);
+        max_p_value = &max_value;
+      }
     } else {
       GRL_WARNING ("Unexpected key type when setting up the filter");
       success = FALSE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]