[gtk+] styleproperty: Add a function to compare values for equality



commit 115c34498e00d5c1723c72f82a1bc80ea39faa32
Author: Benjamin Otte <otte redhat com>
Date:   Fri Mar 23 23:52:48 2012 +0100

    styleproperty: Add a function to compare values for equality
    
    and default to never compare them as equal.

 gtk/gtkcssstyleproperty.c        |   31 +++++++++++++++++++++++++++++++
 gtk/gtkcssstylepropertyprivate.h |    7 +++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 8839cd6..95b8ba1 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -298,12 +298,21 @@ gtk_css_style_property_real_compute_value (GtkCssStyleProperty *property,
   return _gtk_css_style_compute_value (context, _gtk_css_style_property_get_computed_type (property), specified);
 }
 
+static gboolean
+gtk_css_style_property_real_equal (GtkCssStyleProperty *property,
+                                   GtkCssValue         *value1,
+                                   GtkCssValue         *value2)
+{
+  return FALSE;
+}
+
 static void
 _gtk_css_style_property_init (GtkCssStyleProperty *property)
 {
   property->parse_value = gtk_css_style_property_real_parse_value;
   property->print_value = gtk_css_style_property_real_print_value;
   property->compute_value = gtk_css_style_property_real_compute_value;
+  property->equal_func = gtk_css_style_property_real_equal;
 }
 
 /**
@@ -538,3 +547,25 @@ _gtk_css_style_property_print_value (GtkCssStyleProperty    *property,
     }
 }
 
+/**
+ * _gtk_css_style_property_is_equal:
+ * @property: the property
+ * @value1: the first value to compare
+ * @value2: the second value to compare
+ *
+ * Compares @value1 and @value2 for equality. Both values must be the
+ * result of a call _gtk_css_style_property_compute_value().
+ *
+ * Returns: %TRUE if @value1 and @value2 are equal
+ **/
+gboolean
+_gtk_css_style_property_is_equal (GtkCssStyleProperty *property,
+                                  GtkCssValue         *value1,
+                                  GtkCssValue         *value2)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
+  g_return_val_if_fail (value1 != NULL, FALSE);
+  g_return_val_if_fail (value2 != NULL, FALSE);
+
+  return property->equal_func (property, value1, value2);
+}
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index a51d455..21c57b9 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -44,6 +44,9 @@ typedef void             (* GtkCssStylePropertyPrintFunc)  (GtkCssStyleProperty
 typedef GtkCssValue  *   (* GtkCssStylePropertyComputeFunc)(GtkCssStyleProperty    *property,
                                                             GtkStyleContext        *context,
                                                             GtkCssValue            *specified);
+typedef gboolean         (* GtkCssStylePropertyEqualFunc)  (GtkCssStyleProperty    *property,
+                                                            GtkCssValue            *value1,
+                                                            GtkCssValue            *value2);
 struct _GtkCssStyleProperty
 {
   GtkStyleProperty parent;
@@ -56,6 +59,7 @@ struct _GtkCssStyleProperty
   GtkCssStylePropertyParseFunc parse_value;
   GtkCssStylePropertyPrintFunc print_value;
   GtkCssStylePropertyComputeFunc compute_value;
+  GtkCssStylePropertyEqualFunc equal_func;
 };
 
 struct _GtkCssStylePropertyClass
@@ -88,6 +92,9 @@ GtkCssValue *           _gtk_css_style_property_compute_value   (GtkCssStyleProp
 void                    _gtk_css_style_property_print_value     (GtkCssStyleProperty    *property,
                                                                  GtkCssValue            *value,
                                                                  GString                *string);
+gboolean                _gtk_css_style_property_is_equal        (GtkCssStyleProperty    *property,
+                                                                 GtkCssValue            *value1,
+                                                                 GtkCssValue            *value2);
                                                                  
 
 G_END_DECLS



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