summaryrefslogtreecommitdiff
path: root/src/edje_externals/elm.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-26 00:58:14 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-26 00:58:14 +0000
commit0fa8bd1b3d6180bfcecb9269041a0dd6efd9ca60 (patch)
tree0f8f1f743234397e5e8f12b70deaedf494825601 /src/edje_externals/elm.c
parent6ef61679ab19774d634867cc8f499393006e1841 (diff)
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using callbacks described with Evas_Smart_Cb_Description and set to Evas_Smart_Class or per-instance with evas_object_smart_callbacks_descriptions_set(). Right now elm_widget is not subclassable, so there is no way to define class signals, just instance signals. Just doing it for button, lots of widgets to do... If you can help, please follow the process: * see example at src/lib/elm_button.c, copy it. * read your widget documentation at Elementary.h * grep for evas_object_smart_callback_call(), see if they are all documented in Elementary.h, or if there are some missing. Fix Elementary.h * paste and change based on fixed Elementary.h My recommendation is to create "static const char []" variables and replace all evas_object_smart_callback_call() with that, to force sync. With callback descriptions pre-defined and using the same pointer with a custom variation evas_object_smart_callback_call_ptr() we may later optimize signal calling heavily, removing the requirement to call eina_stringshare_add()/eina_stringshare_del() and also not mixing all the callbacks in teh same list, instead having an array for defined signals, and a list from there. These optimizations are not in, but they are easily added later without breaking the API/ABI. SVN revision: 47461
Diffstat (limited to '')
-rw-r--r--src/edje_externals/elm.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/edje_externals/elm.c b/src/edje_externals/elm.c
index 2aa8c814e..520a4ddf7 100644
--- a/src/edje_externals/elm.c
+++ b/src/edje_externals/elm.c
@@ -15,6 +15,66 @@ external_translate(void *data __UNUSED__, const char *orig)
15 return orig; 15 return orig;
16} 16}
17 17
18typedef struct {
19 const char *emission;
20 const char *source;
21 Evas_Object *edje;
22} Elm_External_Signals_Proxy_Context;
23
24static void
25_external_signal_proxy_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
26{
27 Elm_External_Signals_Proxy_Context *ctxt = data;
28 free(ctxt);
29}
30
31static void
32_external_signal_proxy_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
33{
34 Elm_External_Signals_Proxy_Context *ctxt = data;
35 // TODO: Is it worth to check Evas_Smart_Cb_Description and do something
36 // TODO: with event_info given its description?
37 edje_object_signal_emit(ctxt->edje, ctxt->emission, ctxt->source);
38}
39
40void
41external_signals_proxy(Evas_Object *obj, Evas_Object *edje, const char *part_name)
42{
43 const Evas_Smart_Cb_Description **cls_descs, **inst_descs;
44 unsigned int cls_count, inst_count, total;
45 Elm_External_Signals_Proxy_Context *ctxt;
46
47 evas_object_smart_callbacks_descriptions_get
48 (obj, &cls_descs, &cls_count, &inst_descs, &inst_count);
49
50 total = cls_count + inst_count;
51 if (!total) return;
52 ctxt = malloc(sizeof(Elm_External_Signals_Proxy_Context) * total);
53 if (!ctxt) return;
54 evas_object_event_callback_add
55 (obj, EVAS_CALLBACK_DEL, _external_signal_proxy_free_cb, ctxt);
56
57 for (; cls_count > 0; cls_count--, cls_descs++, ctxt++)
58 {
59 const Evas_Smart_Cb_Description *d = *cls_descs;
60 ctxt->emission = d->name;
61 ctxt->source = part_name;
62 ctxt->edje = edje;
63 evas_object_smart_callback_add
64 (obj, d->name, _external_signal_proxy_cb, ctxt);
65 }
66
67 for (; inst_count > 0; inst_count--, inst_descs++, ctxt++)
68 {
69 const Evas_Smart_Cb_Description *d = *inst_descs;
70 ctxt->emission = d->name;
71 ctxt->source = part_name;
72 ctxt->edje = edje;
73 evas_object_smart_callback_add
74 (obj, d->name, _external_signal_proxy_cb, ctxt);
75 }
76}
77
18void * 78void *
19external_common_params_parse_internal(size_t params_size, void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) 79external_common_params_parse_internal(size_t params_size, void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
20{ 80{