rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=adef79ab17a07db1c2d38d9e413457705705caae

commit adef79ab17a07db1c2d38d9e413457705705caae
Author: Vitalii Vorobiov <vi.vorob...@samsung.com>
Date:   Tue Sep 6 16:47:04 2016 +0300

    editor: API fro edje_edit_colorclass... add/del/changes
---
 src/bin/common/signals.h                          | 20 +++---
 src/bin/editor/banned_edje_edit_api.h             |  7 ++-
 src/bin/editor/editor.h                           | 26 ++++++++
 src/bin/editor/editor_top_level.c                 | 74 +++++++++++++++++++++++
 src/bin/project_manager/group_manager.c           |  2 +-
 src/bin/project_manager/project_manager.c         | 10 +--
 src/bin/resource_manager/resource_manager_react.c | 17 ++----
 src/bin/ui/colorclass_manager.c                   | 11 +---
 src/bin/ui/property/property_color.c              | 34 +++++------
 9 files changed, 145 insertions(+), 56 deletions(-)

diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h
index 9ff0553..392e8b5 100644
--- a/src/bin/common/signals.h
+++ b/src/bin/common/signals.h
@@ -142,6 +142,14 @@ typedef struct {
  */
 #define SIGNAL_EDITOR_ATTRIBUTE_CHANGED "SIGNAL_EDITOR_ATTRIBUTE_CHANGED"
 
+/**
+ * emited when any attribute of top level resource (image, colorclass etc) is 
changed in editor.
+ * eventinfo - Pointer to Attribute
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_EDITOR_RESOURCE_ATTRIBUTE_CHANGED 
"SIGNAL_EDITOR_RESOURCE_ATTRIBUTE_CHANGED"
+
 typedef struct {
    const char *part_name;
    const char *state_name;
@@ -267,7 +275,7 @@ typedef struct {
 
 /**
  * emited when colorclass is added.
- * eventinfo - NULL
+ * eventinfo - colorclass'es name
  *
  * @ingroup Window
  */
@@ -275,21 +283,13 @@ typedef struct {
 
 /**
  * emited when colorclass is deleted.
- * eventinfo - NULL
+ * eventinfo - colorclass'es name
  *
  * @ingroup Window
  */
 #define SIGNAL_EDITOR_COLORCLASS_DELETED "SIGNAL_EDITOR_COLORCLASS_DELETED"
 
 /**
- * emited when colorclass is changed.
- * eventinfo - NULL
- *
- * @ingroup Window
- */
-#define SIGNAL_EDITOR_COLORCLASS_CHANGED "SIGNAL_EDITOR_COLORCLASS_CHANGED"
-
-/**
  * emited when sound is added.
  * eventinfo - NULL
  *
diff --git a/src/bin/editor/banned_edje_edit_api.h 
b/src/bin/editor/banned_edje_edit_api.h
index fea958f..e3d3c8c 100644
--- a/src/bin/editor/banned_edje_edit_api.h
+++ b/src/bin/editor/banned_edje_edit_api.h
@@ -59,10 +59,11 @@
 #pragma GCC poison edje_edit_group_data_name_set
 
 /* Color Classes API */
-//#pragma GCC poison edje_edit_color_class_add
-//#pragma GCC poison edje_edit_color_class_del
-//#pragma GCC poison edje_edit_color_class_colors_set
+#pragma GCC poison edje_edit_color_class_add
+#pragma GCC poison edje_edit_color_class_del
+#pragma GCC poison edje_edit_color_class_colors_set
 //#pragma GCC poison edje_edit_color_class_name_set
+#pragma GCC poison edje_edit_color_class_description_set
 
 /* Text styles API */
 //#pragma GCC poison edje_edit_style_add
diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h
index a2a129d..9020b79 100644
--- a/src/bin/editor/editor.h
+++ b/src/bin/editor/editor.h
@@ -218,6 +218,17 @@ typedef enum {
    ATTRIBUTE_LAST
 } Attribute;
 
+
+typedef enum {
+   ATTRIBUTE_RESOURCES_NONE,
+
+   ATTRIBUTE_RESOURCES_COLORCLASS_DESCRIPTION,
+   ATTRIBUTE_RESOURCES_COLORCLASS_COLORS,
+
+   ATTRIBUTE_RESOURCES_LAST
+} Attribute_Resource;
+
+
 void
 _editor_project_changed();
 
@@ -228,6 +239,21 @@ editor_image_add(Evas_Object *obj, const char *selected, 
Eina_Bool notify) EINA_
 Eina_Bool
 editor_image_del(Evas_Object *obj, const char *selected, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
 
+Eina_Bool
+editor_color_class_add(Evas_Object *obj, const char *name, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_color_class_del(Evas_Object *obj, const char *name, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_color_class_description_set(Evas_Object *obj, const char *name, const 
char *description) EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_color_class_colors_set(Evas_Object *obj, const char *name,
+                              int r, int g, int b, int a,
+                              int r2, int g2, int b2, int a2,
+                              int r3, int g3, int b3, int a3) 
EINA_WARN_UNUSED_RESULT;
+
 /* General */
 Eina_Bool
 editor_save(Evas_Object *edit_object) EINA_WARN_UNUSED_RESULT;
diff --git a/src/bin/editor/editor_top_level.c 
b/src/bin/editor/editor_top_level.c
index 333cf53..2cecb48 100644
--- a/src/bin/editor/editor_top_level.c
+++ b/src/bin/editor/editor_top_level.c
@@ -56,3 +56,77 @@ editor_image_del(Evas_Object *obj, const char *name, 
Eina_Bool notify)
      evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_IMAGE_DELETED, 
(void *)name);
    return true;
 }
+
+Eina_Bool
+editor_color_class_add(Evas_Object *obj, const char *name, Eina_Bool notify)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_color_class_add(obj, name));
+
+   if (!editor_save(obj))
+     return false; /* i hope it will never happen */
+   _editor_project_changed();
+   if (notify)
+     evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_COLORCLASS_ADDED, 
(void *)name);
+   return true;
+}
+
+Eina_Bool
+editor_color_class_del(Evas_Object *obj, const char *name, Eina_Bool notify)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_color_class_del(obj, name));
+
+   if (!editor_save(obj))
+     return false; /* i hope it will never happen */
+   _editor_project_changed();
+   if (notify)
+     evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_COLORCLASS_DELETED, 
(void *)name);
+   return true;
+}
+
+Eina_Bool
+editor_color_class_description_set(Evas_Object *obj, const char *name, const 
char *description)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   Attribute attribute = ATTRIBUTE_RESOURCES_COLORCLASS_DESCRIPTION;
+
+   CRIT_ON_FAIL(edje_edit_color_class_description_set(obj, name, description));
+
+   if (!editor_save(obj))
+     return false; /* i hope it will never happen */
+   _editor_project_changed();
+   if (!_editor_signals_blocked)
+     evas_object_smart_callback_call(ap.win, 
SIGNAL_EDITOR_RESOURCE_ATTRIBUTE_CHANGED, &attribute);
+   return true;
+}
+
+Eina_Bool
+editor_color_class_colors_set(Evas_Object *obj, const char *name,
+                              int r, int g, int b, int a,
+                              int r2, int g2, int b2, int a2,
+                              int r3, int g3, int b3, int a3)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   Attribute attribute = ATTRIBUTE_RESOURCES_COLORCLASS_COLORS;
+
+   CRIT_ON_FAIL(edje_edit_color_class_colors_set(obj, name,
+                                                 r, g, b, a,
+                                                 r2, g2, b2, a2,
+                                                 r3, g3, b3, a3));
+
+   if (!editor_save(obj))
+     return false; /* i hope it will never happen */
+   _editor_project_changed();
+   if (!_editor_signals_blocked)
+     evas_object_smart_callback_call(ap.win, 
SIGNAL_EDITOR_RESOURCE_ATTRIBUTE_CHANGED, &attribute);
+   return true;
+}
diff --git a/src/bin/project_manager/group_manager.c 
b/src/bin/project_manager/group_manager.c
index 91bce4e..adaf95a 100644
--- a/src/bin/project_manager/group_manager.c
+++ b/src/bin/project_manager/group_manager.c
@@ -413,7 +413,7 @@ gm_state_add(Project *pro, Part *part, const char 
*state_name, double state_valu
              /* Colorclass can be specified but not defined in edc.
                 If colorclass don't exist yet adding it */ \
              TODO("move this code to colorclass resource manager"); \
-             edje_edit_color_class_add(pro->global_object, name); \
+             CRIT_ON_FAIL(editor_color_class_add(pro->global_object, name, 
false)); \
              Colorclass_Resource *res = (Colorclass_Resource 
*)resource_add(name, RESOURCE_TYPE_COLORCLASS); \
              res->color1.r = res->color1.g = res->color1.b = res->color1.a = 
255; \
              res->color2.r = res->color2.g = res->color2.b = res->color2.a = 
255; \
diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index 3916eb2..43b5bbb 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -1283,11 +1283,11 @@ pm_project_group_import(Project *project, const char 
*edj, const char *group)
                                          &c1_r, &c1_g, &c1_b, &c1_a,
                                          &c2_r, &c2_g, &c2_b, &c2_a,
                                          &c3_r, &c3_g, &c3_b, &c3_a);
-        CRIT_ON_FAIL(edje_edit_color_class_add(project->global_object, data));
-        CRIT_ON_FAIL(edje_edit_color_class_colors_set(project->global_object, 
data,
-                                                      c1_r, c1_g, c1_b, c1_a,
-                                                      c2_r, c2_g, c2_b, c2_a,
-                                                      c3_r, c3_g, c3_b, c3_a));
+        CRIT_ON_FAIL(editor_color_class_add(project->global_object, data, 
false));
+        CRIT_ON_FAIL(editor_color_class_colors_set(project->global_object, 
data,
+                                                   c1_r, c1_g, c1_b, c1_a,
+                                                   c2_r, c2_g, c2_b, c2_a,
+                                                   c3_r, c3_g, c3_b, c3_a));
         THREAD_CONTEXT_SWITCH_END;
         res = (External_Resource *)resource_add(data, 
RESOURCE_TYPE_COLORCLASS);
         resource_insert(&project->colorclasses, (Resource *)res);
diff --git a/src/bin/resource_manager/resource_manager_react.c 
b/src/bin/resource_manager/resource_manager_react.c
index 2a492a1..a459505 100644
--- a/src/bin/resource_manager/resource_manager_react.c
+++ b/src/bin/resource_manager/resource_manager_react.c
@@ -210,22 +210,19 @@ _property_attribute_changed(void *data __UNUSED__,
 static void
 _colorclass_added(void *data __UNUSED__,
                   Evas_Object *obj __UNUSED__,
-                  void *ei __UNUSED__)
+                  void *ei)
 {
+   const char *image_name = (const char *)ei;
+   printf("Colorclass added [%s] \n", image_name);
 }
 
 static void
 _colorclass_deleted(void *data __UNUSED__,
                     Evas_Object *obj __UNUSED__,
-                    void *ei __UNUSED__)
-{
-}
-
-static void
-_colorclass_changed(void *data __UNUSED__,
-                    Evas_Object *obj __UNUSED__,
-                    void *ei __UNUSED__)
+                    void *ei)
 {
+   const char *image_name = (const char *)ei;
+   printf("Colorclass deleted [%s] \n", image_name);
 }
 
 static void
@@ -586,7 +583,6 @@ _resource_callbacks_register(Project *project)
    TODO("Those signals and their edje_edit API need to be implemented through 
editor")
    evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_COLORCLASS_ADDED, 
_colorclass_added, project);
    evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_COLORCLASS_DELETED, 
_colorclass_deleted, project);
-   evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_COLORCLASS_CHANGED, 
_colorclass_changed, project);
    evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_SOUND_ADDED, 
_sound_added, project);
    evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_SOUND_DELETED, 
_sound_deleted, project);
    evas_object_smart_callback_add(ap.win,  SIGNAL_EDITOR_IMAGE_ADDED, 
_image_added, project);
@@ -623,7 +619,6 @@ _resource_callbacks_unregister(Project *project)
    TODO("Those signals and their edje_edit API need to be implemented through 
editor")
    evas_object_smart_callback_del_full(ap.win,  
SIGNAL_EDITOR_COLORCLASS_ADDED, _colorclass_added, project);
    evas_object_smart_callback_del_full(ap.win,  
SIGNAL_EDITOR_COLORCLASS_DELETED, _colorclass_deleted, project);
-   evas_object_smart_callback_del_full(ap.win,  
SIGNAL_EDITOR_COLORCLASS_CHANGED, _colorclass_changed, project);
    evas_object_smart_callback_del_full(ap.win,  SIGNAL_EDITOR_SOUND_ADDED, 
_sound_added, project);
    evas_object_smart_callback_del_full(ap.win,  SIGNAL_EDITOR_SOUND_DELETED, 
_sound_deleted, project);
    evas_object_smart_callback_del_full(ap.win,  SIGNAL_EDITOR_IMAGE_ADDED, 
_image_added, project);
diff --git a/src/bin/ui/colorclass_manager.c b/src/bin/ui/colorclass_manager.c
index 8d4f1bf..dcc2ae3 100644
--- a/src/bin/ui/colorclass_manager.c
+++ b/src/bin/ui/colorclass_manager.c
@@ -114,7 +114,7 @@ _colorclass_add_popup_close_cb(void *data,
 
         res = (Colorclass_Resource *)resource_add(it->name, 
RESOURCE_TYPE_COLORCLASS);
         resource_insert(&ap.project->colorclasses, (Resource *)res);
-        edje_edit_color_class_add(ap.project->global_object, 
eina_stringshare_add(it->name));
+        CRIT_ON_FAIL(editor_color_class_add(ap.project->global_object, 
eina_stringshare_add(it->name), true));
 
         glit_ccl = elm_genlist_item_append(mng.genlist, _itc_ccl, it, NULL,
                                            ELM_GENLIST_ITEM_NONE, NULL, NULL);
@@ -123,9 +123,6 @@ _colorclass_add_popup_close_cb(void *data,
         evas_object_del(mng.popup);
         mng.popup = NULL;
 
-        CRIT_ON_FAIL(editor_save(ap.project->global_object));
-        TODO("Remove this line once edje_edit_colorclass API would be added 
into Editor Module and saving would work properly")
-           ap.project->changed = true;
         evas_object_smart_callback_call(ap.win, 
SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute);
      }
    resource_name_validator_free(mng.name_validator);
@@ -160,7 +157,7 @@ _colorclass_del_cb(void *data __UNUSED__,
    request.resource_type = RESOURCE_TYPE_COLORCLASS;
    request.name = ccl->name;
    res = resource_get(ap.project->colorclasses, &request);
-   edje_edit_color_class_del(ap.project->global_object, ccl->name);
+   CRIT_ON_FAIL(editor_color_class_del(ap.project->global_object, ccl->name, 
true));
    resource_remove(&ap.project->colorclasses, res);
    resource_free(res);
    elm_object_item_del(it);
@@ -202,10 +199,6 @@ _colorclass_del_cb(void *data __UNUSED__,
         elm_object_disabled_set(mng.del_button, EINA_TRUE);
         evas_object_smart_callback_call(ap.win, SIGNAL_COLOR_SELECTED, NULL);
      }
-
-   CRIT_ON_FAIL(editor_save(ap.project->global_object));
-   TODO("Remove this line once edje_edit_colorclass API would be added into 
Editor Module and saving would work properly")
-   ap.project->changed = true;
 }
 
 /* Callback on colorclass (un)selection in list */
diff --git a/src/bin/ui/property/property_color.c 
b/src/bin/ui/property/property_color.c
index a0ca625..d2d8966 100644
--- a/src/bin/ui/property/property_color.c
+++ b/src/bin/ui/property/property_color.c
@@ -57,19 +57,20 @@ _colorclass_update(ColorClassData *selected)
                                selected->current_ccl->g3,
                                selected->current_ccl->b3,
                                selected->current_ccl->a3);
-   edje_edit_color_class_colors_set(ap.project->global_object, 
selected->current_ccl->name,
-                                    selected->current_ccl->r1,
-                                    selected->current_ccl->g1,
-                                    selected->current_ccl->b1,
-                                    selected->current_ccl->a1,
-                                    selected->current_ccl->r2,
-                                    selected->current_ccl->g2,
-                                    selected->current_ccl->b2,
-                                    selected->current_ccl->a2,
-                                    selected->current_ccl->r3,
-                                    selected->current_ccl->g3,
-                                    selected->current_ccl->b3,
-                                    selected->current_ccl->a3);
+   CRIT_ON_FAIL(editor_color_class_colors_set(ap.project->global_object,
+                                              selected->current_ccl->name,
+                                              selected->current_ccl->r1,
+                                              selected->current_ccl->g1,
+                                              selected->current_ccl->b1,
+                                              selected->current_ccl->a1,
+                                              selected->current_ccl->r2,
+                                              selected->current_ccl->g2,
+                                              selected->current_ccl->b2,
+                                              selected->current_ccl->a2,
+                                              selected->current_ccl->r3,
+                                              selected->current_ccl->g3,
+                                              selected->current_ccl->b3,
+                                              selected->current_ccl->a3));
 
    TODO("Remove and fix that after REAL RESOURCE MANAGER will exist")
    request.resource_type = RESOURCE_TYPE_COLORCLASS;
@@ -134,10 +135,9 @@ _change_cb(Property_Attribute *pa __UNUSED__, 
Property_Action *action)
    text = property_entry_get(action->control);
 
    Colorclass_Item *cc_it = color_data.selected->current_ccl;
-   edje_edit_color_class_description_set(ap.project->global_object, 
cc_it->name, text);
-
-   CRIT_ON_FAIL(editor_save(ap.project->global_object));
-   ap.project->changed = true;
+   CRIT_ON_FAIL(editor_color_class_description_set(ap.project->global_object,
+                                                   cc_it->name,
+                                                   text));
    eina_stringshare_del(text);
 }
 

-- 


Reply via email to