summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-08-03 17:23:21 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-04 11:52:16 +0900
commitefac7d523ac4be16e1d81541a887dd847c7d9d2c (patch)
tree7518db1c5d1d3fa5cb6c7af9e514256a7979d687 /src/lib/edje
parentad7e16bcf4af199645da45989e866cb50ced6344 (diff)
edje: Move signal APIs to an interface
This interface will be used by elm_layout as well. Ref T5315
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/Edje_Common.h3
-rw-r--r--src/lib/edje/Edje_Eo.h1
-rw-r--r--src/lib/edje/Edje_Legacy.h58
-rw-r--r--src/lib/edje/edje_legacy.c66
-rw-r--r--src/lib/edje/edje_message_queue.c13
-rw-r--r--src/lib/edje/edje_object.eo156
-rw-r--r--src/lib/edje/edje_private.h14
-rw-r--r--src/lib/edje/edje_program.c97
-rw-r--r--src/lib/edje/edje_signal.c41
-rw-r--r--src/lib/edje/edje_smart.c1
-rw-r--r--src/lib/edje/efl_canvas_layout_signal.eo146
11 files changed, 338 insertions, 258 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index 31b38c7882..cbc40f0e1e 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -89,7 +89,8 @@ struct _Edje_Size_Class
89 * @{ 89 * @{
90 */ 90 */
91 91
92typedef void (*Edje_Signal_Cb) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Edje signal callback functions's prototype definition. @c data will have the auxiliary data pointer set at the time the callback registration. @c obj will be a pointer the Edje object where the signal comes from. @c emission will identify the exact signal's emission string and @c source the exact signal's source one. */ 92typedef void (*Efl_Signal_Cb) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Edje signal callback functions's prototype definition. @c data will have the auxiliary data pointer set at the time the callback registration. @c obj will be a pointer the Edje object where the signal comes from. @c emission will identify the exact signal's emission string and @c source the exact signal's source one. */
93typedef Efl_Signal_Cb Edje_Signal_Cb;
93 94
94/** 95/**
95 * @brief Gets extra data passed to callbacks. 96 * @brief Gets extra data passed to callbacks.
diff --git a/src/lib/edje/Edje_Eo.h b/src/lib/edje/Edje_Eo.h
index 44dd896db0..e59610b2bc 100644
--- a/src/lib/edje/Edje_Eo.h
+++ b/src/lib/edje/Edje_Eo.h
@@ -1,6 +1,7 @@
1#include <Efl.h> 1#include <Efl.h>
2 2
3#include "efl_canvas_layout_calc.eo.h" 3#include "efl_canvas_layout_calc.eo.h"
4#include "efl_canvas_layout_signal.eo.h"
4#include "edje_object.eo.h" 5#include "edje_object.eo.h"
5#include "edje_edit.eo.h" 6#include "edje_edit.eo.h"
6 7
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index 2adee590bf..0ffbc28135 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -52,6 +52,64 @@
52EAPI Evas_Object *edje_object_add (Evas *evas); 52EAPI Evas_Object *edje_object_add (Evas *evas);
53 53
54/** 54/**
55 * @brief Adds a callback for an arriving Edje signal, emitted by a given Edje
56 * object.
57 *
58 * Edje signals are one of the communication interfaces between code and a
59 * given Edje object's theme. With signals, one can communicate two string
60 * values at a time, which are: - "emission" value: the name of the signal, in
61 * general - "source" value: a name for the signal's context, in general
62 *
63 * Though there are those common uses for the two strings, one is free to use
64 * them however they like.
65 *
66 * Signal callback registration is powerful, in the way that blobs may be used
67 * to match multiple signals at once. All the "*?[\" set of @c fnmatch()
68 * operators can be used, both for emission and source.
69 *
70 * Edje has internal signals it will emit, automatically, on various actions
71 * taking place on group parts. For example, the mouse cursor being moved,
72 * pressed, released, etc., over a given part's area, all generate individual
73 * signals.
74 *
75 * By using something like edje_object_signal_callback_add(obj, "mouse,down,*",
76 * "button.*", signal_cb, NULL); being @ref "button.*" the pattern for the
77 * names of parts implementing buttons on an interface, you'd be registering
78 * for notifications on events of mouse buttons being pressed down on either of
79 * those parts (those events all have the @"mouse,down," common prefix on their
80 * names, with a suffix giving the button number). The actual emission and
81 * source strings of an event will be passed in as the emission and source
82 * parameters of the callback function (e.g. "mouse,down,2" and
83 * @"button.close"), for each of those events.
84 *
85 * @note See @ref edcref "the syntax" for EDC files See also
86 * @ref edje_object_signal_emit() on how to emits Edje signals from code to a
87 * an object @ref edje_object_signal_callback_del_full()
88 *
89 * @param[in] emission The signal's "emission" string
90 * @param[in] source The signal's "source" string
91 * @param[in] func The callback function to be executed when the signal is
92 * emitted.
93 * @param[in] data A pointer to data to pass in to func.
94 */
95EAPI void edje_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
96
97/**
98 * @brief Sends/emits an Edje signal to a given Edje object
99 *
100 * This function sends a signal to the object obj. An Edje program, at obj's
101 * EDC specification level, can respond to a signal by having declared matching
102 * @'signal' and @'source' fields on its block (see @ref edcref "the syntax"
103 * for EDC files).
104 *
105 * See also @ref edje_object_signal_callback_add() for more on Edje signals.
106 *
107 * @param[in] emission The signal's "emission" string
108 * @param[in] source The signal's "source" string
109 */
110EAPI void edje_object_signal_emit(Evas_Object *obj, const char *emission, const char *source);
111
112/**
55 * @brief Removes a signal-triggered callback from an object. 113 * @brief Removes a signal-triggered callback from an object.
56 * 114 *
57 * @param obj A valid Evas_Object handle. 115 * @param obj A valid Evas_Object handle.
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index f41f2f681e..a917903f32 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -51,14 +51,76 @@ edje_object_part_state_get(const Edje_Object *obj, const char * part, double *va
51EAPI void 51EAPI void
52edje_object_message_signal_process(Edje_Object *obj) 52edje_object_message_signal_process(Edje_Object *obj)
53{ 53{
54 edje_obj_message_signal_process(obj, EINA_FALSE); 54 efl_canvas_layout_signal_process(obj, EINA_FALSE);
55} 55}
56 56
57/* since 1.20 */ 57/* since 1.20 */
58EAPI void 58EAPI void
59edje_object_message_signal_recursive_process(Edje_Object *obj) 59edje_object_message_signal_recursive_process(Edje_Object *obj)
60{ 60{
61 edje_obj_message_signal_process(obj, EINA_TRUE); 61 efl_canvas_layout_signal_process(obj, EINA_TRUE);
62}
63
64EAPI void
65edje_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
66{
67 efl_canvas_layout_signal_callback_add(obj, emission, source, (Efl_Signal_Cb) func, data);
68}
69
70EAPI void *
71edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
72{
73 Edje_Signal_Callback_Group *gp;
74 Edje *ed = _edje_fetch(obj);
75 Eina_Bool ok;
76
77 if (!ed || ed->delete_me) return NULL;
78
79 gp = (Edje_Signal_Callback_Group *) ed->callbacks;
80 if (!gp) return NULL;
81
82 emission = eina_stringshare_add(emission);
83 source = eina_stringshare_add(source);
84
85 ok = _edje_signal_callback_disable(gp, emission, source, func, data);
86
87 // Legacy only
88 if (!ok && !data)
89 {
90 for (unsigned i = 0; i < gp->matches->matches_count; ++i)
91 {
92 if (emission == gp->matches->matches[i].signal &&
93 source == gp->matches->matches[i].source &&
94 func == gp->matches->matches[i].func &&
95 !gp->flags[i].delete_me)
96 {
97 gp->flags[i].delete_me = EINA_TRUE;
98 //return gp->custom_data[i];
99 break;
100 }
101 }
102 }
103
104 eina_stringshare_del(emission);
105 eina_stringshare_del(source);
106
107 // Note: This function seems to have returned NULL since ~2013, despite
108 // what the documentation says.
109 return NULL;
110}
111
112EAPI void *
113edje_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func)
114{
115 // Legacy del_full seems to have been sloppy with NULL data, as that would
116 // match the first callback found. Keeping this legacy behaviour unchanged.
117 return edje_object_signal_callback_del_full(obj, emission, source, func, NULL);
118}
119
120EAPI void
121edje_object_signal_emit(Evas_Object *obj, const char *emission, const char *source)
122{
123 efl_canvas_layout_signal_emit(obj, emission, source);
62} 124}
63 125
64EAPI Eina_Bool 126EAPI Eina_Bool
diff --git a/src/lib/edje/edje_message_queue.c b/src/lib/edje/edje_message_queue.c
index 37e937d194..4e132154ec 100644
--- a/src/lib/edje/edje_message_queue.c
+++ b/src/lib/edje/edje_message_queue.c
@@ -32,7 +32,7 @@ _edje_object_message_propagate_send(Evas_Object *obj, Edje_Message_Type type, in
32} 32}
33 33
34EOLIAN void 34EOLIAN void
35_edje_object_message_send(Eo *obj, Edje *pd EINA_UNUSED, int id, const Eina_Value val) 35_edje_object_efl_canvas_layout_signal_message_send(Eo *obj, Edje *pd EINA_UNUSED, int id, const Eina_Value val)
36{ 36{
37 const Eina_Value_Type *valtype; 37 const Eina_Value_Type *valtype;
38 Edje_Message_Type msgtype; 38 Edje_Message_Type msgtype;
@@ -228,22 +228,17 @@ end:
228} 228}
229 229
230EOLIAN void 230EOLIAN void
231_edje_object_message_signal_process(Eo *obj, Edje *ed, Eina_Bool recurse) 231_edje_object_efl_canvas_layout_signal_signal_process(Eo *obj, Edje *ed, Eina_Bool recurse)
232{ 232{
233 Edje *sub_ed;
234 Eina_List *l; 233 Eina_List *l;
235 Evas_Object *o; 234 Evas_Object *o;
236 235
236 if (ed->delete_me) return;
237 _edje_object_message_signal_process_do(obj, ed); 237 _edje_object_message_signal_process_do(obj, ed);
238 if (!recurse) return; 238 if (!recurse) return;
239 239
240 EINA_LIST_FOREACH(ed->subobjs, l, o) 240 EINA_LIST_FOREACH(ed->subobjs, l, o)
241 { 241 efl_canvas_layout_signal_process(o, EINA_TRUE);
242 sub_ed = _edje_fetch(o);
243 if (!sub_ed) continue;
244
245 _edje_object_message_signal_process(o, sub_ed, EINA_TRUE);
246 }
247} 242}
248 243
249static Eina_Bool 244static Eina_Bool
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 5aacfa15a8..6f403ba0fe 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -3,7 +3,8 @@ import edje_types;
3// FIXME: This EO doc needs a direct link to the "edcref" doc 3// FIXME: This EO doc needs a direct link to the "edcref" doc
4 4
5class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, 5class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
6 Efl.Observer, Efl.Ui.Base, Efl.Canvas.Layout_Calc) 6 Efl.Observer, Efl.Ui.Base, Efl.Canvas.Layout_Calc,
7 Efl.Canvas.Layout_Signal)
7{ 8{
8 [[Edje object class]] 9 [[Edje object class]]
9 legacy_prefix: edje_object; 10 legacy_prefix: edje_object;
@@ -238,154 +239,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
238 } 239 }
239 /* EDJE GROUP DATA APIS END ------------------------------------------ */ 240 /* EDJE GROUP DATA APIS END ------------------------------------------ */
240 241
241 /* MESSAGE & SIGNAL APIS BEGIN --------------------------------------- */
242 message_send {
243 [[Sends an (Edje) message to a given Edje object
244
245 This function sends an Edje message to obj and to all of its
246 child objects, if it has any (swallowed objects are one kind of
247 child object). Only a few types are supported:
248 - int,
249 - float/double,
250 - string/stringshare,
251 - arrays of int, float, double or strings.
252
253 The id argument as a form of code and theme defining a common
254 interface on message communication. One should define the same IDs
255 on both code and EDC declaration, to individualize messages
256 (binding them to a given context).
257 ]]
258 params {
259 @in id: int; [[A identification number for the message to be sent]]
260 @in msg: const(generic_value); [[The message's payload]]
261 }
262 legacy: null;
263 }
264 signal_callback_add {
265 [[Adds a callback for an arriving Edje signal, emitted by
266 a given Edje object.
267
268 Edje signals are one of the communication interfaces between
269 code and a given Edje object's theme. With signals, one can
270 communicate two string values at a time, which are:
271 - "emission" value: the name of the signal, in general
272 - "source" value: a name for the signal's context, in general
273
274 Though there are those common uses for the two strings, one is free
275 to use them however they like.
276
277 Signal callback registration is powerful, in the way that blobs
278 may be used to match multiple signals at once. All the
279 "*?[\" set of $fnmatch() operators can be used, both for
280 emission and source.
281
282 Edje has internal signals it will emit, automatically, on
283 various actions taking place on group parts. For example, the mouse
284 cursor being moved, pressed, released, etc., over a given part's
285 area, all generate individual signals.
286
287 By using something like
288 edje_object_signal_callback_add(obj, "mouse,down,*", "button.*",
289 signal_cb, NULL);
290 being \@ref "button.*" the pattern for the names of parts implementing
291 buttons on an interface, you'd be registering for notifications on
292 events of mouse buttons being pressed down on either of those parts
293 (those events all have the @"mouse,down," common prefix on their
294 names, with a suffix giving the button number). The actual emission
295 and source strings of an event will be passed in as the emission
296 and source parameters of the callback function (e.g.
297 "mouse,down,2" and @"button.close"), for each of those events.
298
299 Note: See \@ref edcref "the syntax" for EDC files
300 See also @.signal_emit() on how to emits Edje signals from
301 code to a an object
302 \@ref edje_object_signal_callback_del_full()]]
303 /* FIXME-doc
304 * This function adds a callback function to a signal emitted by obj, to
305 * be issued every time an EDC program like the following
306 * @code
307 * program
308 * {
309 * name: "emit_example";
310 * action: SIGNAL_EMIT "a_signal" "a_source";
311 * }
312 * @endcode
313 * is run, if emission and source are given those same values,
314 * here.
315 */
316
317 params {
318 @in emission: string; [[The signal's "emission" string]]
319 @in source: string; [[The signal's "source" string]]
320 @in func: Edje.Signal_Cb; [[The callback function to be executed when the signal is
321 emitted.]]
322 @in data: void_ptr; [[A pointer to data to pass in to func.]]
323 }
324 }
325 signal_callback_del {
326 [[Removes a signal-triggered callback from an object.
327
328 This function removes a callback, previously attached to the
329 emission of a signal, from the object obj. The parameters
330 emission, source and func must match exactly those passed to
331 a previous call to edje_object_signal_callback_add(). The data
332 pointer that was passed to this call will be returned.
333
334 See also @.signal_callback_add().
335 \@ref edje_object_signal_callback_del_full().]]
336
337 legacy: null;
338 return: void_ptr; [[The data pointer]]
339 params {
340 @in emission: string; [[The emission string.]]
341 @in source: string; [[The source string.]]
342 @in func: Edje.Signal_Cb; [[The callback function.]]
343 @in data: void_ptr; [[The callback function.]]
344 }
345 }
346 signal_emit {
347 [[Sends/emits an Edje signal to a given Edje object
348
349 This function sends a signal to the object obj. An Edje program,
350 at obj's EDC specification level, can respond to a signal by
351 having declared matching @'signal' and @'source' fields on its
352 block (see \@ref edcref "the syntax" for EDC files).
353
354 See also @.signal_callback_add() for more on Edje signals.]]
355 /* FIXME-doc
356 * @code
357 * program
358 * {
359 * name: "a_program";
360 * signal: "a_signal";
361 * source: "";
362 * action: ...
363 * }
364 * @endcode
365 */
366 params {
367 @in emission: string; [[The signal's "emission" string]]
368 @in source: string; [[The signal's "source" string]]
369 }
370 }
371 message_signal_process {
372 [[Processes an object's message queue.
373
374 This function goes through the object message queue processing the
375 pending messages for this specific Edje object. Normally they'd
376 be processed only at idle time.
377
378 If $recurse is $true, this function will be called recursively
379 on all subobjects.
380 ]]
381 params {
382 recurse: bool @optional; [[Whether to process messages on children
383 objects.]]
384 }
385 legacy: null;
386 }
387 /* MESSAGE & SIGNAL APIS END ----------------------------------------- */
388
389 /* CLASS APIS BEGIN -------------------------------------------------- */ 242 /* CLASS APIS BEGIN -------------------------------------------------- */
390 @property global_color_class @class { 243 @property global_color_class @class {
391 set { 244 set {
@@ -1060,6 +913,11 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
1060 Efl.Canvas.Layout_Calc.calc_freeze; 913 Efl.Canvas.Layout_Calc.calc_freeze;
1061 Efl.Canvas.Layout_Calc.calc_thaw; 914 Efl.Canvas.Layout_Calc.calc_thaw;
1062 Efl.Canvas.Layout_Calc.calc_force; 915 Efl.Canvas.Layout_Calc.calc_force;
916 Efl.Canvas.Layout_Signal.message_send;
917 Efl.Canvas.Layout_Signal.signal_callback_add;
918 Efl.Canvas.Layout_Signal.signal_callback_del;
919 Efl.Canvas.Layout_Signal.signal_emit;
920 Efl.Canvas.Layout_Signal.signal_process;
1063 Efl.Ui.Base.mirrored { set; get; } 921 Efl.Ui.Base.mirrored { set; get; }
1064 Efl.Ui.Base.language { set; get; } 922 Efl.Ui.Base.language { set; get; }
1065 Efl.Ui.Base.scale { set; get; } 923 Efl.Ui.Base.scale { set; get; }
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 26b85ee19f..139272066e 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -2469,13 +2469,13 @@ void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed);
2469 2469
2470const Edje_Signal_Callback_Group *_edje_signal_callback_alloc(void); 2470const Edje_Signal_Callback_Group *_edje_signal_callback_alloc(void);
2471void _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp); 2471void _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp);
2472void _edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp, 2472Eina_Bool _edje_signal_callback_push(Edje_Signal_Callback_Group *cgp,
2473 const char *signal, const char *source, 2473 const char *signal, const char *source,
2474 Edje_Signal_Cb func, void *data, 2474 Edje_Signal_Cb func, void *data,
2475 Eina_Bool propagate); 2475 Eina_Bool propagate);
2476void *_edje_signal_callback_disable(const Edje_Signal_Callback_Group *cgp, 2476Eina_Bool _edje_signal_callback_disable(Edje_Signal_Callback_Group *cgp,
2477 const char *signal, const char *source, 2477 const char *signal, const char *source,
2478 Edje_Signal_Cb func, void *data); 2478 Edje_Signal_Cb func, void *data);
2479 2479
2480EAPI void _edje_edd_init(void); 2480EAPI void _edje_edd_init(void);
2481EAPI void _edje_edd_shutdown(void); 2481EAPI void _edje_edd_shutdown(void);
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index 28b9300ccf..8aeb63e9ab 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -226,102 +226,75 @@ _edje_object_transition_duration_factor_get(Eo *obj EINA_UNUSED, Edje *pd)
226 return pd->duration_scale; 226 return pd->duration_scale;
227} 227}
228 228
229void 229static inline Eina_Bool
230edje_object_propagate_callback_add(Evas_Object *obj, void (*func)(void *data, Evas_Object *o, const char *emission, const char *source), void *data) 230_edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data)
231{ 231{
232 Edje_Signal_Callback_Group *gp;
232 const char *sig; 233 const char *sig;
233 const char *src; 234 const char *src;
234 Edje *ed; 235 Eina_Bool ok;
235
236 ed = _edje_fetch(obj);
237 if (!ed) return;
238 if (ed->delete_me) return;
239 236
240 if (!ed->callbacks) 237 if (!ed->callbacks)
241 ed->callbacks = _edje_signal_callback_alloc(); 238 ed->callbacks = _edje_signal_callback_alloc();
242 if (!ed->callbacks) return; 239 if (!ed->callbacks) return EINA_FALSE;
243 240
244 sig = eina_stringshare_add("*"); 241 sig = eina_stringshare_add(emission);
245 src = eina_stringshare_add("*"); 242 src = eina_stringshare_add(source);
246 243
247 if (ed->callbacks) 244 gp = (Edje_Signal_Callback_Group *) ed->callbacks;
248 _edje_signal_callback_push(ed->callbacks, 245 ok = _edje_signal_callback_push(gp, sig, src, func, data, EINA_TRUE);
249 sig, src,
250 func, data,
251 EINA_TRUE);
252 246
253 eina_stringshare_del(sig); 247 eina_stringshare_del(sig);
254 eina_stringshare_del(src); 248 eina_stringshare_del(src);
249
250 return ok;
255} 251}
256 252
257EOLIAN void 253void
258_edje_object_signal_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Edje_Signal_Cb func, void *data) 254edje_object_propagate_callback_add(Evas_Object *obj, Efl_Signal_Cb func, void *data)
259{ 255{
260 if ((!emission) || (!source) || (!func)) return; 256 Edje *ed;
261
262 if (!ed) return;
263 if (ed->delete_me) return;
264
265 emission = eina_stringshare_add(emission);
266 source = eina_stringshare_add(source);
267
268 if (!ed->callbacks)
269 ed->callbacks = _edje_signal_callback_alloc();
270 if (!ed->callbacks) return;
271
272 _edje_signal_callback_push(ed->callbacks,
273 emission, source,
274 func, data, EINA_FALSE);
275 257
276 eina_stringshare_del(emission); 258 ed = _edje_fetch(obj);
277 eina_stringshare_del(source); 259 if (!ed || ed->delete_me) return;
260 _edje_object_signal_callback_add(ed, "*", "*", func, data);
278} 261}
279 262
280EAPI void * 263EOLIAN Eina_Bool
281edje_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, void (*func)(void *data, Evas_Object *o, const char *emission, const char *source)) 264_edje_object_efl_canvas_layout_signal_signal_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data)
282{ 265{
283 if (!obj) return NULL; 266 return _edje_object_signal_callback_add(ed, emission, source, func, data);
284 void *ret = NULL;
285 ret = edje_obj_signal_callback_del(obj, emission, source, (Edje_Signal_Cb)func, NULL);
286 return ret;
287} 267}
288 268
289EOLIAN void * 269EOLIAN Eina_Bool
290_edje_object_signal_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Edje_Signal_Cb func, void *data) 270_edje_object_efl_canvas_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data)
291{ 271{
292 if ((!emission) || (!source) || (!func)) return NULL; 272 Edje_Signal_Callback_Group *gp;
293 if (!ed) return NULL; 273 Eina_Bool ok;
294 if (ed->delete_me) return NULL; 274
275 if (ed->delete_me) return EINA_FALSE;
276 if ((!emission) || (!source) || (!func)) return EINA_FALSE;
277
278 gp = (Edje_Signal_Callback_Group *) ed->callbacks;
279 if (!gp) return EINA_FALSE;
295 280
296 emission = eina_stringshare_add(emission); 281 emission = eina_stringshare_add(emission);
297 source = eina_stringshare_add(source); 282 source = eina_stringshare_add(source);
298 283
299 _edje_signal_callback_disable(ed->callbacks, 284 ok = _edje_signal_callback_disable(gp, emission, source, func, data);
300 emission, source,
301 func, data);
302 285
303 eina_stringshare_del(emission); 286 eina_stringshare_del(emission);
304 eina_stringshare_del(source); 287 eina_stringshare_del(source);
305 288
306 return NULL; 289 return ok;
307}
308
309EAPI void *
310edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
311{
312 if (!obj) return NULL;
313 void *ret = NULL;
314 ret = edje_obj_signal_callback_del(obj, emission, source, func, data);
315 return ret;
316} 290}
317 291
318EOLIAN void 292EOLIAN void
319_edje_object_signal_emit(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source) 293_edje_object_efl_canvas_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Edje *ed, const char *emission, const char *source)
320{ 294{
321 if ((!emission) || (!source)) return;
322 if (!ed) return;
323 if (ed->delete_me) return; 295 if (ed->delete_me) return;
324 _edje_emit(ed, (char *)emission, (char *)source); 296 if ((!emission) || (!source)) return;
297 _edje_emit(ed, emission, source);
325} 298}
326 299
327/* FIXDOC: Verify/Expand */ 300/* FIXDOC: Verify/Expand */
diff --git a/src/lib/edje/edje_signal.c b/src/lib/edje/edje_signal.c
index 0e381c17a6..2f4bab3bd6 100644
--- a/src/lib/edje/edje_signal.c
+++ b/src/lib/edje/edje_signal.c
@@ -169,12 +169,11 @@ _edje_signal_callback_grow(Edje_Signal_Callback_Group *gp)
169 return gp; 169 return gp;
170} 170}
171 171
172void 172Eina_Bool
173_edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp, 173_edje_signal_callback_push(Edje_Signal_Callback_Group *gp,
174 const char *sig, const char *src, 174 const char *sig, const char *src,
175 Edje_Signal_Cb func, void *data, Eina_Bool propagate) 175 Edje_Signal_Cb func, void *data, Eina_Bool propagate)
176{ 176{
177 Edje_Signal_Callback_Group *gp = (Edje_Signal_Callback_Group *)cgp;
178 unsigned int i; 177 unsigned int i;
179 Edje_Signal_Callback_Flags flags; 178 Edje_Signal_Callback_Flags flags;
180 Edje_Signal_Callback_Matches *tmp; 179 Edje_Signal_Callback_Matches *tmp;
@@ -195,7 +194,7 @@ _edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp,
195 { 194 {
196 _edje_signal_callback_unset(gp, i); 195 _edje_signal_callback_unset(gp, i);
197 _edje_signal_callback_set(gp, i, sig, src, func, data, flags); 196 _edje_signal_callback_set(gp, i, sig, src, func, data, flags);
198 return; 197 return EINA_TRUE;
199 } 198 }
200 } 199 }
201 200
@@ -211,7 +210,7 @@ _edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp,
211 Edje_Signal_Callback_Matches *tmp_dup = 210 Edje_Signal_Callback_Matches *tmp_dup =
212 (Edje_Signal_Callback_Matches *) 211 (Edje_Signal_Callback_Matches *)
213 _edje_signal_callback_matches_dup(tmp); 212 _edje_signal_callback_matches_dup(tmp);
214 if (!tmp_dup) return; 213 if (!tmp_dup) return EINA_FALSE;
215 EINA_REFCOUNT_UNREF(tmp) 214 EINA_REFCOUNT_UNREF(tmp)
216 (void) 0; // do nothing because if refcount == 1 handle above. 215 (void) 0; // do nothing because if refcount == 1 handle above.
217 gp->matches = tmp = tmp_dup; 216 gp->matches = tmp = tmp_dup;
@@ -226,7 +225,7 @@ _edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp,
226 { 225 {
227 _edje_signal_callback_unset(gp, i); 226 _edje_signal_callback_unset(gp, i);
228 _edje_signal_callback_set(gp, i, sig, src, func, data, flags); 227 _edje_signal_callback_set(gp, i, sig, src, func, data, flags);
229 return; 228 return EINA_TRUE;
230 } 229 }
231 } 230 }
232 231
@@ -234,6 +233,8 @@ _edje_signal_callback_push(const Edje_Signal_Callback_Group *cgp,
234 // Set propagate and just_added flags 233 // Set propagate and just_added flags
235 _edje_signal_callback_set(gp, tmp->matches_count - 1, 234 _edje_signal_callback_set(gp, tmp->matches_count - 1,
236 sig, src, func, data, flags); 235 sig, src, func, data, flags);
236
237 return EINA_TRUE;
237} 238}
238 239
239const Edje_Signal_Callback_Group * 240const Edje_Signal_Callback_Group *
@@ -300,17 +301,15 @@ _edje_signal_callback_free(const Edje_Signal_Callback_Group *cgp)
300 free(gp); 301 free(gp);
301} 302}
302 303
303void * 304Eina_Bool
304_edje_signal_callback_disable(const Edje_Signal_Callback_Group *cgp, 305_edje_signal_callback_disable(Edje_Signal_Callback_Group *gp,
305 const char *sig, const char *src, 306 const char *sig, const char *src,
306 Edje_Signal_Cb func, void *data) 307 Edje_Signal_Cb func, void *data)
307{ 308{
308 Edje_Signal_Callback_Group *gp = (Edje_Signal_Callback_Group *)cgp;
309 unsigned int i; 309 unsigned int i;
310 310
311 if (!gp || !gp->matches) return NULL; 311 if (!gp || !gp->matches) return EINA_FALSE;
312 312
313 // FIXME: Shall we check DELETE_ME flags ?
314 for (i = 0; i < gp->matches->matches_count; ++i) 313 for (i = 0; i < gp->matches->matches_count; ++i)
315 { 314 {
316 if (sig == gp->matches->matches[i].signal && 315 if (sig == gp->matches->matches[i].signal &&
@@ -320,26 +319,12 @@ _edje_signal_callback_disable(const Edje_Signal_Callback_Group *cgp,
320 !gp->flags[i].delete_me) 319 !gp->flags[i].delete_me)
321 { 320 {
322 gp->flags[i].delete_me = EINA_TRUE; 321 gp->flags[i].delete_me = EINA_TRUE;
323 return gp->custom_data[i]; 322 //return gp->custom_data[i];
324 } 323 return EINA_TRUE;
325 }
326
327 if (data == NULL)
328 {
329 for (i = 0; i < gp->matches->matches_count; ++i)
330 {
331 if (sig == gp->matches->matches[i].signal &&
332 src == gp->matches->matches[i].source &&
333 func == gp->matches->matches[i].func &&
334 !gp->flags[i].delete_me)
335 {
336 gp->flags[i].delete_me = EINA_TRUE;
337 return gp->custom_data[i];
338 }
339 } 324 }
340 } 325 }
341 326
342 return NULL; 327 return EINA_FALSE;
343} 328}
344 329
345static void 330static void
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index 4a6a76bbca..e33482ad3c 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -562,3 +562,4 @@ _edje_object_efl_observer_update(Eo *obj EINA_UNUSED, Edje *ed, Efl_Object *obs,
562 562
563#include "edje_object.eo.c" 563#include "edje_object.eo.c"
564#include "efl_canvas_layout_calc.eo.c" 564#include "efl_canvas_layout_calc.eo.c"
565#include "efl_canvas_layout_signal.eo.c"
diff --git a/src/lib/edje/efl_canvas_layout_signal.eo b/src/lib/edje/efl_canvas_layout_signal.eo
new file mode 100644
index 0000000000..a7d971bf9a
--- /dev/null
+++ b/src/lib/edje/efl_canvas_layout_signal.eo
@@ -0,0 +1,146 @@
1/*
2 Edje signaling interface.
3
4 Note: This API must be manually bound in other languages as this uses function
5 pointers! This is by design, to keep the API simplhe API simple.
6
7 If function pointers really become allowed in EO this needs to be altered to
8 match that.
9*/
10
11//type Edje.Signal_Cb: __undefined_type; [[Edje signal callback type]]
12
13type Efl.Signal_Cb: __undefined_type; [[Signal callback.]]
14
15interface Efl.Canvas.Layout_Signal
16{
17 [[Layouts asynchronous messaging and signaling interface.
18
19 @since 1.21
20 ]]
21 methods {
22 // FIXME: There is no message_handler in EO!
23 message_send {
24 [[Sends an (Edje) message to a given Edje object
25
26 This function sends an Edje message to obj and to all of its child
27 objects, if it has any (swallowed objects are one kind of child
28 object). Only a few types are supported:
29 - int,
30 - float/double,
31 - string/stringshare,
32 - arrays of int, float, double or strings.
33
34 Messages can go both ways, from code to theme, or theme to code.
35
36 The id argument as a form of code and theme defining a common
37 interface on message communication. One should define the same IDs on
38 both code and EDC declaration, to individualize messages (binding
39 them to a given context).
40 ]]
41 params {
42 @in id: int; [[A identification number for the message to be sent]]
43 @in msg: const(generic_value); [[The message's payload]]
44 }
45 }
46 signal_callback_add {
47 [[Adds a callback for an arriving Edje signal, emitted by
48 a given Edje object.
49
50 Edje signals are one of the communication interfaces between code and
51 a given Edje object's theme. With signals, one can communicate two
52 string values at a time, which are:
53 - "emission" value: the name of the signal, in general
54 - "source" value: a name for the signal's context, in general
55
56 Signals can go both ways, from code to theme, or theme to code.
57
58 Though there are those common uses for the two strings, one is free
59 to use them however they like.
60
61 Signal callback registration is powerful, in the way that blobs may
62 be used to match multiple signals at once. All the "*?[\" set of
63 $fnmatch() operators can be used, both for emission and source.
64
65 Edje has internal signals it will emit, automatically, on various
66 actions taking place on group parts. For example, the mouse cursor
67 being moved, pressed, released, etc., over a given part's area, all
68 generate individual signals.
69
70 With something like emission = "mouse,down,*", source = "button.*"
71 where "button.*" is the pattern for the names of parts implementing
72 buttons on an interface, you'd be registering for notifications on
73 events of mouse buttons being pressed down on either of those parts
74 (those events all have the "mouse,down," common prefix on their
75 names, with a suffix giving the button number). The actual emission
76 and source strings of an event will be passed in as the emission and
77 source parameters of the callback function (e.g. "mouse,down,2" and
78 "button.close"), for each of those events.
79
80 See also the Edje Data Collection Reference for EDC files.
81
82 See @.signal_emit on how to emit signals from code to a an object
83 See @.signal_callback_del.
84 ]]
85 params {
86 @in emission: string; [[The signal's "emission" string]]
87 @in source: string; [[The signal's "source" string]]
88 @in func: Efl.Signal_Cb;
89 [[The callback function to be executed when the signal is emitted.]]
90 @in data: void_ptr; [[A pointer to data to pass to $func.]]
91 }
92 return: bool; [[$true in case of success, $false in case of error.]]
93 }
94 signal_callback_del {
95 [[Removes a signal-triggered callback from an object.
96
97 This function removes a callback, previously attached to the emission
98 of a signal, from the object obj. The parameters emission, source
99 and func must match exactly those passed to a previous call to
100 @.signal_callback_add().
101
102 See @.signal_callback_add.
103 ]]
104 params {
105 @in emission: string; [[The signal's "emission" string]]
106 @in source: string; [[The signal's "source" string]]
107 @in func: Efl.Signal_Cb;
108 [[The callback function to be executed when the signal is emitted.]]
109 @in data: void_ptr; [[A pointer to data to pass to $func.]]
110 }
111 return: bool; [[$true in case of success, $false in case of error.]]
112 }
113 signal_emit {
114 [[Sends/emits an Edje signal to this layout.
115
116 This function sends a signal to the object. An Edje program, at the
117 EDC specification level, can respond to a signal by having declared
118 matching "signal" and "source" fields on its block.
119
120 See also the Edje Data Collection Reference for EDC files.
121
122 See @.signal_callback_add() for more on Edje signals.
123 ]]
124 params {
125 @in emission: string; [[The signal's "emission" string]]
126 @in source: string; [[The signal's "source" string]]
127 }
128 }
129 signal_process {
130 [[Processes an object's messages and signals queue.
131
132 This function goes through the object message queue processing the
133 pending messages for this specific Edje object. Normally they'd be
134 processed only at idle time.
135
136 If $recurse is $true, this function will be called recursively on all
137 subobjects.
138 ]]
139 // FIXME: Should be $true by default!
140 params {
141 recurse: bool @optional; [[Whether to process messages on children
142 objects.]]
143 }
144 }
145 }
146}