#include <Elementary.h>
#ifndef ELM_LIB_QUICKLAUNCH
+#define MAX_TRY 40
+
+static int try_num = 0;
+
+static void
+_timer_del(void *data __UNUSED__,
+ Evas *e __UNUSED__,
+ Evas_Object *obj,
+ void *event_info __UNUSED__)
+{
+ Ecore_Timer *timer = evas_object_data_del(obj, "test-timer");
+ if (!timer) return;
+ ecore_timer_del(timer);
+}
+
+static Eina_Bool
+cb_plug_connect(void *data)
+{
+ Evas_Object *obj = data;
+ Ecore_Timer *timer;
+
+ if (!obj) return ECORE_CALLBACK_CANCEL;
+
+ try_num++;
+ if (try_num > MAX_TRY) return ECORE_CALLBACK_CANCEL;
+
+ timer= evas_object_data_get(obj, "test-timer");
+ if (!timer) return ECORE_CALLBACK_CANCEL;
+
+ if (elm_plug_connect(obj, "ello", 0, EINA_FALSE))
+ {
+ printf("plug connect to server[ello]\n");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ ecore_timer_interval_set(timer, 1);
+ return ECORE_CALLBACK_RENEW;
+}
+
+static void
+cb_plug_disconnected(void *data __UNUSED__,
+ Evas_Object *obj,
+ void *event_info __UNUSED__)
+{
+ Ecore_Timer *timer = evas_object_data_get(obj, "test-timer");
+ if (timer)
+ {
+ ecore_timer_del(timer);
+ evas_object_data_del(obj, "test-timer");
+ return;
+ }
+
+ timer = ecore_timer_add(1, cb_plug_connect, obj);
+ evas_object_data_set(obj, "test-timer", timer);
+}
static void
cb_mouse_down(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
plug = elm_plug_add(win);
evas_object_event_callback_add(elm_plug_image_object_get(plug), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL);
+ evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL, _timer_del, NULL);
if (!elm_plug_connect(plug, "ello", 0, EINA_FALSE))
{
printf("Cannot connect plug\n");
return;
}
+ evas_object_smart_callback_add(plug, "image.deleted", cb_plug_disconnected, NULL);
+
evas_object_resize(plug, 380, 500);
evas_object_move(plug, 10, 10);
evas_object_show(plug);
EAPI const char ELM_PLUG_SMART_NAME[] = "elm_plug";
+static const char PLUG_KEY[] = "__Plug_Ecore_Evas";
+
static const char SIG_CLICKED[] = "clicked";
+static const char SIG_IMAGE_DELETED[] = "image.deleted";
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_CLICKED, ""},
+ {SIG_IMAGE_DELETED, ""},
{NULL, NULL}
};
evas_object_size_hint_max_set(obj, maxw, maxh);
}
+static void
+_elm_plug_disconnected(Ecore_Evas *ee)
+{
+ Evas_Object *plug = NULL;
+
+ if (!ee) return;
+ plug = ecore_evas_data_get(ee, PLUG_KEY);
+ if (!plug) return;
+ evas_object_smart_callback_call(plug, SIG_IMAGE_DELETED, NULL);
+}
+
static Eina_Bool
_elm_plug_smart_theme(Evas_Object *obj)
{
{
Evas_Object *plug_img = NULL;
+ ELM_PLUG_CHECK(obj) EINA_FALSE;
+
plug_img = elm_plug_image_object_get(obj);
if (!plug_img) return EINA_FALSE;
- return ecore_evas_extn_plug_connect(plug_img, svcname, svcnum, svcsys);
+ if (ecore_evas_extn_plug_connect(plug_img, svcname, svcnum, svcsys))
+ {
+ Ecore_Evas *ee = NULL;
+ ee = ecore_evas_object_ecore_evas_get(plug_img);
+ if (!ee) return EINA_FALSE;
+
+ ecore_evas_data_set(ee, PLUG_KEY, obj);
+ ecore_evas_callback_delete_request_set(ee, _elm_plug_disconnected);
+ return EINA_TRUE;
+ }
+ else
+ return EINA_FALSE;
}