3 typedef struct _E_Widget_Data E_Widget_Data;
6 Evas_Object *obj, *o_frame, *img, *o_thumb, *o_extern;
9 /* local subsystem functions */
10 static void _e_wid_del_hook(Evas_Object *obj);
11 static void _e_wid_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info);
13 /* externally accessible functions */
15 e_widget_preview_add(Evas *evas, int minw, int minh)
21 obj = e_widget_add(evas);
22 e_widget_del_hook_set(obj, _e_wid_del_hook);
24 wd = E_NEW(E_Widget_Data, 1);
29 wd->o_frame = edje_object_add(evas);
30 e_theme_edje_object_set(wd->o_frame, "base/theme/widgets",
32 evas_object_show(wd->o_frame);
33 e_widget_sub_object_add(obj, wd->o_frame);
34 e_widget_resize_object_set(obj, wd->o_frame);
36 wd->img = e_livethumb_add(evas);
37 e_livethumb_vsize_set(wd->img, minw * 2, minh * 2);
38 edje_extern_object_min_size_set(wd->img, minw, minh);
39 /* Why do we set max size? This prevents from being nicely resized. */
40 /* edje_extern_object_max_size_set(o, minw, minh); */
41 // evas_object_show(wd->img);
42 edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
43 e_widget_sub_object_add(obj, wd->img);
45 e_widget_data_set(obj, wd);
46 e_widget_can_focus_set(obj, 0);
47 edje_object_size_min_calc(wd->o_frame, &mw, &mh);
48 e_widget_size_min_set(obj, mw, mh);
54 e_widget_preview_evas_get(Evas_Object *obj)
58 wd = e_widget_data_get(obj);
59 return e_livethumb_evas_get(wd->img);
63 e_widget_preview_extern_object_set(Evas_Object *obj, Evas_Object *eobj)
67 wd = e_widget_data_get(obj);
69 e_livethumb_thumb_set(wd->img, wd->o_extern);
75 e_widget_preview_file_set(Evas_Object *obj, const char *file, const char *key)
79 wd = e_widget_data_get(obj);
80 if (wd->o_thumb) evas_object_del(wd->o_thumb);
82 wd->o_thumb = e_icon_add(e_livethumb_evas_get(wd->img));
83 e_icon_fill_inside_set(wd->o_thumb, 0);
84 e_icon_file_key_set(wd->o_thumb, file, key);
85 evas_object_show(wd->o_thumb);
86 e_livethumb_thumb_set(wd->img, wd->o_thumb);
94 e_widget_preview_thumb_set(Evas_Object *obj, const char *file, const char *key, int w, int h)
98 wd = e_widget_data_get(obj);
101 e_widget_sub_object_del(obj, wd->img);
102 evas_object_del(wd->img);
105 wd->img = e_thumb_icon_add(evas_object_evas_get(obj));
106 e_widget_sub_object_add(obj, wd->img);
107 if (eina_str_has_extension(file, "edj"))
110 e_thumb_icon_file_set(wd->img, file, key);
112 /* FIXME: There is probably a quicker way of doing this. */
113 if (edje_file_group_exists(file, "icon"))
114 e_thumb_icon_file_set(wd->img, file, "icon");
115 else if (edje_file_group_exists(file, "e/desktop/background"))
116 e_thumb_icon_file_set(wd->img, file, "e/desktop/background");
117 else if (edje_file_group_exists(file, "e/init/splash"))
118 e_thumb_icon_file_set(wd->img, file, "e/init/splash");
121 e_thumb_icon_file_set(wd->img, file, NULL);
122 evas_object_smart_callback_add(wd->img, "e_thumb_gen", _e_wid_preview_thumb_gen, wd);
123 e_thumb_icon_size_set(wd->img, w, h);
124 e_thumb_icon_begin(wd->img);
126 edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
127 evas_object_show(wd->img);
129 e_widget_change(obj);
135 e_widget_preview_vsize_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
139 wd = e_widget_data_get(obj);
140 e_livethumb_vsize_set(wd->img, w, h);
144 _e_wid_preview_thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
150 e_icon_size_get(wd->img, &w, &h);
151 edje_extern_object_min_size_set(wd->img, w, h);
152 /* Why do we set max size? This prevents from being nicely resized. */
153 /* edje_extern_object_max_size_set(wd->img, w, h); */
154 edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
155 edje_object_size_min_calc(wd->o_frame, &w, &h);
156 e_widget_size_min_set(wd->obj, w, h);
157 evas_object_resize(wd->obj, w, h);
158 evas_object_smart_callback_call(wd->obj, "preview_update", NULL);
162 e_widget_preview_file_get(Evas_Object *obj, const char **file, const char **group)
166 wd = e_widget_data_get(obj);
167 edje_object_file_get(wd->o_thumb, file, group);
171 e_widget_preview_edje_set(Evas_Object *obj, const char *file, const char *group)
176 wd = e_widget_data_get(obj);
177 if (wd->o_thumb) evas_object_del(wd->o_thumb);
178 wd->o_thumb = edje_object_add(e_livethumb_evas_get(wd->img));
179 ret = edje_object_file_set(wd->o_thumb, file, group);
180 evas_object_show(wd->o_thumb);
181 e_livethumb_thumb_set(wd->img, wd->o_thumb);
183 e_widget_change(obj);
189 _e_wid_del_hook(Evas_Object *obj)
193 wd = e_widget_data_get(obj);