rimmed pushed a commit to branch master.

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

commit a0f5cdca9a24b30aba4e4dd7b1364f4f25ea1851
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Thu Nov 19 16:59:58 2015 +0200

    editor: add part_add/_del methods
---
 src/bin/common/signals.h     | 16 +++++++++++
 src/bin/editor/editor.h      |  6 ++++
 src/bin/editor/editor_part.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)

diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h
index 727040a..2b73454 100644
--- a/src/bin/common/signals.h
+++ b/src/bin/common/signals.h
@@ -185,6 +185,22 @@ typedef struct {
 #define SIGNAL_EDITOR_PART_ITEM_DELETED "SIGNAL_EDITOR_PART_ITEM_DELETED"
 
 /**
+ * emited when part is added in editor.
+ * eventinfo - stringshare with parts name
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_EDITOR_PART_ADDED "SIGNAL_EDITOR_PART_ADDED"
+
+/**
+ * emited *before* part will be deleted in editor.
+ * eventinfo - stringshare with parts name
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_EDITOR_PART_DELETED "SIGNAL_EDITOR_PART_DELETED"
+
+/**
  * emited when project is changed in any way (through attribute, .
  * eventinfo - NULL
  *
diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h
index 31c8d78..c088402 100644
--- a/src/bin/editor/editor.h
+++ b/src/bin/editor/editor.h
@@ -415,6 +415,12 @@ editor_state_image_set(Evas_Object *obj, Change *change, 
Eina_Bool merge, const
 /* Part */
 
 Eina_Bool
+editor_part_add(Evas_Object *edit_object, Change *change, Eina_Bool merge,
+                const char *part_name, Edje_Part_Type type);
+Eina_Bool
+editor_part_del(Evas_Object *edit_object, Change *change, Eina_Bool merge,
+                const char *part_name);
+Eina_Bool
 editor_part_item_append(Evas_Object *edit_object, Change *change, Eina_Bool 
merge,
                         const char *part_name, const char *item_name, const 
char *source_group);
 Eina_Bool
diff --git a/src/bin/editor/editor_part.c b/src/bin/editor/editor_part.c
index 56b3d12..6bc8947 100644
--- a/src/bin/editor/editor_part.c
+++ b/src/bin/editor/editor_part.c
@@ -588,3 +588,71 @@ editor_part_reset(Evas_Object *edit_object, Change 
*change, Eina_Bool merge __UN
 
    return res;
 }
+
+Eina_Bool
+editor_part_add(Evas_Object *edit_object, Change *change, Eina_Bool merge 
__UNUSED__,
+                const char *part_name, Edje_Part_Type type)
+{
+   Diff *diff;
+   Eina_Stringshare *event_info;
+
+   assert(edit_object != NULL);
+
+   if (change)
+     {
+        diff = mem_calloc(1, sizeof(Diff));
+        diff->redo.type = FUNCTION_TYPE_STRING_EDJEPARTTYPE;
+        diff->redo.function = editor_part_item_append;
+        diff->redo.args.type_sept.s1 = eina_stringshare_add(part_name);
+        diff->redo.args.type_sept.ept2 = type;
+        diff->undo.type = FUNCTION_TYPE_STRING;
+        diff->undo.function = editor_part_del;
+        diff->undo.args.type_s.s1 = eina_stringshare_add(part_name);
+
+        change_diff_add(change, diff);
+     }
+   if (!edje_edit_part_add(edit_object, part_name, type))
+     return false;
+
+   _editor_project_changed();
+   event_info = eina_stringshare_add(part_name);
+   evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ADDED, (void 
*)&event_info);
+   eina_stringshare_del(event_info);
+   return true;
+}
+
+Eina_Bool
+editor_part_del(Evas_Object *edit_object, Change *change, Eina_Bool merge 
__UNUSED__,
+                const char *part_name)
+{
+   Diff *diff;
+   Eina_Stringshare *event_info;
+   Edje_Part_Type type;
+
+   assert(edit_object != NULL);
+
+   event_info = eina_stringshare_add(part_name);
+   evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_DELETED, 
(void *)&event_info);
+   eina_stringshare_del(event_info);
+
+   if (change)
+     {
+        type = edje_edit_part_type_get(edit_object, part_name);
+        if (!editor_part_reset(edit_object, change, false, part_name))
+          return false;
+        diff = mem_calloc(1, sizeof(Diff));
+        diff->redo.type = FUNCTION_TYPE_STRING;
+        diff->redo.function = editor_part_del;
+        diff->redo.args.type_s.s1 = eina_stringshare_add(part_name);
+        diff->undo.type = FUNCTION_TYPE_STRING_EDJEPARTTYPE;
+        diff->undo.function = editor_part_add;
+        diff->undo.args.type_sept.s1 = eina_stringshare_add(part_name);
+        diff->undo.args.type_sept.ept2 = type;
+
+        change_diff_add(change, diff);
+     }
+   if (!edje_edit_part_del(edit_object, part_name))
+     return false;
+   _editor_project_changed();
+   return true;
+}

-- 


Reply via email to