1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
11 static const char *widtype = NULL;
12 static void _del_hook(Evas_Object *obj);
13 static void _theme_hook(Evas_Object *obj);
14 static void _sizing_eval(Evas_Object *obj);
15 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
16 static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
18 static const char SIG_CLICKED[] = "clicked";
20 static const Evas_Smart_Cb_Description _signals[] = {
27 _del_hook(Evas_Object *obj)
29 Widget_Data *wd = elm_widget_data_get(obj);
36 _del_pre_hook(Evas_Object *obj)
38 Widget_Data *wd = elm_widget_data_get(obj);
42 evas_object_event_callback_del_full(wd->img, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
43 evas_object_del(wd->img);
47 _theme_hook(Evas_Object *obj)
49 Widget_Data *wd = elm_widget_data_get(obj);
56 _sizing_eval(Evas_Object *obj)
58 Widget_Data *wd = elm_widget_data_get(obj);
59 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
63 //TODO: get socket object size
65 evas_object_size_hint_min_get(wd->img, &minw, &minh);
66 evas_object_size_hint_max_get(wd->img, &maxw, &maxh);
67 evas_object_size_hint_min_set(obj, minw, minh);
68 evas_object_size_hint_max_set(obj, maxw, maxh);
72 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
74 Widget_Data *wd = elm_widget_data_get(data);
76 if (obj != wd->img) return;
81 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
83 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
88 elm_plug_image_object_get(const Evas_Object *obj)
90 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
91 Widget_Data *wd = elm_widget_data_get(obj);
93 if (!wd->img) return NULL;
98 elm_plug_add(Evas_Object *parent)
105 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
107 ELM_SET_WIDTYPE(widtype, "plug");
108 elm_widget_type_set(obj, "plug");
109 elm_widget_sub_object_add(parent, obj);
110 elm_widget_data_set(obj, wd);
111 elm_widget_del_hook_set(obj, _del_hook);
112 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
113 elm_widget_theme_hook_set(obj, _theme_hook);
114 elm_widget_can_focus_set(obj, EINA_FALSE);
116 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
117 if (!ee) return NULL;
118 wd->img = ecore_evas_extn_plug_new(ee);
119 if (!wd->img) return NULL;
120 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
121 _changed_size_hints, obj);
122 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
124 elm_widget_resize_object_set(obj, wd->img);
126 evas_object_smart_callbacks_descriptions_set(obj, _signals);
133 elm_plug_connect(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
135 Evas_Object *plug_img = NULL;
137 plug_img = elm_plug_image_object_get(obj);
138 if (!plug_img) return EINA_FALSE;
140 if (ecore_evas_extn_plug_connect(plug_img, svcname, svcnum, svcsys))