[Pkg-e-commits] [SCM] Enlightenment DR17 advanced canvas library branch, upstream-vcs, updated. 069f3cc6c93f253bffbc90289fe21d868f745bb6

barbieri barbieri at alioth.debian.org
Sat Jun 7 18:24:33 UTC 2008


The following commit has been merged in the upstream-vcs branch:
commit 1f2f2964b9cb43d333ae1a01b12469d9b870ae93
Author: barbieri <barbieri>
Date:   Tue Jun 3 20:33:40 2008 +0000

    Add evas_object_event_callback_del_full()
    
    This will check both function and data before removing the callback,
    this is useful when you have lots of children monitoring parent, when
    one child want to remove its monitoring function, others will remain.
    
    Name is quite difficult to choose, I opted for "_full", but could be
    "_with_data" or similar.

diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index 7899c10..3a1830e 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -865,6 +865,7 @@ extern "C" {
 
    EAPI void              evas_object_event_callback_add    (Evas_Object *obj, Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, void *event_info), const void *data);
    EAPI void             *evas_object_event_callback_del    (Evas_Object *obj, Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, void *event_info));
+   EAPI void             *evas_object_event_callback_del_full(Evas_Object *obj, Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, void *event_info), const void *data);
 
    EAPI int		  evas_async_events_fd_get          (void);
    EAPI int		  evas_async_events_process	    (void);
diff --git a/src/lib/canvas/evas_callbacks.c b/src/lib/canvas/evas_callbacks.c
index 7d8f1cd..1fde375 100644
--- a/src/lib/canvas/evas_callbacks.c
+++ b/src/lib/canvas/evas_callbacks.c
@@ -406,3 +406,63 @@ evas_object_event_callback_del(Evas_Object *obj, Evas_Callback_Type type, void (
      }
    return NULL;
 }
+
+/**
+ * Delete a callback function from an object
+ * @param obj Object to remove a callback from
+ * @param type The type of event that was triggering the callback
+ * @param func The function that was to be called when the event was triggered
+ * @param data The data pointer that was to be passed to the callback
+ * @return The data pointer that was to be passed to the callback
+ *
+ * This function removes the most recently added callback from the object
+ * @p obj which was triggered by the event type @p type and was calling the
+ * function @p func with data @p data when triggered. If the removal is
+ * successful it will also return the data pointer that was passed to
+ * evas_object_event_callback_add() (that will be the same as the parameter)
+ * when the callback was added to the object. If not successful NULL will be
+ * returned.
+ *
+ * Example:
+ * @code
+ * extern Evas_Object *object;
+ * void *my_data;
+ * void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info);
+ *
+ * my_data = evas_object_event_callback_del_full(object, EVAS_CALLBACK_MOUSE_UP, up_callback, data);
+ * @endcode
+ * @ingroup Evas_Object_Callback_Group
+ */
+EAPI void *
+evas_object_event_callback_del_full(Evas_Object *obj, Evas_Callback_Type type, void (*func) (void *data, Evas *e, Evas_Object *obj, void *event_info), const void *data)
+{
+   /* MEM OK */
+   Evas_Object_List *l;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return NULL;
+   MAGIC_CHECK_END();
+
+   if (!func) return NULL;
+
+   if (!obj->callbacks) return NULL;
+
+   for (l = obj->callbacks->callbacks; l; l = l->next)
+     {
+	Evas_Func_Node *fn;
+
+	fn = (Evas_Func_Node *)l;
+	if ((fn->func == func) && (fn->type == type) && (fn->data == data) && (!fn->delete_me))
+	  {
+	     void *data;
+
+	     data = fn->data;
+	     fn->delete_me = 1;
+	     obj->callbacks->deletions_waiting = 1;
+	     if (!obj->callbacks->walking_list)
+	       evas_object_event_callback_clear(obj);
+	     return data;
+	  }
+     }
+   return NULL;
+}

-- 
Enlightenment DR17 advanced canvas library



More information about the Pkg-e-commits mailing list