summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>2012-12-04 20:21:59 +0000
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>2013-08-13 17:58:57 -0300
commit9e59edb4e174cae588c806b1e20a88fc8b83edcb (patch)
treea1d5e9284f373013c4f1b51ed3e23831b5ba99d0
parent081071ccb209f4cb8bf9eba1f18dc33fac5a9394 (diff)
downloadedje-accepted/tizen/ivi/genivi/20140131.030537.tar.gz
edje-accepted/tizen/ivi/genivi/20140131.030537.tar.bz2
edje-accepted/tizen/ivi/genivi/20140131.030537.zip
It is now you can run programs with names generated dinamically. Say that you have 10 programs indexed somehow. You can now call them using the following snippet: script { new program_id[15], i; for (i = 0; i < 10; i++) { snprintf(program_id, 15, "my_program_%d", i+1); run_program(get_program_id(program_id)); } } Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
-rw-r--r--data/include/edje.inc1
-rw-r--r--src/lib/edje_embryo.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/data/include/edje.inc b/data/include/edje.inc
index dfa5416..a3995cf 100644
--- a/data/include/edje.inc
+++ b/data/include/edje.inc
@@ -84,6 +84,7 @@ native cancel_anim(id);
*/
native emit (sig[], src[]);
native get_part_id (part[]);
+native get_program_id (program[]);
native set_state (part_id, state[], Float:state_val);
native get_state (part_id, dst[], maxlen, &Float:val);
native set_tween_state (part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val);
diff --git a/src/lib/edje_embryo.c b/src/lib/edje_embryo.c
index 9d85738..b242348 100644
--- a/src/lib/edje_embryo.c
+++ b/src/lib/edje_embryo.c
@@ -828,6 +828,29 @@ _edje_embryo_fn_get_part_id(Embryo_Program *ep, Embryo_Cell *params)
return -1;
}
+/* get_program_id(program[]) */
+static Embryo_Cell
+_edje_embryo_fn_get_program_id(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ Edje_Program **prog;
+ char *p;
+ int i;
+
+ CHKPARAM(1);
+ ed = embryo_program_data_get(ep);
+ GETSTR(p, params[1]);
+ if (!p) return -1;
+ prog = ed->table_programs;
+ if (!prog) return -1;
+ for (i = 0; i < ed->table_programs_size; i++, prog++)
+ {
+ if (!(*prog)->name) continue;
+ if (!strcmp((*prog)->name, p)) return (*prog)->id;
+ }
+ return -1;
+}
+
static Embryo_Cell
_edje_embryo_fn_play_sample(Embryo_Program *ep, Embryo_Cell *params)
{
@@ -3024,6 +3047,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit);
embryo_program_native_call_add(ep, "get_part_id", _edje_embryo_fn_get_part_id);
+ embryo_program_native_call_add(ep, "get_program_id", _edje_embryo_fn_get_program_id);
embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state);
embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state);
embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);