rimmed pushed a commit to branch master.

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

commit 13c4ba0c8f9fa0441da41476b6b14277b034cc07
Author: Vitalii Vorobiov <[email protected]>
Date:   Tue Sep 6 17:45:24 2016 +0300

    editor: cover edje_edit API of styles and poison it
---
 src/bin/editor/banned_edje_edit_api.h             | 10 +--
 src/bin/editor/editor.h                           | 17 +++++
 src/bin/editor/editor_top_level.c                 | 83 +++++++++++++++++++++++
 src/bin/project_manager/project_manager.c         |  6 +-
 src/bin/resource_manager/resource_manager_react.c |  4 ++
 src/bin/ui/property/property_textblock.c          |  4 +-
 src/bin/ui/style_manager.c                        | 30 +++-----
 7 files changed, 124 insertions(+), 30 deletions(-)

diff --git a/src/bin/editor/banned_edje_edit_api.h 
b/src/bin/editor/banned_edje_edit_api.h
index 4124dce..fb67ecd 100644
--- a/src/bin/editor/banned_edje_edit_api.h
+++ b/src/bin/editor/banned_edje_edit_api.h
@@ -72,12 +72,12 @@
 #pragma GCC poison edje_edit_sound_tone_del
 
 /* Text styles API */
-//#pragma GCC poison edje_edit_style_add
-//#pragma GCC poison edje_edit_style_del
-//#pragma GCC poison edje_edit_style_tag_value_set
+#pragma GCC poison edje_edit_style_add
+#pragma GCC poison edje_edit_style_del
+#pragma GCC poison edje_edit_style_tag_value_set
 //#pragma GCC poison edje_edit_style_tag_name_set
-//#pragma GCC poison edje_edit_style_tag_add
-//#pragma GCC poison edje_edit_style_tag_del
+#pragma GCC poison edje_edit_style_tag_add
+#pragma GCC poison edje_edit_style_tag_del
 
 /* Externals API */
 //#pragma GCC poison edje_edit_external_add
diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h
index 7ddbfe3..505d7ef 100644
--- a/src/bin/editor/editor.h
+++ b/src/bin/editor/editor.h
@@ -224,6 +224,8 @@ typedef enum {
 
    ATTRIBUTE_RESOURCES_COLORCLASS_DESCRIPTION,
    ATTRIBUTE_RESOURCES_COLORCLASS_COLORS,
+   ATTRIBUTE_RESOURCES_STYLE_TAG_ADDED,
+   ATTRIBUTE_RESOURCES_STYLE_TAG_DELETED,
 
    ATTRIBUTE_RESOURCES_LAST
 } Attribute_Resource;
@@ -266,6 +268,21 @@ editor_sound_tone_add(Evas_Object *obj, const char *name, 
int frq, Eina_Bool not
 Eina_Bool
 editor_sound_tone_del(Evas_Object *obj, const char *name, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
 
+Eina_Bool
+editor_style_add(Evas_Object *obj, const char *name, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_style_del(Evas_Object *obj, const char *name, Eina_Bool notify) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_style_tag_add(Evas_Object *obj, const char *name, const char *tag) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_style_tag_del(Evas_Object *obj, const char *name, const char *tag) 
EINA_WARN_UNUSED_RESULT;
+
+Eina_Bool
+editor_style_tag_value_set(Evas_Object *obj, const char *name, const char 
*tag, const char *value) 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 215fdd4..090043b 100644
--- a/src/bin/editor/editor_top_level.c
+++ b/src/bin/editor/editor_top_level.c
@@ -196,3 +196,86 @@ editor_sound_tone_del(Evas_Object *obj, const char *name, 
Eina_Bool notify)
      evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_TONE_DELETED, (void 
*)name);
    return true;
 }
+
+Eina_Bool
+editor_style_add(Evas_Object *obj, const char *name, Eina_Bool notify)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_style_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_STYLE_ADDED, (void 
*)name);
+   return true;
+}
+
+Eina_Bool
+editor_style_del(Evas_Object *obj, const char *name, Eina_Bool notify)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_style_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_STYLE_DELETED, 
(void *)name);
+   return true;
+}
+
+Eina_Bool
+editor_style_tag_add(Evas_Object *obj, const char *name, const char *tag)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_style_tag_add(obj, name, tag));
+   Attribute attribute = ATTRIBUTE_RESOURCES_STYLE_TAG_ADDED;
+
+   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_style_tag_del(Evas_Object *obj, const char *name, const char *tag)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_style_tag_del(obj, name, tag));
+   Attribute attribute = ATTRIBUTE_RESOURCES_STYLE_TAG_DELETED;
+
+   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_style_tag_value_set(Evas_Object *obj, const char *name, const char 
*tag, const char *value)
+{
+   assert(obj != NULL);
+   assert(name != NULL);
+
+   CRIT_ON_FAIL(edje_edit_style_tag_value_set(obj, name, tag, value));
+   Attribute attribute = ATTRIBUTE_RESOURCES_STYLE_TAG_DELETED;
+
+   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/project_manager.c 
b/src/bin/project_manager/project_manager.c
index 9dabbfd..715e8cc 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -1309,7 +1309,7 @@ pm_project_group_import(Project *project, const char 
*edj, const char *group)
              TODO("implement resource replacing")
                 continue;
           }
-        edje_edit_style_add(project->global_object, data);
+        CRIT_ON_FAIL(editor_style_add(project->global_object, data, false));
         THREAD_CONTEXT_SWITCH_BEGIN;
         resources1 = edje_edit_style_tags_list_get(obj, data);
         THREAD_CONTEXT_SWITCH_END;
@@ -1317,8 +1317,8 @@ pm_project_group_import(Project *project, const char 
*edj, const char *group)
           {
              THREAD_CONTEXT_SWITCH_END;
              source = edje_edit_style_tag_value_get(obj, data, data1);
-             CRIT_ON_FAIL(edje_edit_style_tag_add(project->global_object, 
data, data1));
-             
CRIT_ON_FAIL(edje_edit_style_tag_value_set(project->global_object, data, data1, 
source));
+             CRIT_ON_FAIL(editor_style_tag_add(project->global_object, data, 
data1));
+             CRIT_ON_FAIL(editor_style_tag_value_set(project->global_object, 
data, data1, source));
              eina_stringshare_del(source);
              THREAD_CONTEXT_SWITCH_END;
           }
diff --git a/src/bin/resource_manager/resource_manager_react.c 
b/src/bin/resource_manager/resource_manager_react.c
index ea90489..1dd1e9a 100644
--- a/src/bin/resource_manager/resource_manager_react.c
+++ b/src/bin/resource_manager/resource_manager_react.c
@@ -284,6 +284,8 @@ _style_added(void *data __UNUSED__,
              Evas_Object *obj __UNUSED__,
              void *ei __UNUSED__)
 {
+   const char *name = (const char *)ei;
+   printf("style added [%s] \n", name);
 }
 
 static void
@@ -291,6 +293,8 @@ _style_deleted(void *data __UNUSED__,
                Evas_Object *obj __UNUSED__,
                void *ei __UNUSED__)
 {
+   const char *name = (const char *)ei;
+   printf("style deleted [%s] \n", name);
 }
 
 static void
diff --git a/src/bin/ui/property/property_textblock.c 
b/src/bin/ui/property/property_textblock.c
index 089e0f4..ffb76c3 100644
--- a/src/bin/ui/property/property_textblock.c
+++ b/src/bin/ui/property/property_textblock.c
@@ -396,8 +396,8 @@ _update_style()
    else
      evas_object_textblock_text_markup_set(tpd.current_style.textblock_style, 
TEST_TEXT);
 
-   edje_edit_style_tag_value_set(ap.project->global_object, 
tpd.current_style.st_name,
-                                 tpd.current_style.st_tag, 
eina_strbuf_string_get(tag));
+   CRIT_ON_FAIL(editor_style_tag_value_set(ap.project->global_object, 
tpd.current_style.st_name,
+                                           tpd.current_style.st_tag, 
eina_strbuf_string_get(tag)));
    eina_stringshare_del(tpd.current_style.stvalue);
    tpd.current_style.stvalue = 
eina_stringshare_add(eina_strbuf_string_get(tag));
    eina_strbuf_free(tag);
diff --git a/src/bin/ui/style_manager.c b/src/bin/ui/style_manager.c
index 9f50953..ce7c93f 100644
--- a/src/bin/ui/style_manager.c
+++ b/src/bin/ui/style_manager.c
@@ -187,13 +187,13 @@ _style_add_popup_close_cb_cb(void *data __UNUSED__,
    if (BTN_CANCEL == btn_res) goto close;
 
    style_name = elm_entry_entry_get(mng.popup.name);
-   edje_edit_style_add(ap.project->global_object, style_name);
-   if (edje_edit_style_tag_add(ap.project->global_object, style_name, 
STYLE_DEFAULT))
+   CRIT_ON_FAIL(editor_style_add(ap.project->global_object, style_name, true));
+   if (editor_style_tag_add(ap.project->global_object, style_name, 
STYLE_DEFAULT))
      {
-        if (!edje_edit_style_tag_value_set(ap.project->global_object, 
style_name, STYLE_DEFAULT, STYLE_DEFAULT_VALUE))
+        if (!editor_style_tag_value_set(ap.project->global_object, style_name, 
STYLE_DEFAULT, STYLE_DEFAULT_VALUE))
           {
              WARN(_("Failed to add tag value. Tag will be deleted"));
-             edje_edit_style_tag_del(ap.project->global_object, style_name, 
STYLE_DEFAULT);
+             CRIT_ON_FAIL(editor_style_tag_del(ap.project->global_object, 
style_name, STYLE_DEFAULT));
              goto close;
           }
      }
@@ -208,9 +208,6 @@ _style_add_popup_close_cb_cb(void *data __UNUSED__,
    res = resource_add(style_name, RESOURCE_TYPE_STYLE);
    resource_insert(&ap.project->styles, res);
 
-   CRIT_ON_FAIL(editor_save(ap.project->global_object));
-   TODO("Remove this line once edje_edit 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);
 
 close:
@@ -267,11 +264,12 @@ _tag_add_popup_close_cb(void *data,
    if (BTN_CANCEL == btn_res) goto close;
 
    tpd->tag_name = elm_entry_entry_get(mng.popup.name);
-   edje_edit_style_tag_add(ap.project->global_object, tpd->style_name, 
tpd->tag_name);
-   if (!edje_edit_style_tag_value_set(ap.project->global_object, 
tpd->style_name, tpd->tag_name, ""))
+
+   CRIT_ON_FAIL(editor_style_tag_add(ap.project->global_object, 
tpd->style_name, tpd->tag_name));
+   if (!editor_style_tag_value_set(ap.project->global_object, tpd->style_name, 
tpd->tag_name, ""))
      {
         WARN(_("Failed to add tag value. Tag will be deleted"));
-        edje_edit_style_tag_del(ap.project->global_object, tpd->style_name, 
tpd->tag_name);
+        CRIT_ON_FAIL(editor_style_tag_del(ap.project->global_object, 
tpd->style_name, tpd->tag_name));
         goto close;
      }
    tpd->glit = elm_genlist_item_append(mng.genlist, _itc_tags,
@@ -282,10 +280,6 @@ _tag_add_popup_close_cb(void *data,
    elm_genlist_item_selected_set(tpd->glit, true);
    elm_genlist_item_bring_in(tpd->glit, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
 
-   CRIT_ON_FAIL(editor_save(ap.project->global_object));
-   TODO("Remove this line once edje_edit API would be added into Editor Module 
and saving would work properly")
-   ap.project->changed = true;
-
 close:
    EINA_LIST_FREE(tpd->resources, res)
       resource_free(res);
@@ -356,7 +350,7 @@ _btn_del_cb(void *data __UNUSED__,
         request.resource_type = RESOURCE_TYPE_STYLE;
         request.name = style_name;
         res = resource_get(ap.project->styles, &request);
-        edje_edit_style_del(edje_edit_obj, style_name);
+        CRIT_ON_FAIL(editor_style_del(edje_edit_obj, style_name, true));
         resource_remove(&ap.project->styles, res);
         evas_object_smart_callback_call(ap.win, 
SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute);
      }
@@ -364,17 +358,13 @@ _btn_del_cb(void *data __UNUSED__,
      {
         style_name = elm_object_item_data_get(glit_parent);
         tag = elm_object_item_data_get(glit);
-        edje_edit_style_tag_del(edje_edit_obj, style_name, tag);
+        CRIT_ON_FAIL(editor_style_tag_del(edje_edit_obj, style_name, tag));
      }
 
    elm_object_item_del(glit);
 
    elm_object_disabled_set(mng.button_del, true);
    evas_object_smart_callback_call(ap.win, SIGNAL_STYLE_SELECTED, NULL);
-
-   CRIT_ON_FAIL(editor_save(ap.project->global_object));
-   TODO("Remove this line once edje_edit API would be added into Editor Module 
and saving would work properly")
-   ap.project->changed = true;
 }
 
 /* For GenList, getting the content for showing. Tag Names. */

-- 


Reply via email to