* edje: Change filter_state to filter and give the possibility to
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 19 Feb 2010 18:30:46 +0000 (18:30 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 19 Feb 2010 18:30:46 +0000 (18:30 +0000)
filter from another part than the event source.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@46316 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_cc_handlers.c
src/lib/edje_data.c
src/lib/edje_edit.c
src/lib/edje_load.c
src/lib/edje_private.h
src/lib/edje_program.c

index 59680ad..b7db137 100644 (file)
@@ -223,7 +223,7 @@ static void st_collections_group_programs_program_name(void);
 static void st_collections_group_parts_part_description_params_string(void);
 static void st_collections_group_programs_program_signal(void);
 static void st_collections_group_programs_program_source(void);
-static void st_collections_group_programs_program_filter_state(void);
+static void st_collections_group_programs_program_filter(void);
 static void st_collections_group_programs_program_in(void);
 static void st_collections_group_programs_program_action(void);
 static void st_collections_group_programs_program_transition(void);
@@ -508,7 +508,7 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.parts.program.name", st_collections_group_programs_program_name}, /* dup */
      {"collections.group.parts.program.signal", st_collections_group_programs_program_signal}, /* dup */
      {"collections.group.parts.program.source", st_collections_group_programs_program_source}, /* dup */
-     {"collections.group.parts.program.filter_state", st_collections_group_programs_program_filter_state}, /* dup */
+     {"collections.group.parts.program.filter", st_collections_group_programs_program_filter}, /* dup */
      {"collections.group.parts.program.in", st_collections_group_programs_program_in}, /* dup */
      {"collections.group.parts.program.action", st_collections_group_programs_program_action}, /* dup */
      {"collections.group.parts.program.transition", st_collections_group_programs_program_transition}, /* dup */
@@ -518,7 +518,7 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.program.name", st_collections_group_programs_program_name}, /* dup */
      {"collections.group.program.signal", st_collections_group_programs_program_signal}, /* dup */
      {"collections.group.program.source", st_collections_group_programs_program_source}, /* dup */
-     {"collections.group.program.filter_state", st_collections_group_programs_program_filter_state}, /* dup */
+     {"collections.group.program.filter", st_collections_group_programs_program_filter}, /* dup */
      {"collections.group.program.in", st_collections_group_programs_program_in}, /* dup */
      {"collections.group.program.action", st_collections_group_programs_program_action}, /* dup */
      {"collections.group.program.transition", st_collections_group_programs_program_transition}, /* dup */
@@ -528,7 +528,7 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.programs.program.name", st_collections_group_programs_program_name},
      {"collections.group.programs.program.signal", st_collections_group_programs_program_signal},
      {"collections.group.programs.program.source", st_collections_group_programs_program_source},
-     {"collections.group.programs.program.filter_state", st_collections_group_programs_program_filter_state}, /* dup */
+     {"collections.group.programs.program.filter", st_collections_group_programs_program_filter}, /* dup */
      {"collections.group.programs.program.in", st_collections_group_programs_program_in},
      {"collections.group.programs.program.action", st_collections_group_programs_program_action},
      {"collections.group.programs.program.transition", st_collections_group_programs_program_transition},
@@ -5956,7 +5956,7 @@ st_collections_group_parts_part_description_params_string(void)
                      name: "programname";
                      signal: "signalname";
                      source: "partname";
-                     filter_state: "statename";
+                     filter: "partname" "statename";
                      in: 0.3 0.0;
                      action: STATE_SET "statename" state_value;
                      transition: LINEAR 0.5;
@@ -6080,27 +6080,32 @@ st_collections_group_programs_program_source(void)
 /**
     @page edcref
     @property
-        filter_state
+        filter
     @parameters
-        [filter_state name]
+        [filter part state]
     @effect
-        State of the source part that should accept signal. Only one source state
-        keyword per program may be used. ex:state: "default"; (Signals from
-        a part currently in state named "default" are accepted).
+        The part [part] should be in state [state] for the signal to be accepted. Only one source state
+        keyword per program may be used. ex:state: "button" "default"; (Signals are accepted
+        if part button is currently in state named "default").
     @endproperty
 */
 static void
-st_collections_group_programs_program_filter_state(void)
+st_collections_group_programs_program_filter(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->filter_state = parse_str(0);
+   if(is_param(1)) {
+          ep->filter.part = parse_str(0);
+          ep->filter.state = parse_str(1);
+   } else {
+          ep->filter.state = parse_str(0);
+   }
 }
 
 /**
index 678771d..8ed33ad 100644 (file)
@@ -215,7 +215,8 @@ _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, "filter_state", filter_state, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_part", filter.part, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_state", filter.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);
index 6ebae36..66f510c 100644 (file)
@@ -4940,7 +4940,8 @@ edje_edit_program_add(Evas_Object *obj, const char *name)
    epr->name = eina_stringshare_add(name);
    epr->signal = NULL;
    epr->source = NULL;
-   epr->filter_state = NULL;
+   epr->filter.part = NULL;
+   epr->filter.state = NULL;
    epr->in.from = 0.0;
    epr->in.range = 0.0;
    epr->action = 0;
@@ -4989,7 +4990,8 @@ 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->filter_state);
+   _edje_if_string_free(ed, epr->filter.part);
+   _edje_if_string_free(ed, epr->filter.state);
    _edje_if_string_free(ed, epr->state);
    _edje_if_string_free(ed, epr->state2);
 
@@ -5156,13 +5158,35 @@ edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *sou
 }
 
 EAPI const char *
+edje_edit_program_filter_part_get(Evas_Object *obj, const char *prog)
+{
+   GET_EPR_OR_RETURN(NULL);
+
+   if (!epr->filter.part) return NULL;
+   return eina_stringshare_add(epr->filter.part);
+}
+
+EAPI Eina_Bool
+edje_edit_program_filter_part_set(Evas_Object *obj, const char *prog, const char *filter_part)
+{
+   GET_ED_OR_RETURN(0);
+   GET_EPR_OR_RETURN(0);
+
+   if (!filter_part) return 0;
+
+   _edje_if_string_free(ed, epr->filter.part);
+   epr->filter.part = eina_stringshare_add(filter_part);
+
+   return 1;
+}
+
+EAPI const char *
 edje_edit_program_filter_state_get(Evas_Object *obj, const char *prog)
 {
    GET_EPR_OR_RETURN(NULL);
 
-   if (!epr->filter_state) return NULL;
-   //printf("GET SOURCE for program: %s [%s]\n", prog, epr->source_state);
-   return eina_stringshare_add(epr->filter_state);
+   if (!epr->filter.state) return NULL;
+   return eina_stringshare_add(epr->filter.state);
 }
 
 EAPI Eina_Bool
@@ -5173,10 +5197,8 @@ edje_edit_program_filter_state_set(Evas_Object *obj, const char *prog, const cha
 
    if (!filter_state) return 0;
 
-   //printf("SET SOURCE for program: %s [%s]\n", prog, source);
-
-   _edje_if_string_free(ed, epr->filter_state);
-   epr->filter_state = eina_stringshare_add(filter_state);
+   _edje_if_string_free(ed, epr->filter.state);
+   epr->filter.state = eina_stringshare_add(filter_state);
 
    return 1;
 }
index 6daff50..dd4ae57 100644 (file)
@@ -1102,7 +1102,8 @@ _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->filter_state) eina_stringshare_del(pr->filter_state);
+             if (pr->filter.part) eina_stringshare_del(pr->filter.part);
+             if (pr->filter.state) eina_stringshare_del(pr->filter.state);
              if (pr->state) eina_stringshare_del(pr->state);
              if (pr->state2) eina_stringshare_del(pr->state2);
           }
index 6852574..ebdeab9 100644 (file)
@@ -404,7 +404,11 @@ 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 *filter_state; /* if part state that emitted this (name) matches this */
+
+   struct {
+      const char *part;
+      const char *state; /* if state is not set, we will try with source */
+   } filter; /* the part filter.part should be in state filter.state for signal to be accepted */
 
    struct {
       double   from;
index f3d0bde..db96885 100644 (file)
@@ -1023,16 +1023,16 @@ static int _edje_glob_callback(Edje_Program *pr, void *dt)
    data->matched++;
 #endif
 
-   if (pr->filter_state)
-   {
-     rp = _edje_real_part_get(data->ed, data->source);
-     if (rp)
-       exec = (rp->chosen_description->state.name == pr->filter_state);
-   }
+   if (pr->filter.state)
+     {
+       rp = _edje_real_part_get(data->ed, pr->filter.part ? pr->filter.part : data->source);
+       if (rp)
+         exec = (rp->chosen_description->state.name == pr->filter.state);
+     }
 
    if (exec)
      _edje_program_run(data->ed, pr, 0, data->signal, data->source);
+
    if (_edje_block_break(data->ed))
      {
 #ifdef EDJE_PROGRAM_CACHE