edje: Make setters for "edje_edit_state_min/max..." return Eina_Bool
authorVorobiov Vitalii <vi.vorobiov@samsung.com>
Wed, 30 Oct 2013 12:45:00 +0000 (21:45 +0900)
committerCedric Bail <cedric.bail@free.fr>
Wed, 30 Oct 2013 13:30:15 +0000 (22:30 +0900)
This patch start returning Eina_Bool for state's min and max value setters, so
we can now catch error when calling those function.
edje_edit_state_min_h_set
edje_edit_state_min_w_set
edje_edit_state_max_h_set
edje_edit_state_max_w_set

Reviewers: cedric, seoz

Reviewed By: cedric

CC: reutskiy.v.v
Differential Revision: https://phab.enlightenment.org/D298

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
src/lib/edje/Edje_Edit.h
src/lib/edje/edje_edit.c

index 1a6d037..1c3f24f 100644 (file)
@@ -1608,7 +1608,7 @@ EAPI int edje_edit_state_min_w_get(Evas_Object *obj, const char *part, const cha
  * @param value The state value.
  * @param min_w Minimum width value.
  */
-EAPI void edje_edit_state_min_w_set(Evas_Object *obj, const char *part, const char *state, double value, int min_w);
+EAPI Eina_Bool edje_edit_state_min_w_set(Evas_Object *obj, const char *part, const char *state, double value, int min_w);
 
 /** Get the minimum height value of a part state.
  *
@@ -1629,7 +1629,7 @@ EAPI int edje_edit_state_min_h_get(Evas_Object *obj, const char *part, const cha
  * @param value The state value.
  * @param min_h Minimum height value.
  */
-EAPI void edje_edit_state_min_h_set(Evas_Object *obj, const char *part, const char *state, double value, int min_h);
+EAPI Eina_Bool edje_edit_state_min_h_set(Evas_Object *obj, const char *part, const char *state, double value, int min_h);
 
 /** Get the maximum width value of a part state.
  *
@@ -1650,7 +1650,7 @@ EAPI int edje_edit_state_max_w_get(Evas_Object *obj, const char *part, const cha
  * @param value The state value.
  * @param max_w Maximum width value.
  */
-EAPI void edje_edit_state_max_w_set(Evas_Object *obj, const char *part, const char *state, double value, int max_w);
+EAPI Eina_Bool edje_edit_state_max_w_set(Evas_Object *obj, const char *part, const char *state, double value, int max_w);
 
 /** Get the maximum height value of a part state.
  *
@@ -1671,7 +1671,7 @@ EAPI int edje_edit_state_max_h_get(Evas_Object *obj, const char *part, const cha
  * @param value The state value.
  * @param max_h Maximum height value.
  */
-EAPI void edje_edit_state_max_h_set(Evas_Object *obj, const char *part, const char *state, double value, int max_h);
+EAPI Eina_Bool edje_edit_state_max_h_set(Evas_Object *obj, const char *part, const char *state, double value, int max_h);
 
 /** Get the minimum aspect value of a part state.
  *
index 90cb4cf..e72cf8e 100644 (file)
@@ -3346,27 +3346,31 @@ edje_edit_state_color3_set(Evas_Object *obj, const char *part, const char *state
      edje_object_calc_force(obj);                                      \
   }
 
-#define FUNC_STATE_INT(Class, Value)                                   \
+#define FUNC_STATE_INT(Class, Value, Min)                              \
   EAPI int                                                             \
   edje_edit_state_##Class##_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
   {                                                                    \
      GET_PD_OR_RETURN(0);                                              \
      return pd->Class.Value;                                   \
   }                                                                    \
-  EAPI void                                                            \
+  EAPI Eina_Bool \
   edje_edit_state_##Class##_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, int v) \
   {                                                                    \
-     GET_PD_OR_RETURN();                                               \
-     pd->Class.Value = v;                                      \
+     if ((!obj) || (!part) || (!state))                                 \
+       return EINA_FALSE;                                               \
+     if (v < Min) return EINA_FALSE;                                    \
+     GET_PD_OR_RETURN(EINA_FALSE);                                      \
+     pd->Class.Value = v;                                              \
      edje_object_calc_force(obj);                                      \
+     return EINA_TRUE;                                                  \
   }
 
 FUNC_STATE_DOUBLE(align, x);
 FUNC_STATE_DOUBLE(align, y);
-FUNC_STATE_INT(min, w);
-FUNC_STATE_INT(min, h);
-FUNC_STATE_INT(max, w);
-FUNC_STATE_INT(max, h);
+FUNC_STATE_INT(min, w, 0);
+FUNC_STATE_INT(min, h, 0);
+FUNC_STATE_INT(max, w, -1);
+FUNC_STATE_INT(max, h, -1);
 FUNC_STATE_DOUBLE(aspect, min);
 FUNC_STATE_DOUBLE(aspect, max);