Allow sending signals to GROUP sub-parts.

Today signals emitted inside GROUP sub-parts are delivered to parent
group as "part-name:original-source". This is good and allow edje
groups to be reused. But no counter part to send events to inside
sub-groups existed.

This patch allows one to send a signal "signal" to inside a part
"part" that is of type GROUP by prepending signal emission with part name:

    emission: "part:signal"
    source: "source"

this is the same as:

   o = edje_object_part_swallow_get(ed);
   edje_object_signal_emit(o, "signal", "source");

but can be done all in themes, no need to go to application c/c++/python.

Based on patch by Pieter, see mail list.


SVN revision: 40489
This commit is contained in:
Gustavo Sverzut Barbieri 2009-05-02 20:05:53 +00:00
parent 4fd5d0c794
commit 022204e09c
1 changed files with 37 additions and 1 deletions

View File

@ -2,6 +2,7 @@
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#define _GNU_SOURCE
#include <string.h>
#include "edje_private.h"
@ -814,8 +815,43 @@ _edje_emit(Edje *ed, const char *sig, const char *src)
Edje_Message_Signal emsg;
Eina_List *l;
Evas_Object *obj;
const char *sep;
if (ed->delete_me) return;
sep = strchr(sig, ':');
if (sep)
{
/* the signal contains a colon, split the signal into "group:signal",
* and deliver it to "group"
*/
char *part = strdupa(sig);
if (part)
{
char *newsig = part + (sep - sig);
int i;
*newsig = '\0';
newsig++;
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->swallowed_object) &&
(rp->part) && (rp->part->name) &&
(strcmp(rp->part->name, part) == 0))
{
Edje *ed2 = _edje_fetch(rp->swallowed_object);
if (ed2) _edje_emit(ed2, newsig, src);
return; /* stop processing.
* XXX maybe let signal be processed anyway?
* XXX in this case, just comment this line
*/
}
}
}
}
emsg.sig = sig;
emsg.src = src;
_edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);