Hi everyone,
I couldn't get this to work, and by looking at the code it did not seem to
be implemented, so here's a patch that allows sending signals to a box's
items.
It's quite useful when you populate a box in edje through items{} and can't
access the evas_object directly or just want to do it in Edje.
This does not change the current behavior to get messages from the item
itself.
It's used that way :
emit => (signal = "boxname:idx:signal", source = "whatever")
where idx is an integer (starting at 0 of course).
The code is quite raw and may need a little reviewing/cleaning, but it seems
to work as far as I've tested.
Regards
Hugo Camboulive
diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c
index 4004ad3..72cbf08 100644
--- a/src/lib/edje_program.c
+++ b/src/lib/edje_program.c
@@ -1035,8 +1035,8 @@ _edje_emit(Edje *ed, const char *sig, const char *src)
for (i = 0; i < ed->table_parts_size; i++)
{
Edje_Real_Part *rp = ed->table_parts[i];
- if ((rp->part->type == EDJE_PART_TYPE_GROUP || rp->part->type == EDJE_PART_TYPE_EXTERNAL) &&
- (rp->swallowed_object) &&
+ if ((((rp->part->type == EDJE_PART_TYPE_GROUP || rp->part->type == EDJE_PART_TYPE_EXTERNAL) && (rp->swallowed_object))
+ || rp->part->type == EDJE_PART_TYPE_BOX) &&
(rp->part) && (rp->part->name) &&
(strcmp(rp->part->name, part) == 0))
{
@@ -1054,6 +1054,33 @@ _edje_emit(Edje *ed, const char *sig, const char *src)
_edje_external_signal_emit(rp->swallowed_object, newsig, src);
return;
}
+ else if (rp->part->type == EDJE_PART_TYPE_BOX)
+ {
+ const char *newsep = strchr(newsig, ':');
+ if (newsep)
+ {
+ size_t newlength = strlen(newsig) + 1;
+ char *newpart = alloca(newlength);
+ char *newnewsig;
+ int newpartid;
+ Evas_Object *child;
+ Eina_List *l;
+
+ memcpy(newpart, newsig, newlength);
+ newnewsig = newpart + (newsep - newsig);
+ *newnewsig = '\0';
+ newnewsig++;
+ newpartid = atoi(newpart);
+ if (!rp->object)
+ return;
+ l = evas_object_box_children_get(rp->object);
+ child = eina_list_nth(l, newpartid);
+ if (child)
+ _edje_emit(_edje_fetch(child), newnewsig, newpart);
+ eina_list_free(l);
+ return; /* return only if we found a colon */
+ }
+ }
}
}
}
------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel