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);
73 e_widget_preview_file_set(Evas_Object *obj, const char *file, const char *key)
77 wd = e_widget_data_get(obj);
78 if (wd->o_thumb) evas_object_del(wd->o_thumb);
80 wd->o_thumb = e_icon_add(e_livethumb_evas_get(wd->img));
81 e_icon_fill_inside_set(wd->o_thumb, 0);
82 e_icon_file_key_set(wd->o_thumb, file, key);
83 evas_object_show(wd->o_thumb);
84 e_livethumb_thumb_set(wd->img, wd->o_thumb);
90 e_widget_preview_thumb_set(Evas_Object *obj, const char *file, const char *key __UNUSED__, int w, int h)
94 wd = e_widget_data_get(obj);
97 e_widget_sub_object_del(obj, wd->img);
98 evas_object_del(wd->img);
101 wd->img = e_thumb_icon_add(evas_object_evas_get(obj));
102 e_widget_sub_object_add(obj, wd->img);
103 if (e_util_glob_case_match(file, "*.edj"))
105 /* FIXME: There is probably a quicker way of doing this. */
106 if (edje_file_group_exists(file, "icon"))
107 e_thumb_icon_file_set(wd->img, file, "icon");
108 else if (edje_file_group_exists(file, "e/desktop/background"))
109 e_thumb_icon_file_set(wd->img, file, "e/desktop/background");
110 else if (edje_file_group_exists(file, "e/init/splash"))
111 e_thumb_icon_file_set(wd->img, file, "e/init/splash");
114 e_thumb_icon_file_set(wd->img, file, NULL);
115 evas_object_smart_callback_add(wd->img, "e_thumb_gen", _e_wid_preview_thumb_gen, wd);
116 e_thumb_icon_size_set(wd->img, w, h);
117 e_thumb_icon_begin(wd->img);
119 edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
120 evas_object_show(wd->img);
126 e_widget_preview_vsize_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
130 wd = e_widget_data_get(obj);
131 e_livethumb_vsize_set(wd->img, w, h);
135 _e_wid_preview_thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
141 e_icon_size_get(wd->img, &w, &h);
142 edje_extern_object_min_size_set(wd->img, w, h);
143 /* Why do we set max size? This prevents from being nicely resized. */
144 /* edje_extern_object_max_size_set(wd->img, w, h); */
145 edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
146 edje_object_size_min_calc(wd->o_frame, &w, &h);
147 e_widget_size_min_set(wd->obj, w, h);
148 evas_object_resize(wd->obj, w, h);
149 evas_object_smart_callback_call(wd->obj, "preview_update", NULL);
153 e_widget_preview_edje_set(Evas_Object *obj, const char *file, const char *group)
158 wd = e_widget_data_get(obj);
159 if (wd->o_thumb) evas_object_del(wd->o_thumb);
160 wd->o_thumb = edje_object_add(e_livethumb_evas_get(wd->img));
161 ret = edje_object_file_set(wd->o_thumb, file, group);
162 evas_object_show(wd->o_thumb);
163 e_livethumb_thumb_set(wd->img, wd->o_thumb);
168 _e_wid_del_hook(Evas_Object *obj)
172 wd = e_widget_data_get(obj);