externals {} in edje_edit, source generation and add module to the external_Type api to keep track of who registers what

SVN revision: 44003
This commit is contained in:
Iván Briano 2009-11-26 17:01:31 +00:00
parent 4b44a59d2e
commit 828b281904
3 changed files with 159 additions and 1 deletions

View File

@ -302,6 +302,7 @@ typedef struct _Edje_External_Param_Info Edje_External_Param_Info;
struct _Edje_External_Type
{
const char *module;
Evas_Object *(*add) (void *data, Evas *evas, Evas_Object *parent, const Eina_List *params);
void (*state_set) (void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos);
void (*signal_emit) (void *data, Evas_Object *obj, const char *emission, const char *source);

View File

@ -448,6 +448,38 @@ edje_edit_style_tag_del(
const char* tag ///< The name of the tag to remove
);
//@}
/******************************************************************************/
/************************ EXTERNALS API ***********************************/
/******************************************************************************/
/** @name Externals API
* Functions to deal with list of external modules (see @ref edcref).
*/ //@{
/** Get the list of all the externals requested in the given edje object.
* Use edje_edit_string_list_free() when you don't need it anymore.
*/
EAPI Eina_List * ///@return An Eina_List* of string (char *)containing all the externals names.
edje_edit_externals_list_get(
Evas_Object *obj ///< The edje object
);
/** Add an external module to be requested on edje load
* If one with the same name exists nothing is created and FALSE is returned.
*/
EAPI Eina_Bool ///@return TRUE on success, FALSE otherwise
edje_edit_external_add(
Evas_Object *obj, ///< The edje object
const char *external ///< The new name for the extermal
);
/** Delete the given external from the list. */
EAPI void
edje_edit_external_del(
Evas_Object *obj, ///< The edje object
const char *external ///< The name for the external to delete
);
//@}
/******************************************************************************/
/************************** PARTS API *************************************/

View File

@ -600,6 +600,22 @@ _edje_edit_style_tag_get(Edje *ed, const char *style, const char *name)
return NULL;
}
static Edje_External_Directory_Entry *
_edje_edit_external_get(Edje *ed, const char *name)
{
Eina_List *l;
Edje_External_Directory_Entry *e;
if (!ed || !ed->file || !ed->file->external_dir || !name)
return NULL;
EINA_LIST_FOREACH(ed->file->external_dir->entries, l, e)
if (e->entry && !strcmp(e->entry, name))
return e;
return NULL;
}
/*****************/
/* GENERAL API */
/*****************/
@ -1433,6 +1449,68 @@ edje_edit_style_tag_del(Evas_Object * obj, const char* style, const char* tag)
t = NULL;
}
/*******************/
/* EXTERNALS API */
/*******************/
EAPI Eina_List *
edje_edit_externals_list_get(Evas_Object *obj)
{
Eina_List *externals = NULL;
Eina_List *l;
Edje_External_Directory_Entry *e;
GET_ED_OR_RETURN(NULL);
if (!ed->file || !ed->file->external_dir)
return NULL;
//printf("GET STYLES LIST %d\n", eina_list_count(ed->file->styles));
EINA_LIST_FOREACH(ed->file->external_dir->entries, l, e)
externals = eina_list_append(externals, eina_stringshare_add(e->entry));
return externals;
}
EAPI Eina_Bool
edje_edit_external_add(Evas_Object *obj, const char *external)
{
Edje_External_Directory_Entry *e;
GET_ED_OR_RETURN(0);
e = _edje_edit_external_get(ed, external);
if (e) return 0;
e = _alloc(sizeof(Edje_External_Directory_Entry));
if (!e) return 0;
e->entry = (char*)eina_stringshare_add(external);
if (!ed->file->external_dir)
ed->file->external_dir = _alloc(sizeof(Edje_External_Directory));
ed->file->external_dir->entries = eina_list_append(ed->file->external_dir->entries, e);
return 1;
}
EAPI void
edje_edit_external_del(Evas_Object *obj, const char *external)
{
Edje_External_Directory_Entry *e;
GET_ED_OR_RETURN();
e = _edje_edit_external_get(ed, external);
if (!e) return;
ed->file->external_dir->entries = eina_list_remove(ed->file->external_dir->entries, e);
if (!ed->file->external_dir->entries)
{
free(ed->file->external_dir);
ed->file->external_dir = NULL;
}
_edje_if_string_free(ed, e->entry);
free(e);
}
/***************/
/* PARTS API */
/***************/
@ -5289,7 +5367,7 @@ edje_edit_script_get(Evas_Object *obj)
#define I6 " "
#define I7 " "
static char *types[] = {"NONE", "RECT", "TEXT", "IMAGE", "SWALLOW", "TEXTBLOCK", "GRADIENT", "GROUP"};
static char *types[] = {"NONE", "RECT", "TEXT", "IMAGE", "SWALLOW", "TEXTBLOCK", "GRADIENT", "GROUP", "BOX", "TABLE", "EXTERNAL"};
static char *effects[] = {"NONE", "PLAIN", "OUTLINE", "SOFT_OUTLINE", "SHADOW", "SOFT_SHADOW", "OUTLINE_SHADOW", "OUTLINE_SOFT_SHADOW ", "FAR_SHADOW ", "FAR_SOFT_SHADOW", "GLOW"};
static char *prefers[] = {"NONE", "VERTICAL", "HORIZONTAL", "BOTH"};
static void
@ -5352,6 +5430,12 @@ _edje_generate_source_of_style(Edje * ed, const char *name, FILE * f)
}
}
static void
_edje_generate_source_of_external(Edje *ed, const char *name, FILE *f)
{
fprintf(f, I1 "external: \"%s\";\n", name);
}
static void
_edje_generate_source_of_program(Evas_Object *obj, const char *program, FILE *f)
{
@ -5651,6 +5735,36 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s
//TODO rel1 and 2 seems unused
fprintf(f, I5"}\n");
}
//External
if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
{
if ((ll = edje_edit_state_external_params_list_get(obj, part, state)))
{
Edje_External_Param *p;
fprintf(f, I5"params {\n");
EINA_LIST_FOREACH(ll, l, p)
{
switch (p->type)
{
case EDJE_EXTERNAL_PARAM_TYPE_INT:
fprintf(f, I6"int: \"%s\" \"%d\";\n", p->name, p->i);
break;
case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
fprintf(f, I6"double: \"%s\" \"%g\";\n", p->name, p->d);
break;
case EDJE_EXTERNAL_PARAM_TYPE_STRING:
if (p->s)
fprintf(f, I6"string: \"%s\" \"%s\";\n", p->name, p->s);
break;
default:
break;
}
}
fprintf(f, I5"}\n");
}
}
fprintf(f, I4"}\n");//description
}
@ -5880,6 +5994,17 @@ _edje_generate_source(Evas_Object *obj)
edje_edit_string_list_free(ll);
}
/* Externals */
if ((ll = edje_edit_externals_list_get(obj)))
{
fprintf(f, I0 "externals {\n");
EINA_LIST_FOREACH(ll, l, entry)
_edje_generate_source_of_external(ed, entry, f);
fprintf(f, I0 "}\n\n");
edje_edit_string_list_free(ll);
}
/* Collections */
fprintf(f, "collections {\n");
ll = edje_file_collection_list(ed->file->path);