emsg = (Edje_Message_Signal *)em->msg;
if (emsg->sig) eina_stringshare_del(emsg->sig);
if (emsg->src) eina_stringshare_del(emsg->src);
+ if (emsg->data && (--(emsg->data->ref) == 0))
+ {
+ if (emsg->data->free_func)
+ {
+ emsg->data->free_func(emsg->data->data);
+ }
+ free(emsg->data);
+ }
free(emsg);
}
break;
emsg3 = calloc(1, sizeof(Edje_Message_Signal));
if (emsg2->sig) emsg3->sig = eina_stringshare_add(emsg2->sig);
if (emsg2->src) emsg3->src = eina_stringshare_add(emsg2->src);
+ if (emsg2->data)
+ {
+ emsg3->data = emsg2->data;
+ emsg3->data->ref++;
+ }
msg = (unsigned char *)emsg3;
}
break;
{
_edje_emit_handle(em->edje,
((Edje_Message_Signal *)em->msg)->sig,
- ((Edje_Message_Signal *)em->msg)->src);
+ ((Edje_Message_Signal *)em->msg)->src,
+ ((Edje_Message_Signal *)em->msg)->data);
return;
}
/* if this has been queued up for the app then just call the callback */
typedef struct _Edje_Message_Signal Edje_Message_Signal;
typedef struct _Edje_Message Edje_Message;
+typedef struct _Edje_Message_Signal_Data Edje_Message_Signal_Data;
+struct _Edje_Message_Signal_Data
+{
+ int ref;
+ void *data;
+ void (*free_func)(void *);
+};
+
struct _Edje_Message_Signal
{
const char *sig;
const char *src;
+ Edje_Message_Signal_Data *data;
};
struct _Edje_Message
void _edje_programs_patterns_clean(Edje *ed);
void _edje_programs_patterns_init(Edje *ed);
void _edje_emit(Edje *ed, const char *sig, const char *src);
-void _edje_emit_handle(Edje *ed, const char *sig, const char *src);
+void _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *));
+void _edje_emit_handle(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data);
void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp);
void _edje_callbacks_patterns_clean(Edje *ed);
#include "edje_private.h"
-static void _edje_emit_cb(Edje *ed, const char *sig, const char *src);
+static void _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data);
static void _edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part *dst_part, const char *dst_param);
static void _edje_param_set(Edje_Real_Part *part, const char *param, const char *value);
void
_edje_emit(Edje *ed, const char *sig, const char *src)
{
+ _edje_emit_full(ed, sig, src, NULL, NULL);
+}
+
+/* data should either be NULL or a malloc allocated data */
+void
+_edje_emit_full(Edje *ed, const char *sig, const char *src, void *data,
+ void (*free_func)(void *))
+{
Edje_Message_Signal emsg;
Eina_List *l;
Evas_Object *obj;
end:
emsg.sig = sig;
emsg.src = src;
+ if (data)
+ {
+ emsg.data = calloc(1, sizeof(*(emsg.data)));
+ emsg.data->ref = 1;
+ emsg.data->data = data;
+ emsg.data->free_func = free_func;
+ }
+ else
+ {
+ emsg.data = NULL;
+ }
_edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
EINA_LIST_FOREACH(ed->subobjs, l, obj)
{
if (ed2->delete_me) continue;
_edje_message_send(ed2, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
}
+
+ if (emsg.data && (--(emsg.data->ref) == 0))
+ {
+ if (emsg.data->free_func)
+ {
+ emsg.data->free_func(emsg.data->data);
+ }
+ free(emsg.data);
+ }
}
struct _Edje_Program_Data
/* FIXME: what if we delete the evas object??? */
void
-_edje_emit_handle(Edje *ed, const char *sig, const char *src)
+_edje_emit_handle(Edje *ed, const char *sig, const char *src,
+ Edje_Message_Signal_Data *sdata)
{
if (ed->delete_me) return;
if (!sig) sig = "";
}
#endif
}
- _edje_emit_cb(ed, sig, src);
+ _edje_emit_cb(ed, sig, src, sdata);
if (_edje_block_break(ed))
{
goto break_prog;
_edje_unblock(ed);
}
+/* Extra data for callbacks */
+static void *callback_extra_data = NULL;
+
+EAPI void *
+edje_object_signal_callback_extra_data_get(void)
+{
+ return callback_extra_data;
+}
+
/* FIXME: what if we delete the evas object??? */
static void
-_edje_emit_cb(Edje *ed, const char *sig, const char *src)
+_edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data)
{
Eina_List *l;
const Eina_List *match;
const Eina_List *l2;
int r = 1;
+ callback_extra_data = (data) ? data->data : NULL;
_edje_callbacks_patterns_init(ed);
if (ed->patterns.callbacks.u.callbacks.globing)