rimmed pushed a commit to branch master.

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

commit 0a9b0c52e4650271de79da41c7f588e9c0ebe4f6
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Thu Nov 19 15:30:31 2015 +0200

    editor: add part_append/_del methods
---
 src/bin/common/signals.h     | 20 ++++++++++++
 src/bin/editor/editor.h      |  6 ++++
 src/bin/editor/editor_part.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+)

diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h
index 9f93b7b..727040a 100644
--- a/src/bin/common/signals.h
+++ b/src/bin/common/signals.h
@@ -164,6 +164,26 @@ typedef struct {
  */
 #define SIGNAL_EDITOR_STATE_DELETED "SIGNAL_EDITOR_STATE_DELETED"
 
+typedef struct {
+   const char *part_name;
+   const char *item_name;
+} Editor_Item;
+/**
+ * emited when item is added in editor.
+ * eventinfo - Editor_Item struct
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_EDITOR_PART_ITEM_ADDED "SIGNAL_EDITOR_PART_ITEM_ADDED"
+
+/**
+ * emited *before* item will be deleted in editor.
+ * eventinfo - Editor_Item struct
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_EDITOR_PART_ITEM_DELETED "SIGNAL_EDITOR_PART_ITEM_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 b0ba6b1..31c8d78 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_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
+editor_part_item_del(Evas_Object *edit_object, Change *change, Eina_Bool merge,
+                     const char *part_name, const char *item_name);
+Eina_Bool
 editor_part_item_min_w_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name, const char *item_name,
       int new_val);
 Eina_Bool
diff --git a/src/bin/editor/editor_part.c b/src/bin/editor/editor_part.c
index 17a8041..add4d85 100644
--- a/src/bin/editor/editor_part.c
+++ b/src/bin/editor/editor_part.c
@@ -444,3 +444,77 @@ editor_part_item_reset(Evas_Object *edit_object, Change 
*change, Eina_Bool merge
 
    return res;
 }
+
+Eina_Bool
+editor_part_item_append(Evas_Object *edit_object, Change *change, Eina_Bool 
merge __UNUSED__,
+                        const char *part_name, const char *item_name, const 
char *source_group)
+{
+   Diff *diff;
+   Editor_Item event_info;
+
+   assert(edit_object != NULL);
+
+   if (change)
+     {
+        diff = mem_calloc(1, sizeof(Diff));
+        diff->redo.type = FUNCTION_TYPE_STRING_STRING_STRING;
+        diff->redo.function = editor_part_item_append;
+        diff->redo.args.type_sss.s1 = eina_stringshare_add(part_name);
+        diff->redo.args.type_sss.s2 = eina_stringshare_add(item_name);
+        diff->redo.args.type_sss.s3 = eina_stringshare_add(source_group);
+        diff->undo.type = FUNCTION_TYPE_STRING_STRING;
+        diff->undo.function = editor_part_item_del;
+        diff->undo.args.type_ss.s1 = eina_stringshare_add(part_name);
+        diff->undo.args.type_ss.s2 = eina_stringshare_add(item_name);
+
+        change_diff_add(change, diff);
+     }
+   if (!edje_edit_part_item_append(edit_object, part_name, item_name, 
source_group))
+     return false;
+   _editor_project_changed();
+   event_info.part_name = eina_stringshare_add(part_name);
+   event_info.item_name = eina_stringshare_add(item_name);
+   evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_ADDED, 
(void *)&event_info);
+   eina_stringshare_del(event_info.part_name);
+   eina_stringshare_del(event_info.item_name);
+   return true;
+}
+
+Eina_Bool
+editor_part_item_del(Evas_Object *edit_object, Change *change, Eina_Bool merge 
__UNUSED__,
+                     const char *part_name, const char *item_name)
+{
+   Diff *diff;
+   Editor_Item event_info;
+   Eina_Stringshare *source_group;
+
+   assert(edit_object != NULL);
+
+   event_info.part_name = eina_stringshare_add(part_name);
+   event_info.item_name = eina_stringshare_add(item_name);
+   evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_DELETED, 
(void *)&event_info);
+   eina_stringshare_del(event_info.part_name);
+   eina_stringshare_del(event_info.item_name);
+   if (change)
+     {
+        source_group = edje_edit_part_item_source_get(edit_object, part_name, 
item_name);
+        if (!editor_part_item_reset(edit_object, change, false, part_name, 
item_name))
+          return false;
+        diff = mem_calloc(1, sizeof(Diff));
+        diff->redo.type = FUNCTION_TYPE_STRING_STRING;
+        diff->redo.function = editor_part_item_del;
+        diff->redo.args.type_ss.s1 = eina_stringshare_add(part_name);
+        diff->redo.args.type_ss.s2 = eina_stringshare_add(item_name);
+        diff->undo.type = FUNCTION_TYPE_STRING_STRING_STRING;
+        diff->undo.function = editor_part_item_append;
+        diff->undo.args.type_sss.s1 = eina_stringshare_add(part_name);
+        diff->undo.args.type_sss.s2 = eina_stringshare_add(item_name);
+        diff->undo.args.type_sss.s3 = eina_stringshare_add(source_group);
+
+        change_diff_add(change, diff);
+     }
+   if (!edje_edit_part_item_del(edit_object, part_name, item_name))
+     return false;
+   _editor_project_changed();
+   return true;
+}

-- 


Reply via email to