1 #include <Elementary.h>
3 #include "elm_widget_plug.h"
5 EAPI const char ELM_PLUG_SMART_NAME[] = "elm_plug";
7 static const char PLUG_KEY[] = "__Plug_Ecore_Evas";
9 static const char SIG_CLICKED[] = "clicked";
10 static const char SIG_IMAGE_DELETED[] = "image.deleted";
11 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
13 {SIG_IMAGE_DELETED, ""},
17 EVAS_SMART_SUBCLASS_NEW
18 (ELM_PLUG_SMART_NAME, _elm_plug, Elm_Plug_Smart_Class,
19 Elm_Widget_Smart_Class, elm_widget_smart_class_get, _smart_callbacks);
22 _sizing_eval(Evas_Object *obj __UNUSED__)
24 //Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
26 //TODO: get socket object size
27 //this reset plug's min/max size
28 //evas_object_size_hint_min_set(obj, minw, minh);
29 //evas_object_size_hint_max_set(obj, maxw, maxh);
33 _elm_plug_disconnected(Ecore_Evas *ee)
35 Evas_Object *plug = NULL;
38 plug = ecore_evas_data_get(ee, PLUG_KEY);
40 evas_object_smart_callback_call(plug, SIG_IMAGE_DELETED, NULL);
44 _elm_plug_smart_theme(Evas_Object *obj)
46 if (!_elm_plug_parent_sc->theme(obj)) return EINA_FALSE;
54 _on_mouse_up(void *data,
56 Evas_Object *obj __UNUSED__,
57 void *event_info __UNUSED__)
59 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
63 _elm_plug_smart_add(Evas_Object *obj)
68 EVAS_SMART_DATA_ALLOC(obj, Elm_Plug_Smart_Data);
70 _elm_plug_parent_sc->base.add(obj);
72 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
75 p_obj = ecore_evas_extn_plug_new(ee);
78 elm_widget_resize_object_set(obj, p_obj);
80 evas_object_event_callback_add
81 (ELM_WIDGET_DATA(priv)->resize_obj, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up,
84 elm_widget_can_focus_set(obj, EINA_FALSE);
89 _elm_plug_smart_set_user(Elm_Plug_Smart_Class *sc)
91 ELM_WIDGET_CLASS(sc)->base.add = _elm_plug_smart_add;
93 ELM_WIDGET_CLASS(sc)->theme = _elm_plug_smart_theme;
96 EAPI const Elm_Plug_Smart_Class *
97 elm_plug_smart_class_get(void)
99 static Elm_Plug_Smart_Class _sc =
100 ELM_PLUG_SMART_CLASS_INIT_NAME_VERSION(ELM_PLUG_SMART_NAME);
101 static const Elm_Plug_Smart_Class *class = NULL;
103 if (class) return class;
105 _elm_plug_smart_set(&_sc);
112 elm_plug_add(Evas_Object *parent)
116 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
118 obj = elm_widget_add(_elm_plug_smart_class_new(), parent);
119 if (!obj) return NULL;
121 ELM_PLUG_DATA_GET(obj, sd);
122 if (!ELM_WIDGET_DATA(sd)->resize_obj) return NULL;
124 if (!elm_widget_sub_object_add(parent, obj))
125 ERR("could not add %p as sub object of %p", obj, parent);
131 elm_plug_image_object_get(const Evas_Object *obj)
133 ELM_PLUG_CHECK(obj) NULL;
134 ELM_PLUG_DATA_GET(obj, sd);
136 return ELM_WIDGET_DATA(sd)->resize_obj;
140 elm_plug_connect(Evas_Object *obj,
145 Evas_Object *plug_img = NULL;
147 ELM_PLUG_CHECK(obj) EINA_FALSE;
149 plug_img = elm_plug_image_object_get(obj);
150 if (!plug_img) return EINA_FALSE;
152 if (ecore_evas_extn_plug_connect(plug_img, svcname, svcnum, svcsys))
154 Ecore_Evas *ee = NULL;
155 ee = ecore_evas_object_ecore_evas_get(plug_img);
156 if (!ee) return EINA_FALSE;
158 ecore_evas_data_set(ee, PLUG_KEY, obj);
159 ecore_evas_callback_delete_request_set(ee, _elm_plug_disconnected);