yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=64b18acb7461c4ff23790d6c3f23f1b4cc18a5be

commit 64b18acb7461c4ff23790d6c3f23f1b4cc18a5be
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Sun Nov 8 12:00:08 2015 +0200

    Add API to compare Gui_Properties and Gui_Values
---
 src/lib/gui_widget.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/gui_widget.h |  7 +++++++
 2 files changed, 63 insertions(+)

diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index ab94dd7..f7ffff8 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -2743,6 +2743,25 @@ prop_wdg_get(const Gui_Widget_Property *prop)
    return prop->wdg;
 }
 
+Eina_Bool
+prop_cmp(const Gui_Widget_Property *prop1, const Gui_Widget_Property *prop2)
+{
+   if (prop1 == prop2) return EINA_FALSE;
+   if (!prop1 || !prop2) return EINA_TRUE;
+   Eina_List *values1, *values2;
+   values1 = prop_value_get(prop1);
+   values2 = prop_value_get(prop2);
+
+   while (values1)
+     {
+        if (gui_value_cmp(eina_list_data_get(values1), 
eina_list_data_get(values2))) return EINA_TRUE;
+        values1 = eina_list_next(values1);
+        values2 = eina_list_next(values2);
+     }
+
+   return EINA_FALSE;
+}
+
 /************************************************************/
 /* Gui Callback Functions*/
 
@@ -3042,6 +3061,43 @@ gui_value_del(Gui_Value *val)
    free(val);
 }
 
+Eina_Bool
+gui_value_cmp(const Gui_Value *val1, const Gui_Value *val2)
+{
+   if (val1 == val2) return EINA_FALSE;
+   if (!val1 || !val2) return EINA_TRUE;
+   if (val1->type != val2->type)
+     {
+        ERR("Trying to compare values of different types! Normally this can 
not happen");
+        return EINA_TRUE;
+     }
+   switch (val1->type)
+     {
+      case GUI_TYPE_SINT:
+      case GUI_TYPE_DOUBLE:
+      case GUI_TYPE_OBJECT:
+      case GUI_TYPE_FILE:
+      case GUI_TYPE_THEME:
+      case GUI_TYPE_BOOL:
+      case GUI_TYPE_CB:
+      case GUI_TYPE_OBJECT_ITEM:
+      case GUI_TYPE_VOID:
+           {
+              return (!(val1->value_pointer == val2->value_pointer));
+           }
+      case GUI_TYPE_ENUM:
+      case GUI_TYPE_STRING:
+           {
+              return strcmp(val1->string, val2->string);
+              break;
+           }
+      default:
+         ERR("switch default: %s", db_gui_type_name_get(val1->type));
+     }
+   return EINA_TRUE;
+}
+
+
 /*
  * Get pointer to value of Gui_Value object.
  *
diff --git a/src/lib/gui_widget.h b/src/lib/gui_widget.h
index edf72ec..a37525b 100644
--- a/src/lib/gui_widget.h
+++ b/src/lib/gui_widget.h
@@ -666,6 +666,9 @@ prop_op_desc_get(const Gui_Widget_Property *prop);
 const Gui_Widget *
 prop_wdg_get(const Gui_Widget_Property *prop);
 
+Eina_Bool
+prop_cmp(const Gui_Widget_Property *prop1, const Gui_Widget_Property *prop2);
+
 
/******************************************************************************/
 /* Callback functions */
 
@@ -750,6 +753,10 @@ gui_value_type_get(const Gui_Value *val);
 void
 gui_value_del(Gui_Value *val);
 
+/* Compare two Gui_Values. */
+Eina_Bool
+gui_value_cmp(const Gui_Value *val1, const Gui_Value *val2);
+
 void *
 gui_value_pointer_get(const Gui_Value *gui_value);
 

-- 


Reply via email to