Setters and getters functions to Api property of Parts and Programs
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 15 Jun 2010 01:51:46 +0000 (01:51 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 15 Jun 2010 01:51:46 +0000 (01:51 +0000)
Now we can set and retrieve, name and descripition of the api
property, from Parts and Programs.

By: Thiago Ribeiro Masaki <masaki@profusion.mobi>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@49678 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Edje_Edit.h
src/lib/edje_edit.c

index 5507d18..9e2b941 100644 (file)
@@ -732,6 +732,44 @@ EAPI Eina_Bool edje_edit_part_restack_above(Evas_Object *obj, const char *part);
  */
 EAPI Eina_Bool edje_edit_part_name_set(Evas_Object *obj, const char *part, const char *new_name);
 
+/** Get api's name of a part.
+ *
+ * @param obj Object being edited.
+ * @param part Name of the part.
+ *
+ * @return name of the api if succesful, NULL otherwise.
+ */
+EAPI const char * edje_edit_part_api_name_get(Evas_Object *obj, const char *part);
+
+/** Get api's description of a part.
+ *
+ * @param obj Object being edited.
+ * @param part Name of the part.
+ *
+ * @return description of the api if succesful, NULL otherwise.
+ */
+EAPI const char * edje_edit_part_api_description_get(Evas_Object *obj, const char *part);
+
+/** Set api's name of a part.
+ *
+ * @param obj Object being edited.
+ * @param part Name of the part.
+ * @param name New name for the api property.
+ *
+ * @return EINA_TRUE if succesful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_api_name_set(Evas_Object *obj, const char *part, const char *name);
+
+/** Set api's description of a part.
+ *
+ * @param obj Object being edited.
+ * @param part Name of part.
+ * @param description New description for the api property.
+ *
+ * @return EINA_TRUE if succesful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_api_description_set(Evas_Object *obj, const char *part, const char *description);
+
 /** Get the type of a part.
  *
  * @param obj Object being edited.
@@ -3102,6 +3140,44 @@ EAPI Eina_Bool edje_edit_program_afters_clear(Evas_Object *obj, const char *prog
  */
 EAPI const char * edje_edit_program_state_get(Evas_Object *obj, const char *prog);
 
+/** Get api's name of a program.
+ *
+ * @param obj Object being edited.
+ * @param prog Name of program.
+ *
+ * @return name of the api if succesful, NULL otherwise.
+ */
+EAPI const char * edje_edit_program_api_name_get(Evas_Object *obj, const char *prog);
+
+/** Get api's description of a program.
+ *
+ * @param obj Object being edited.
+ * @param prog Name of program.
+ *
+ * @return description of the api if succesful, NULL otherwise.
+ */
+EAPI const char * edje_edit_program_api_description_get(Evas_Object *obj, const char *prog);
+
+/** Set api's name of a program.
+ *
+ * @param obj Object being edited.
+ * @param prog Name of the part.
+ * @param name New name for the api property.
+ *
+ * @return EINA_TRUE if succesful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char *name);
+
+/** Set api's description of a program.
+ *
+ * @param obj Object being edited.
+ * @param prog Name of the program.
+ * @param description New description for the api property.
+ *
+ * @return EINA_TRUE if succesful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description);
+
 /** Set the state for the given program
  *
  * In a STATE_SET action this is the name of state to set.
index 7f9f2bf..d54bd16 100644 (file)
@@ -1905,6 +1905,44 @@ edje_edit_part_name_set(Evas_Object *obj, const char* part, const char* new_name
    return EINA_TRUE;
 }
 
+EAPI const char *
+edje_edit_part_api_name_get(Evas_Object *obj, const char *part)
+{
+   GET_RP_OR_RETURN(NULL);
+
+   return eina_stringshare_add(rp->part->api.name);
+}
+
+EAPI const char *
+edje_edit_part_api_description_get(Evas_Object *obj, const char *part)
+{
+   GET_RP_OR_RETURN(NULL);
+
+   return eina_stringshare_add(rp->part->api.description);
+}
+
+EAPI Eina_Bool
+edje_edit_part_api_name_set(Evas_Object *obj, const char *part, const char *name)
+{
+   GET_RP_OR_RETURN(EINA_FALSE);
+
+   _edje_if_string_free(ed, rp->part->api.name);
+   rp->part->api.name = eina_stringshare_add(name);
+
+   return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+edje_edit_part_api_description_set(Evas_Object *obj, const char *part, const char *description)
+{
+   GET_RP_OR_RETURN(EINA_FALSE);
+
+   _edje_if_string_free(ed, rp->part->api.description);
+   rp->part->api.description = eina_stringshare_add(description);
+
+   return EINA_TRUE;
+}
+
 Eina_Bool
 _edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type, const char *source)
 {
@@ -6059,6 +6097,46 @@ edje_edit_program_after_del(Evas_Object *obj, const char *prog, const char *afte
    return EINA_TRUE;
 }
 
+EAPI const char *
+edje_edit_program_api_name_get(Evas_Object *obj, const char *prog)
+{
+   GET_EPR_OR_RETURN(NULL);
+
+   return eina_stringshare_add(epr->api.name);
+}
+
+EAPI const char *
+edje_edit_program_api_description_get(Evas_Object *obj, const char *prog)
+{
+   GET_EPR_OR_RETURN(NULL);
+
+   return eina_stringshare_add(epr->api.description);
+}
+
+EAPI Eina_Bool
+edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char* name)
+{
+   GET_ED_OR_RETURN(EINA_FALSE);
+   GET_EPR_OR_RETURN(EINA_FALSE);
+
+   _edje_if_string_free(ed, epr->api.name);
+   epr->api.name = eina_stringshare_add(name);
+
+   return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description)
+{
+   GET_ED_OR_RETURN(EINA_FALSE);
+   GET_EPR_OR_RETURN(EINA_FALSE);
+
+   _edje_if_string_free(ed, epr->api.description);
+   epr->api.description = eina_stringshare_add(description);
+
+   return EINA_TRUE;
+}
+
 /*************************/
 /*  EMBRYO SCRIPTS  API  */
 /*************************/
@@ -6178,6 +6256,7 @@ _edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Str
    double db, db2;
    char *data;
    Eina_Bool ret = EINA_TRUE;
+   const char *api_name, *api_description;
 
    GET_ED_OR_RETURN(EINA_FALSE);
 
@@ -6278,6 +6357,30 @@ _edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Str
      }
 
    // TODO Support script {}
+   /* api */
+   api_name = edje_edit_program_api_name_get(obj, program);
+   api_description = edje_edit_program_api_description_get(obj, program);
+
+   if (api_name || api_description)
+     {
+       if (api_name && api_description)
+         {
+            BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description);
+            edje_edit_string_free(api_name);
+            edje_edit_string_free(api_description);
+         }
+       else
+         if (api_name)
+           {
+              BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name);
+              edje_edit_string_free(api_name);
+           }
+         else
+           {
+              BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description);
+              edje_edit_string_free(api_description);
+           }
+     }
 
    BUF_APPEND(I3 "}\n");
    return ret;
@@ -6527,6 +6630,7 @@ _edje_generate_source_of_part(Evas_Object *obj, const char *part, Eina_Strbuf *b
    Eina_List *l, *ll;
    char *data;
    Eina_Bool ret = EINA_TRUE;
+   const char *api_name, *api_description;
 
    BUF_APPENDF(I3"part { name: \"%s\";\n", part);
    BUF_APPENDF(I4"type: %s;\n", types[edje_edit_part_type_get(obj, part)]);
@@ -6594,6 +6698,30 @@ _edje_generate_source_of_part(Evas_Object *obj, const char *part, Eina_Strbuf *b
      }
    edje_edit_string_list_free(ll);
 
+   api_name = edje_edit_part_api_name_get(obj, part);
+   api_description = edje_edit_part_api_description_get(obj, part);
+
+   if (api_name || api_description)
+     {
+       if (api_name && api_description)
+         {
+            BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description);
+            edje_edit_string_free(api_name);
+            edje_edit_string_free(api_description);
+         }
+       else
+         if (api_name)
+           {
+              BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name);
+              edje_edit_string_free(api_name);
+           }
+         else
+           {
+              BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description);
+              edje_edit_string_free(api_description);
+           }
+     }
+
    BUF_APPEND(I3"}\n");//part
    return ret;
 }