2006-03-03 20:11:51 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
typedef struct _E_Widget_Data E_Widget_Data;
|
|
|
|
struct _E_Widget_Data
|
|
|
|
{
|
2006-10-20 07:31:51 -07:00
|
|
|
Evas_Object *obj, *o_frame, *img, *o_thumb, *o_extern;
|
2006-03-03 20:11:51 -08:00
|
|
|
};
|
|
|
|
|
2008-03-24 19:20:32 -07:00
|
|
|
/* local subsystem functions */
|
2006-03-03 20:11:51 -08:00
|
|
|
static void _e_wid_del_hook(Evas_Object *obj);
|
2006-08-14 10:42:45 -07:00
|
|
|
static void _e_wid_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info);
|
2006-03-03 20:11:51 -08:00
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
EAPI Evas_Object *
|
|
|
|
e_widget_preview_add(Evas *evas, int minw, int minh)
|
|
|
|
{
|
2010-06-19 15:59:02 -07:00
|
|
|
Evas_Object *obj;
|
2006-03-03 20:11:51 -08:00
|
|
|
E_Widget_Data *wd;
|
|
|
|
Evas_Coord mw, mh;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
obj = e_widget_add(evas);
|
|
|
|
e_widget_del_hook_set(obj, _e_wid_del_hook);
|
2010-06-19 15:59:02 -07:00
|
|
|
|
|
|
|
wd = E_NEW(E_Widget_Data, 1);
|
2008-03-24 19:20:32 -07:00
|
|
|
if (!wd) return NULL;
|
2006-03-03 20:11:51 -08:00
|
|
|
|
2006-08-26 01:32:56 -07:00
|
|
|
wd->obj = obj;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2010-06-19 15:59:02 -07:00
|
|
|
wd->o_frame = edje_object_add(evas);
|
|
|
|
e_theme_edje_object_set(wd->o_frame, "base/theme/widgets",
|
|
|
|
"e/widgets/preview");
|
|
|
|
evas_object_show(wd->o_frame);
|
|
|
|
e_widget_sub_object_add(obj, wd->o_frame);
|
|
|
|
e_widget_resize_object_set(obj, wd->o_frame);
|
|
|
|
|
|
|
|
wd->img = e_livethumb_add(evas);
|
|
|
|
e_livethumb_vsize_set(wd->img, minw * 2, minh * 2);
|
|
|
|
edje_extern_object_min_size_set(wd->img, minw, minh);
|
2008-10-11 01:19:31 -07:00
|
|
|
/* Why do we set max size? This prevents from being nicely resized. */
|
|
|
|
/* edje_extern_object_max_size_set(o, minw, minh); */
|
2010-06-19 15:59:02 -07:00
|
|
|
// evas_object_show(wd->img);
|
|
|
|
edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
|
|
|
|
e_widget_sub_object_add(obj, wd->img);
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
e_widget_data_set(obj, wd);
|
|
|
|
e_widget_can_focus_set(obj, 0);
|
|
|
|
edje_object_size_min_calc(wd->o_frame, &mw, &mh);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, mw, mh);
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2006-10-20 07:31:51 -07:00
|
|
|
EAPI Evas *
|
|
|
|
e_widget_preview_evas_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-10-20 07:31:51 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
return e_livethumb_evas_get(wd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_widget_preview_extern_object_set(Evas_Object *obj, Evas_Object *eobj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-10-20 07:31:51 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
wd->o_extern = eobj;
|
|
|
|
e_livethumb_thumb_set(wd->img, wd->o_extern);
|
|
|
|
}
|
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
EAPI int
|
2006-04-01 01:24:56 -08:00
|
|
|
e_widget_preview_file_set(Evas_Object *obj, const char *file, const char *key)
|
2006-03-03 20:11:51 -08:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
2006-10-15 08:12:14 -07:00
|
|
|
if (wd->o_thumb) evas_object_del(wd->o_thumb);
|
2006-08-14 10:42:45 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
wd->o_thumb = e_icon_add(e_livethumb_evas_get(wd->img));
|
|
|
|
e_icon_file_key_set(wd->o_thumb, file, key);
|
|
|
|
evas_object_show(wd->o_thumb);
|
|
|
|
e_livethumb_thumb_set(wd->img, wd->o_thumb);
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-08-14 10:42:45 -07:00
|
|
|
EAPI int
|
2010-08-18 13:29:41 -07:00
|
|
|
e_widget_preview_thumb_set(Evas_Object *obj, const char *file, const char *key __UNUSED__, int w, int h)
|
2006-08-14 10:42:45 -07:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-08-14 10:42:45 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
if (wd->img)
|
2006-10-15 08:12:14 -07:00
|
|
|
{
|
|
|
|
e_widget_sub_object_del(obj, wd->img);
|
|
|
|
evas_object_del(wd->img);
|
|
|
|
}
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-08-14 10:42:45 -07:00
|
|
|
wd->img = e_thumb_icon_add(evas_object_evas_get(obj));
|
2006-10-15 08:12:14 -07:00
|
|
|
e_widget_sub_object_add(obj, wd->img);
|
2006-08-26 01:32:56 -07:00
|
|
|
if (e_util_glob_case_match(file, "*.edj"))
|
2006-10-15 08:12:14 -07:00
|
|
|
{
|
|
|
|
/* FIXME: There is probably a quicker way of doing this. */
|
|
|
|
if (edje_file_group_exists(file, "icon"))
|
|
|
|
e_thumb_icon_file_set(wd->img, file, "icon");
|
|
|
|
else if (edje_file_group_exists(file, "e/desktop/background"))
|
|
|
|
e_thumb_icon_file_set(wd->img, file, "e/desktop/background");
|
|
|
|
else if (edje_file_group_exists(file, "e/init/splash"))
|
|
|
|
e_thumb_icon_file_set(wd->img, file, "e/init/splash");
|
|
|
|
}
|
2006-08-26 01:32:56 -07:00
|
|
|
else
|
|
|
|
e_thumb_icon_file_set(wd->img, file, NULL);
|
2006-10-15 08:12:14 -07:00
|
|
|
evas_object_smart_callback_add(wd->img, "e_thumb_gen", _e_wid_preview_thumb_gen, wd);
|
2006-08-14 10:42:45 -07:00
|
|
|
e_thumb_icon_size_set(wd->img, w, h);
|
|
|
|
e_thumb_icon_begin(wd->img);
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
|
2006-08-14 10:42:45 -07:00
|
|
|
evas_object_show(wd->img);
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-08-14 10:42:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-08-07 23:18:00 -07:00
|
|
|
EAPI void
|
|
|
|
e_widget_preview_vsize_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
|
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
e_livethumb_vsize_set(wd->img, w, h);
|
|
|
|
}
|
|
|
|
|
2006-08-14 10:42:45 -07:00
|
|
|
static void
|
2010-08-18 13:29:41 -07:00
|
|
|
_e_wid_preview_thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2006-08-14 10:42:45 -07:00
|
|
|
{
|
|
|
|
Evas_Coord w, h;
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
|
2007-05-12 14:48:59 -07:00
|
|
|
wd = data;
|
2006-08-14 10:42:45 -07:00
|
|
|
e_icon_size_get(wd->img, &w, &h);
|
2006-08-26 01:32:56 -07:00
|
|
|
edje_extern_object_min_size_set(wd->img, w, h);
|
2008-10-11 01:19:31 -07:00
|
|
|
/* Why do we set max size? This prevents from being nicely resized. */
|
|
|
|
/* edje_extern_object_max_size_set(wd->img, w, h); */
|
2006-08-26 01:32:56 -07:00
|
|
|
edje_object_part_swallow(wd->o_frame, "e.swallow.content", wd->img);
|
|
|
|
edje_object_size_min_calc(wd->o_frame, &w, &h);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(wd->obj, w, h);
|
2006-08-26 01:32:56 -07:00
|
|
|
evas_object_resize(wd->obj, w, h);
|
|
|
|
evas_object_smart_callback_call(wd->obj, "preview_update", NULL);
|
2006-08-14 10:42:45 -07:00
|
|
|
}
|
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
EAPI int
|
2006-04-01 01:24:56 -08:00
|
|
|
e_widget_preview_edje_set(Evas_Object *obj, const char *file, const char *group)
|
2006-03-03 20:11:51 -08:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
int ret;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
if (wd->o_thumb) evas_object_del(wd->o_thumb);
|
|
|
|
wd->o_thumb = edje_object_add(e_livethumb_evas_get(wd->img));
|
|
|
|
ret = edje_object_file_set(wd->o_thumb, file, group);
|
|
|
|
evas_object_show(wd->o_thumb);
|
|
|
|
e_livethumb_thumb_set(wd->img, wd->o_thumb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_wid_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2008-03-24 19:20:32 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
2010-06-19 15:59:02 -07:00
|
|
|
E_FREE(wd);
|
2006-03-03 20:11:51 -08:00
|
|
|
}
|