I wrote a patch that does the compile time check of the group name when
adding a GROUP: tag. Now the part_swallow embryo function *requires* the
second parameter to be tagged by GROUP: and refer to an existing group.
The following patch includes both the part_swallow embryo function
(without modifications to the previous patch except on the embryo
prototipe declaration) and changes to src/bin/edje_cc_out.c to add the
GROUP: check.
I will be more than grateful for any corrections or comments :)!
Thanks!
--
Santiago Aguiar
Edantech
? edje_part_swallow.patch
Index: data/include/edje.inc
===================================================================
RCS file: /var/cvs/e/e17/libs/edje/data/include/edje.inc,v
retrieving revision 1.23
diff -n -u -r1.23 edje.inc
--- data/include/edje.inc 11 Aug 2007 13:20:33 -0000 1.23
+++ data/include/edje.inc 28 Mar 2008 00:03:29 -0000
@@ -108,6 +108,7 @@
native stop_programs_on (part_id);
native set_min_size (Float:w, Float:h);
native set_max_size (Float:w, Float:h);
+native part_swallow (part_id, GROUP:str[]);
enum Msg_Type
{
Index: src/bin/edje_cc_out.c
===================================================================
RCS file: /var/cvs/e/e17/libs/edje/src/bin/edje_cc_out.c,v
retrieving revision 1.59
diff -n -u -r1.59 edje_cc_out.c
--- src/bin/edje_cc_out.c 25 Nov 2007 16:22:58 -0000 1.59
+++ src/bin/edje_cc_out.c 28 Mar 2008 00:03:32 -0000
@@ -12,6 +12,7 @@
typedef struct _Part_Lookup Part_Lookup;
typedef struct _Program_Lookup Program_Lookup;
+typedef struct _Group_Lookup Group_Lookup;
typedef struct _String_Lookup Image_Lookup;
typedef struct _String_Lookup Spectrum_Lookup;
typedef struct _Slave_Lookup Slave_Lookup;
@@ -31,6 +32,11 @@
int *dest;
};
+struct _Group_Lookup
+{
+ char *name;
+};
+
struct _String_Lookup
{
char *name;
@@ -50,8 +56,8 @@
int val;
};
-static void data_queue_image_pc_lookup(Edje_Part_Collection *pc, char *name, int *dest);
-static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, int *val));
+static void data_queue_image_pc_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len);
+static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char *ptr, int len));
Edje_File *edje_file = NULL;
Evas_List *edje_collections = NULL;
@@ -77,6 +83,7 @@
static Evas_List *part_lookups = NULL;
static Evas_List *program_lookups = NULL;
+static Evas_List *group_lookups = NULL;
static Evas_List *image_lookups = NULL;
static Evas_List *spectrum_lookups = NULL;
static Evas_List *part_slave_lookups = NULL;
@@ -821,6 +828,16 @@
}
void
+data_queue_group_lookup(char *name)
+{
+ Group_Lookup *gl;
+
+ gl = mem_alloc(SZ(Group_Lookup));
+ group_lookups = evas_list_append(group_lookups, gl);
+ gl->name = mem_strdup(name);
+}
+
+void
data_queue_part_lookup(Edje_Part_Collection *pc, char *name, int *dest)
{
Part_Lookup *pl;
@@ -975,6 +992,31 @@
free(pl);
}
+ while (group_lookups)
+ {
+ Group_Lookup *gl;
+
+ gl = group_lookups->data;
+ for (l = edje_file->collection_dir->entries; l; l = l->next)
+ {
+ Edje_Part_Collection_Directory_Entry *de;
+ de = l->data;
+ if (!strcmp(de->entry, gl->name))
+ {
+ break;
+ }
+ }
+ if (!l)
+ {
+ fprintf(stderr, "%s: Error. unable to find group name %s\n",
+ progname, gl->name);
+ exit(-1);
+ }
+ group_lookups = evas_list_remove(group_lookups, gl);
+ free(gl->name);
+ free(gl);
+ }
+
while (image_lookups)
{
Image_Lookup *il;
@@ -1069,7 +1111,7 @@
}
static void
-data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, int *val))
+data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len))
{
char *p;
char *key;
@@ -1097,78 +1139,72 @@
{
if (!strncmp(p, key, keyl))
{
- Code_Lookup *cl;
-
- cl = mem_alloc(SZ(Code_Lookup));
- if (cl)
+ char *ptr;
+ int len;
+ int inesc = 0;
+ char *name;
+
+ ptr = p;
+ p += keyl;
+ while ((*p))
{
- int inesc = 0;
- char *name;
-
- cl->ptr = p;
- p += keyl;
- while ((*p))
- {
- if (!inesc)
+ if (!inesc)
+ {
+ if (*p == '\\') inesc = 1;
+ else if (*p == '\"')
{
- if (*p == '\\') inesc = 1;
- else if (*p == '\"')
- {
- /* string concatenation, see below */
- if (*(p + 1) != '\"')
- break;
- else
- p++;
- }
+ /* string concatenation, see below */
+ if (*(p + 1) != '\"')
+ break;
+ else
+ p++;
}
- else
- inesc = 0;
- p++;
}
- cl->len = p - cl->ptr + 1;
- name = alloca(cl->len);
- if (name)
- {
- char *pp;
- int i;
+ else
+ inesc = 0;
+ p++;
+ }
+ len = p - ptr + 1;
+ name = alloca(len);
+ if (name)
+ {
+ char *pp;
+ int i;
- name[0] = 0;
- pp = cl->ptr + keyl;
- inesc = 0;
- i = 0;
- while (*pp)
+ name[0] = 0;
+ pp = ptr + keyl;
+ inesc = 0;
+ i = 0;
+ while (*pp)
+ {
+ if (!inesc)
{
- if (!inesc)
- {
- if (*pp == '\\') inesc = 1;
- else if (*pp == '\"')
- {
- /* concat strings like "foo""bar" to "foobar" */
- if (*(pp + 1) == '\"')
- pp++;
- else
- {
- name[i] = 0;
- break;
- }
- }
+ if (*pp == '\\') inesc = 1;
+ else if (*pp == '\"')
+ {
+ /* concat strings like "foo""bar" to "foobar" */
+ if (*(pp + 1) == '\"')
+ pp++;
else
- {
- name[i] = *pp;
- name[i + 1] = 0;
- i++;
+ {
+ name[i] = 0;
+ break;
}
}
else
- inesc = 0;
- pp++;
+ {
+ name[i] = *pp;
+ name[i + 1] = 0;
+ i++;
+ }
}
- func(pc, name, &(cl->val));
- }
- code_lookups = evas_list_append(code_lookups, cl);
- }
- else break;
- }
+ else
+ inesc = 0a;
+ pp++;
+ }
+ func(pc, name, ptr, len);
+ }
+ }
}
else
{
@@ -1186,13 +1222,49 @@
}
static void
-data_queue_image_pc_lookup(Edje_Part_Collection *pc, char *name, int *dest)
+_data_queue_part_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
{
- data_queue_image_lookup(name, dest);
+ Code_Lookup *cl;
+ cl = mem_alloc(SZ(Code_Lookup));
+ cl->ptr = ptr;
+ cl->len = len;
+
+ data_queue_part_lookup(pc, name, &(cl->val));
+
+ code_lookups = evas_list_append(code_lookups, cl);
+}
+static void
+_data_queue_program_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
+{
+ Code_Lookup *cl;
+ cl = mem_alloc(SZ(Code_Lookup));
+ cl->ptr = ptr;
+ cl->len = len;
+
+ data_queue_program_lookup(pc, name, &(cl->val));
+
+ code_lookups = evas_list_append(code_lookups, cl);
+}
+static void
+_data_queue_group_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
+{
+ data_queue_group_lookup(name);
+}
+static void
+_data_queue_image_pc_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
+{
+ Code_Lookup *cl;
+ cl = mem_alloc(SZ(Code_Lookup));
+ cl->ptr = ptr;
+ cl->len = len;
+
+ data_queue_image_lookup(name, &(cl->val));
+
+ code_lookups = evas_list_append(code_lookups, cl);
}
static void
-data_queue_spectrum_pc_lookup(Edje_Part_Collection *pc, char *name, int *dest)
+_data_queue_spectrum_pc_lookup(Edje_Part_Collection *pc, char *name, int *dest)
{
data_queue_spectrum_lookup(name, dest);
}
@@ -1215,9 +1287,10 @@
if (cd->shared)
{
- data_process_string(pc, "PART", cd->shared, data_queue_part_lookup);
- data_process_string(pc, "PROGRAM", cd->shared, data_queue_program_lookup);
- data_process_string(pc, "IMAGE", cd->shared, data_queue_image_pc_lookup);
+ data_process_string(pc, "PART", cd->shared, _data_queue_part_lookup);
+ data_process_string(pc, "PROGRAM", cd->shared, _data_queue_program_lookup);
+ data_process_string(pc, "IMAGE", cd->shared, _data_queue_image_pc_lookup);
+ data_process_string(pc, "GROUP", cd->shared, _data_queue_group_lookup);
}
for (ll = cd->programs; ll; ll = ll->next)
{
@@ -1226,9 +1299,10 @@
cp = ll->data;
if (cp->script)
{
- data_process_string(pc, "PART", cp->script, data_queue_part_lookup);
- data_process_string(pc, "PROGRAM", cp->script, data_queue_program_lookup);
- data_process_string(pc, "IMAGE", cp->script, data_queue_image_pc_lookup);
+ data_process_string(pc, "PART", cp->script, _data_queue_part_lookup);
+ data_process_string(pc, "PROGRAM", cp->script, _data_queue_program_lookup);
+ data_process_string(pc, "IMAGE", cp->script, _data_queue_image_pc_lookup);
+ data_process_string(pc, "GROUP", cp->script, _data_queue_group_lookup);
}
}
}
Index: src/lib/edje_embryo.c
===================================================================
RCS file: /var/cvs/e/e17/libs/edje/src/lib/edje_embryo.c,v
retrieving revision 1.59
diff -n -u -r1.59 edje_embryo.c
--- src/lib/edje_embryo.c 6 Mar 2008 17:52:58 -0000 1.59
+++ src/lib/edje_embryo.c 28 Mar 2008 00:03:37 -0000
@@ -174,6 +174,7 @@
* set_clip(part_id, clip_part_id)
* get_clip(part_id)
*
+ * part_swallow(part_id, group_name)
*
* ADD/DEL CUSTOM OBJECTS UNDER SOLE EMBRYO SCRIPT CONTROL
*
@@ -2129,6 +2130,42 @@
return 0;
}
+/* part_swallow(part_id, group_name) */
+static Embryo_Cell
+_edje_embryo_fn_part_swallow(Embryo_Program *ep, Embryo_Cell *params)
+{
+ int part_id = 0;
+ char* group_name = 0;
+ Edje *ed;
+ Edje_Real_Part *rp;
+ Evas_Object *new_obj;
+
+ CHKPARAM(2);
+
+ part_id = params[1];
+ if (part_id < 0) return 0;
+
+ GETSTR(group_name, params[2]);
+ if (!group_name) return 0;
+
+ ed = embryo_program_data_get(ep);
+
+ rp = ed->table_parts[part_id % ed->table_parts_size];
+ if (!rp) return 0;
+
+ new_obj = edje_object_add(ed->evas);
+ if (!new_obj) return 0;
+
+ if (!edje_object_file_set(new_obj, ed->file->path, group_name))
+ {
+ evas_object_del(new_obj);
+ return 0;
+ }
+ edje_object_part_swallow(ed->obj, rp->part->name, new_obj);
+
+ return 0;
+}
+
void
_edje_embryo_script_init(Edje *ed)
{
@@ -2203,6 +2240,8 @@
embryo_program_native_call_add(ep, "set_state_val", _edje_embryo_fn_set_state_val);
embryo_program_native_call_add(ep, "get_state_val", _edje_embryo_fn_get_state_val);
+ embryo_program_native_call_add(ep, "part_swallow", _edje_embryo_fn_part_swallow);
+
// embryo_program_vm_push(ed->collection->script);
// _edje_embryo_globals_init(ed);
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel