summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>2016-10-11 15:50:10 +0300
committerVyacheslav Reutskiy <v.reutskiy@samsung.com>2016-10-12 15:03:20 +0300
commit8d7ec4181e939d377e3dc75918005e4363ef472f (patch)
tree8d718c24fbd7ea8611622146457eeaa641ed9694
parent49689708a6b3b1223c1b3b8e307eed5943aea84d (diff)
downloadefl-8d7ec4181e939d377e3dc75918005e4363ef472f.tar.gz
edje_edit: add API for get source code of global block data
This API is annex for edje_edit_object_source_generate. Together this API's provide a mechanism for generate source for custom groups from a edj file or more.
-rw-r--r--src/lib/edje/Edje_Edit.h11
-rw-r--r--src/lib/edje/edje_edit.c50
2 files changed, 61 insertions, 0 deletions
diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 4727e0abd9..89502c31c8 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -8163,6 +8163,17 @@ EAPI const char * edje_edit_object_source_generate(Evas_Object *obj);
EAPI char *edje_edit_full_source_generate(Evas_Object *obj);
+/**
+ * Return source code of global block data.
+ *
+ * Remember to free the string with edje_edit_string_free()
+ *
+ * @param obj The object being edited
+ *
+ * @return Source code of global block data.
+ */
+EAPI const char * edje_edit_data_source_generate(Evas_Object *obj);
+
//@}
/******************************************************************************/
/************************** ERROR API ***********************************/
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 48bc7142b7..7d897319ee 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -12791,6 +12791,56 @@ edje_edit_object_source_generate(Evas_Object *obj)
return _edje_edit_source_generate(obj, EINA_TRUE);
}
+EAPI const char *
+edje_edit_data_source_generate(Evas_Object *obj)
+{
+ Eina_Strbuf *buf = NULL;
+ Eina_Bool ret = EINA_TRUE;
+ Eina_Stringshare *str = NULL;
+ const char *entry;
+
+ GET_ED_OR_RETURN(NULL);
+
+ if (!ed->file) return NULL;
+
+ buf = eina_strbuf_new();
+
+ /* If data items exist, print them */
+ if (ed->file->data)
+ {
+ Edje_String *es;
+ size_t data_len = 0;
+ char *escaped_entry = NULL;
+ char *escaped_string = NULL;
+ BUF_APPEND(I0 "data {\n");
+ Eina_Iterator *it = eina_hash_iterator_key_new(ed->file->data);
+ EINA_ITERATOR_FOREACH(it, entry)
+ {
+ es = eina_hash_find(ed->file->data, entry);
+ str = edje_string_get(es);
+ if (!str) break;
+ data_len = strlen(str);
+ /* In case when data ends with '\n' character, this item recognize
+ * as data.file. This data will not generated into the source code
+ * of group. */
+ if (str[data_len - 1] == '\n') continue;
+ escaped_entry = eina_str_escape(entry);
+ escaped_string = eina_str_escape(str);
+ BUF_APPENDF(I1 "item: \"%s\" \"%s\";\n", escaped_entry, escaped_string);
+ free(escaped_entry);
+ free(escaped_string);
+ }
+ eina_iterator_free(it);
+ BUF_APPEND(I0 "}\n\n");
+ }
+
+ /* return resulted source code of the group */
+ if (ret)
+ str = eina_stringshare_add(eina_strbuf_string_get(buf));
+ eina_strbuf_free(buf);
+ return str;
+}
+
#undef COLLECT_RESOURCE
static Eina_Bool