Here is a new patch that replace the strcmp by == (thank you cedric), but
that might not work with editje.
2010/2/5 Cedric BAIL <cedric.b...@free.fr>
> On Mon, Feb 1, 2010 at 5:54 PM, Gustavo Sverzut Barbieri
> <barbi...@profusion.mobi> wrote:
> > On Mon, Feb 1, 2010 at 2:19 PM, tristan <blunde...@gmail.com> wrote:
> >> Hello,
> >>
> >> I was having trouble with the EDC programs that were missing a filter
> for
> >> the current state of source part. This allow for instance to make a
> toggle
> >> button without using any C code.
> >>
> >> I made a patch that add an optional parameter to the "source" keyword of
> an
> >> EDC program : the part state. If this second parameter is omitted, then
> it
> >> behave exactly the same as before, and therefore stay compatible with
> all
> >> other EDC files.
> >>
> >> Here is an example:
> >> program {
> >> name: "set_on"
> >> signal: "mouse,up,*";
> >> source: "button" "is_off"
> >> action: STATE_SET "is_on" 0.0;
> >> target: "button";
> >> }
> >> program {
> >> name: "set_off"
> >> signal: "mouse,up,*";
> >> source: "button" "is_on"
> >> action: STATE_SET "is_off" 0.0;
> >> target: "button";
> >> }
> >
> > dunno if this is good... and you don't need C code to do it, you can
> > use embryo or lua.
>
> Yes, you can, but it's lighter in my opinion if we could just do that
> this way. Reading from the patch, doesn't sound like it could break
> older edje and provide a nice feature for people that don't like to
> start an script just to test a state.
> --
> Cedric BAIL
>
--
618FE3EF
diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c
index ca1cb45..4872923 100644
--- a/src/bin/edje_cc_handlers.c
+++ b/src/bin/edje_cc_handlers.c
@@ -5697,7 +5697,7 @@ st_collections_group_parts_part_description_params_string(void)
program {
name: "programname";
signal: "signalname";
- source: "partname";
+ source: "partname" "statename";
in: 0.3 0.0;
action: STATE_SET "statename" state_value;
transition: LINEAR 0.5;
@@ -5798,11 +5798,13 @@ st_collections_group_programs_program_signal(void)
@property
source
@parameters
- [source name]
+ [source name state]
@effect
Source of accepted signal. Sources may be globbed, but only one source
keyword per program may be used. ex:source: "button-*"; (Signals from
- any part or program named "button-*" are accepted)
+ any part or program named "button-*" are accepted).
+ The state part is optional and allow you to accept signal only if <name> is
+ in its state <state>. No state set means all states.
@endproperty
*/
static void
@@ -5811,11 +5813,17 @@ st_collections_group_programs_program_source(void)
Edje_Part_Collection *pc;
Edje_Program *ep;
- check_arg_count(1);
+ check_min_arg_count(1);
pc = eina_list_data_get(eina_list_last(edje_collections));
ep = eina_list_data_get(eina_list_last(pc->programs));
ep->source = parse_str(0);
+
+ if (is_param(1)) {
+ ep->source_state = parse_str(1);
+ } else {
+ ep->source_state = NULL;
+ }
}
/**
diff --git a/src/lib/edje_data.c b/src/lib/edje_data.c
index 11c4e9f..d4c77ca 100644
--- a/src/lib/edje_data.c
+++ b/src/lib/edje_data.c
@@ -214,6 +214,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "name", name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "signal", signal, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "source", source, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "source_state", source_state, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.from", in.from, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "action", action, EET_T_INT);
diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c
index 36a34f0..a52df05 100644
--- a/src/lib/edje_edit.c
+++ b/src/lib/edje_edit.c
@@ -4762,6 +4762,7 @@ edje_edit_program_add(Evas_Object *obj, const char *name)
epr->name = eina_stringshare_add(name);
epr->signal = NULL;
epr->source = NULL;
+ epr->source_state = NULL;
epr->in.from = 0.0;
epr->in.range = 0.0;
epr->action = 0;
@@ -4815,6 +4816,7 @@ edje_edit_program_del(Evas_Object *obj, const char *prog)
_edje_if_string_free(ed, epr->name);
_edje_if_string_free(ed, epr->signal);
_edje_if_string_free(ed, epr->source);
+ _edje_if_string_free(ed, epr->source_state);
_edje_if_string_free(ed, epr->state);
_edje_if_string_free(ed, epr->state2);
@@ -4981,6 +4983,32 @@ edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *sou
}
EAPI const char *
+edje_edit_program_source_state_get(Evas_Object *obj, const char *prog)
+{
+ GET_EPR_OR_RETURN(NULL);
+
+ if (!epr->source_state) return NULL;
+ //printf("GET SOURCE for program: %s [%s]\n", prog, epr->source_state);
+ return eina_stringshare_add(epr->source_state);
+}
+
+EAPI Eina_Bool
+edje_edit_program_source_state_set(Evas_Object *obj, const char *prog, const char *source_state)
+{
+ GET_ED_OR_RETURN(0);
+ GET_EPR_OR_RETURN(0);
+
+ if (!source_state) return 0;
+
+ //printf("SET SOURCE for program: %s [%s]\n", prog, source);
+
+ _edje_if_string_free(ed, epr->source_state);
+ epr->source = eina_stringshare_add(source_state);
+
+ return 1;
+}
+
+EAPI const char *
edje_edit_program_signal_get(Evas_Object *obj, const char *prog)
{
GET_EPR_OR_RETURN(NULL);
diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c
index 5710467..00b4ace 100644
--- a/src/lib/edje_load.c
+++ b/src/lib/edje_load.c
@@ -1096,6 +1096,7 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec)
if (pr->name) eina_stringshare_del(pr->name);
if (pr->signal) eina_stringshare_del(pr->signal);
if (pr->source) eina_stringshare_del(pr->source);
+ if (pr->source_state) eina_stringshare_del(pr->source_state);
if (pr->state) eina_stringshare_del(pr->state);
if (pr->state2) eina_stringshare_del(pr->state2);
}
diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h
index 5fd2566..4231f38 100644
--- a/src/lib/edje_private.h
+++ b/src/lib/edje_private.h
@@ -334,6 +334,7 @@ struct _Edje_Program /* a conditional program to be run */
const char *signal; /* if signal emission name matches the glob here... */
const char *source; /* if part that emitted this (name) matches this glob */
+ const char *source_state; /* if part state that emitted this (name) matches this glob */
struct {
double from;
diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c
index ab51431..78f3212 100644
--- a/src/lib/edje_program.c
+++ b/src/lib/edje_program.c
@@ -1015,13 +1015,24 @@ struct _Edje_Program_Data
static int _edje_glob_callback(Edje_Program *pr, void *dt)
{
+ char exec = 0;
struct _Edje_Program_Data *data = dt;
+ Edje_Real_Part *rp = NULL;
#ifdef EDJE_PROGRAM_CACHE
data->matched++;
#endif
- _edje_program_run(data->ed, pr, 0, data->signal, data->source);
+ if (pr->source_state)
+ {
+ rp = _edje_real_part_get(data->ed, data->source);
+ if (rp)
+ exec = (rp->chosen_description->state.name == pr->source_state);
+ }
+
+ if (exec)
+ _edje_program_run(data->ed, pr, 0, data->signal, data->source);
+
if (_edje_block_break(data->ed))
{
#ifdef EDJE_PROGRAM_CACHE
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel