Listen and unlisten are quite bad. Keep Edje name compat as did for emit. I know it may be used differently, but even them signal_callback_add is good
On Friday, June 25, 2010, Enlightenment SVN <no-re...@enlightenment.org> wrote: > Log: > Implement elm_object_signal_listen and unlisten > > elm_object_signal_listen add callback(s) for edje object(s) of the widget. > elm_object_signal_unlisten delete this callback. > They're general functions, and every widget should set hooks for these. > > It will improve elm extension flexibility. We have already > elm_object_signal_emit to send signals for the widgets theme, adding > callbacks > is an expected step. > > It provides a way to support sound on widgets. For example, in the elm > extension > we could emit "file_to_play", "play", and add a callback with > elm_object_signal_listen for "*", "play". The callback function could use > the signal received to request the file to be played by the backend > sound system. > > Certainly we should look for a better way to provide support for sound > on edje, but for now, it does the work. And anyway, it's only a use case > for these new functions. > > > Author: bdilly > Date: 2010-06-25 15:38:32 -0700 (Fri, 25 Jun 2010) > New Revision: 49868 > > Modified: > trunk/TMP/st/elementary/src/lib/Elementary.h.in > trunk/TMP/st/elementary/src/lib/elm_main.c > trunk/TMP/st/elementary/src/lib/elm_priv.h > trunk/TMP/st/elementary/src/lib/elm_widget.c > > Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in > =================================================================== > --- trunk/TMP/st/elementary/src/lib/Elementary.h.in 2010-06-25 22:28:06 > UTC (rev 49867) > +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in 2010-06-25 22:38:32 > UTC (rev 49868) > @@ -288,6 +288,8 @@ > EAPI void elm_object_scroll_freeze_pop(Evas_Object *obj); > > EAPI void elm_object_signal_emit(Evas_Object *obj, const char > *emission, const char *source); > + EAPI void elm_object_signal_listen(Evas_Object *obj, const char > *emission, const char *source, void (*func) (void *data, Evas_Object *o, > const char *emission, const char *source), void *data); > + EAPI void *elm_object_signal_unlisten(Evas_Object *obj, const > char *emission, const char *source, void (*func) (void *data, Evas_Object *o, > const char *emission, const char *source)); > > EAPI void elm_coords_finger_size_adjust(int times_w, Evas_Coord > *w, int times_h, Evas_Coord *h); > > > Modified: trunk/TMP/st/elementary/src/lib/elm_main.c > =================================================================== > --- trunk/TMP/st/elementary/src/lib/elm_main.c 2010-06-25 22:28:06 UTC (rev > 49867) > +++ trunk/TMP/st/elementary/src/lib/elm_main.c 2010-06-25 22:38:32 UTC (rev > 49868) > @@ -1409,3 +1409,45 @@ > { > elm_widget_signal_emit(obj, emission, source); > } > + > +/** > + * Add a callback for a signal emitted by widget edje object. > + * > + * This function connects a callback function to a signal emitted by the > + * edje object of the obj. > + * Globs can occur in either the emission or source name. > + * > + * @param obj The object > + * @param emission The signal's name. > + * @param source The signal's source. > + * @param func The callback function to be executed when the signal is > + * emitted. > + * @param data A pointer to data to pass in to the callback function. > + * @ingroup General > + */ > +EAPI void elm_object_signal_listen(Evas_Object *obj, const char *emission, > const char *source, void (*func) (void *data, Evas_Object *o, const char > *emission, const char *source), void *data) > +{ > + elm_widget_signal_listen(obj, emission, source, func, data); > +} > + > +/** > + * Remove a signal-triggered callback from an widget edje object. > + * > + * This function removes a callback, previoulsy attached to a signal emitted > + * by the edje object of the obj. > + * The parameters emission, source and func must match exactly those passed > to > + * a previous call to elm_object_signal_listen(). The data pointer that > + * was passed to this call will be returned. > + * > + * @param obj The object > + * @param emission The signal's name. > + * @param source The signal's source. > + * @param func The callback function to be executed when the signal is > + * emitted. > + * @return The data pointer > + * @ingroup General > + */ > +EAPI void *elm_object_signal_unlisten(Evas_Object *obj, const char > *emission, const char *source, void (*func) (void *data, Evas_Object *o, > const char *emission, const char *source)) > +{ > + return elm_widget_signal_unlisten(obj, emission, source, func); > +} > > Modified: trunk/TMP/st/elementary/src/lib/elm_priv.h > =================================================================== > --- trunk/TMP/st/elementary/src/lib/elm_priv.h 2010-06-25 22:28:06 UTC (rev > 49867) > +++ trunk/TMP/st/elementary/src/lib/elm_priv.h 2010-06-25 22:38:32 UTC (rev > 49868) > @@ -139,6 +139,8 @@ > EAPI void elm_widget_theme_hook_set(Evas_Object *obj, void (*func) > (Evas_Object *obj)); > EAPI void elm_widget_changed_hook_set(Evas_Object *obj, void (*func) > (Evas_Object *obj)); > EAPI void elm_widget_signal_emit_hook_set(Evas_Object *obj, void > (*func) (Evas_Object *obj, const char *emission, const char *source)); > +EAPI void elm_widget_signal_listen_hook_set(Evas_Object *obj, void > (*func) (Evas_Object *obj, const char *emission, const char *source, void > (*func_cb) (void *data, Evas_Object *o, const char *emission, const char > *source), void *data)); > +EAPI void elm_widget_signal_unlisten_hook_set(Evas_Object *obj, void > *(*func) (Evas_Object *obj, const char *emission, const char *source, void > (*func_cb) (void *data, Evas_Object *o, const char *emission, const char > *source))); > EAPI void elm_widget_theme(Evas_Object *obj); > EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void > (*func) (void *data, Evas_Object *obj), void *data); > EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void > (*func) (void *data, Evas_Object *obj), void *data); > @@ -150,6 +152,8 @@ > EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object > *sobj); > EAPI void elm_widget_hover_object_set(Evas_Object *obj, Evas_Object > *sobj); > EAPI void elm_widget_signal_emit(Evas_Object *obj, const char > *emission, const char *source); > +EAPI void elm_widget_signal_listen(Evas_Object *obj, const char > *emission, const char *source, void (*func) (void *data, Evas_Object *o, > const char *emission, const char *source), void *data); > +EAPI void *elm_widget_signal_unlisten(Evas_Object *obj, const char > *emission, const char *source, void (*func) (void *data, Evas_Object *o, > const char *emission, const char *source)); > EAPI void elm_widget_can_focus_set(Evas_Object *obj, int can_focus); > EAPI int elm_widget_can_focus_get(const Evas_Object *obj); > EAPI int elm_widget_focus_get(const Evas_Object *obj); > > Modified: trunk/TMP/st/elementary/src/lib/elm_widget.c > =================================================================== > --- trunk/TMP/st/elementary/src/lib/elm_widget.c 2010-06-25 22:28:06 > UTC (rev 49867) > +++ trunk/TMP/st/elementary/src/lib/elm_widget.c 2010-06-25 22:38:32 > UTC (rev 49868) > @@ -29,6 +29,14 @@ > void (*theme_func) (Evas_Object *obj); > void (*signal_func) (Evas_Object *obj, const char *emission, > const char *source); > + void (*listen_func) (Evas_Object *obj, const char *emission, > + const char *source, void (*func) (void *data, > + Evas_Object *o, const char *emission, > + const char *source), void *data); > + void *(*unlisten_func) (Evas_Object *obj, const char *emission, > + const char *source, void (*func) (void > *data, > + Evas_Object *o, const char *emission, > + const char *source)); > void (*changed_func) (Evas_Object *obj); > void (*on_focus_func) (void *data, Evas_Object *obj); > void *on_focus_data; > @@ -171,6 +179,20 @@ > } > > EAPI void > +elm_widget_signal_listen_hook_set(Evas_Object *obj, void (*func) > (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) > (void *data, Evas_Object *o, const char *emission, const char *source), void > *data)) > +{ > + API_ENTRY return; > + sd->listen_func = func; > +} > + > +EAPI void > +elm_widget_signal_unlisten_hook_set(Evas_Object *obj, void *(*func) > (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) > (void *data, Evas_Object *o, const char *emission, const char *source))) > +{ > + API_ENTRY return; > + sd->unlisten_func = func; > +} > + > +EAPI void > elm_widget_theme(Evas_Object *obj) > { > const Eina_List *l; > @@ -610,6 +632,22 @@ > } > > EAPI void > +elm_widget_signal_listen(Evas_Object *obj, const char *emission, const char > *source, void (*func) (void *data, Evas_Object *o, const char *emission, > const char *source), void *data) > +{ > + API_ENTRY return; > + if (!sd->listen_func) return; > + sd->listen_func(obj, emission, source, func, data); > +} > + > +EAPI void * > +elm_widget_signal_unlisten(Evas_Object *obj, const char *emission, const > char *source, void (*func) (void *data, Evas_Object *o, const char *emission, > const char *source)) > +{ > + API_ENTRY return NULL; > + if (!sd->unlisten_func) return NULL; > + return sd->unlisten_func(obj, emission, source, func); > +} > + > +EAPI void > elm_widget_focus_set(Evas_Object *obj, int first) > { > API_ENTRY return; > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > enlightenment-svn mailing list > enlightenment-...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: barbi...@gmail.com Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel