2012-06-17 09:32:23 -07:00
|
|
|
#include "private.h"
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
#include <Elementary.h>
|
2013-02-01 06:10:51 -08:00
|
|
|
#include <Ethumb_Client.h>
|
2012-06-17 00:10:27 -07:00
|
|
|
#include <Emotion.h>
|
2013-03-20 04:20:50 -07:00
|
|
|
#include <Efreet.h>
|
2012-08-08 06:15:54 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2012-06-17 00:10:27 -07:00
|
|
|
#include "media.h"
|
2012-06-16 21:10:17 -07:00
|
|
|
#include "config.h"
|
2020-06-23 03:48:27 -07:00
|
|
|
#include "theme.h"
|
2019-09-15 08:47:07 -07:00
|
|
|
#include "termiolink.h"
|
2012-06-16 21:10:17 -07:00
|
|
|
|
|
|
|
typedef struct _Media Media;
|
|
|
|
|
|
|
|
struct _Media
|
|
|
|
{
|
|
|
|
Evas_Object_Smart_Clipped_Data __clipped_data;
|
2013-02-18 07:31:54 -08:00
|
|
|
Evas_Object *clip, *o_img, *o_tmp, *o_ctrl, *o_busy, *o_event;
|
2012-06-16 22:41:02 -07:00
|
|
|
Ecore_Timer *anim;
|
2012-07-05 20:24:43 -07:00
|
|
|
Ecore_Timer *smooth_timer;
|
2012-06-17 00:10:27 -07:00
|
|
|
Ecore_Job *restart_job;
|
2012-08-08 06:15:54 -07:00
|
|
|
Ecore_Con_Url *url;
|
|
|
|
Ecore_Event_Handler *url_prog_hand, *url_compl_hand;
|
2013-02-01 06:10:51 -08:00
|
|
|
Ethumb_Client_Async *et_req;
|
2012-06-16 22:19:21 -07:00
|
|
|
const char *src;
|
2012-08-08 06:15:54 -07:00
|
|
|
const char *ext;
|
|
|
|
const char *realf;
|
2012-06-17 13:24:23 -07:00
|
|
|
const Config *config;
|
2012-08-08 06:15:54 -07:00
|
|
|
double download_perc;
|
|
|
|
int tmpfd;
|
2012-07-05 20:24:43 -07:00
|
|
|
int w, h;
|
2012-06-16 22:19:21 -07:00
|
|
|
int iw, ih;
|
2012-06-16 23:01:14 -07:00
|
|
|
int sw, sh;
|
2013-07-05 20:53:46 -07:00
|
|
|
int fr, frnum, loops;
|
2014-10-08 15:12:34 -07:00
|
|
|
int mode;
|
|
|
|
Media_Type type;
|
2012-07-05 20:24:43 -07:00
|
|
|
int resizes;
|
2013-02-18 07:31:54 -08:00
|
|
|
struct {
|
|
|
|
Evas_Coord x, y;
|
2014-08-28 12:04:00 -07:00
|
|
|
unsigned char down : 1;
|
2013-02-18 07:31:54 -08:00
|
|
|
} down;
|
2014-08-28 12:04:00 -07:00
|
|
|
unsigned char nosmooth : 1;
|
|
|
|
unsigned char downloading : 1;
|
|
|
|
unsigned char queued : 1;
|
|
|
|
unsigned char pos_drag : 1;
|
2012-06-16 21:10:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static Evas_Smart *_smart = NULL;
|
2012-12-29 06:02:05 -08:00
|
|
|
static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
|
2012-06-16 21:10:17 -07:00
|
|
|
|
2013-01-29 07:54:47 -08:00
|
|
|
#include "extns.h"
|
2012-06-16 22:19:21 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
static const char *
|
2012-06-16 22:19:21 -07:00
|
|
|
_is_fmt(const char *f, const char **extn)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
int i;
|
|
|
|
size_t len;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
len = strlen(f);
|
|
|
|
for (i = 0; extn[i]; i++)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
size_t l = strlen(extn[i]);
|
|
|
|
if (len < l)
|
|
|
|
continue;
|
|
|
|
if (!strcasecmp(extn[i], f + len - l))
|
|
|
|
return extn[i];
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
2012-08-08 06:15:54 -07:00
|
|
|
return NULL;
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
2013-02-01 06:10:51 -08:00
|
|
|
//////////////////////// thumb
|
|
|
|
|
|
|
|
static Ethumb_Client *et_client = NULL;
|
|
|
|
static Eina_Bool et_connected = EINA_FALSE;
|
2013-05-11 20:16:09 -07:00
|
|
|
static Eina_List *et_queue = NULL;
|
2013-02-01 06:10:51 -08:00
|
|
|
|
|
|
|
static void _et_init(void);
|
2015-08-23 07:40:19 -07:00
|
|
|
static int _type_thumb_init2(Evas_Object *obj);
|
2013-02-01 06:10:51 -08:00
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_et_disconnect(void *_data EINA_UNUSED, Ethumb_Client *c)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
if (c != et_client) return;
|
|
|
|
ethumb_client_disconnect(et_client);
|
|
|
|
et_connected = EINA_FALSE;
|
|
|
|
et_client = NULL;
|
2013-07-03 16:39:43 -07:00
|
|
|
if (et_queue) _et_init();
|
2013-02-01 06:10:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_et_connect(void *_data EINA_UNUSED, Ethumb_Client *c, Eina_Bool ok)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
if (ok)
|
|
|
|
{
|
2013-05-11 20:16:09 -07:00
|
|
|
Evas_Object *o;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-02-01 06:10:51 -08:00
|
|
|
et_connected = EINA_TRUE;
|
|
|
|
ethumb_client_on_server_die_callback_set(c, _et_disconnect,
|
|
|
|
NULL, NULL);
|
2013-05-11 20:16:09 -07:00
|
|
|
EINA_LIST_FREE(et_queue, o)
|
|
|
|
_type_thumb_init2(o);
|
2013-02-01 06:10:51 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
et_client = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_et_init(void)
|
|
|
|
{
|
|
|
|
if (et_client) return;
|
|
|
|
|
|
|
|
ethumb_client_init();
|
|
|
|
et_client = ethumb_client_connect(_et_connect, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_type_thumb_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
|
|
|
|
{
|
|
|
|
w = 1;
|
|
|
|
h = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int iw = 1, ih = 1;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-02-01 06:10:51 -08:00
|
|
|
iw = w;
|
|
|
|
ih = (sd->ih * w) / sd->iw;
|
|
|
|
if (ih > h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = (sd->iw * h) / sd->ih;
|
|
|
|
if (iw > w) iw = w;
|
|
|
|
}
|
|
|
|
if ((iw > sd->iw) || (ih > sd->ih))
|
|
|
|
{
|
|
|
|
iw = sd->iw;
|
|
|
|
ih = sd->ih;
|
|
|
|
}
|
|
|
|
x += ((w - iw) / 2);
|
|
|
|
y += ((h - ih) / 2);
|
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
}
|
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
|
|
evas_object_resize(sd->o_img, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_thumb_preloaded(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
|
|
|
|
_type_thumb_calc(data, ox, oy, ow, oh);
|
|
|
|
evas_object_show(sd->o_img);
|
|
|
|
evas_object_show(sd->clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_et_done(Ethumb_Client *_c EINA_UNUSED,
|
|
|
|
const char *file, const char *key, void *data)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-08-27 01:18:17 -07:00
|
|
|
// if (c != et_client) return;
|
2013-02-01 06:10:51 -08:00
|
|
|
sd->et_req = NULL;
|
|
|
|
evas_object_event_callback_add(sd->o_img, EVAS_CALLBACK_IMAGE_PRELOADED,
|
|
|
|
_cb_thumb_preloaded, obj);
|
|
|
|
evas_object_image_file_set(sd->o_img, file, key);
|
|
|
|
evas_object_image_size_get(sd->o_img, &(sd->iw), &(sd->ih));
|
|
|
|
evas_object_image_preload(sd->o_img, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_et_error(Ethumb_Client *_c EINA_UNUSED, void *data)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
2013-08-27 01:18:17 -07:00
|
|
|
// if (c != et_client) return;
|
2013-02-01 06:10:51 -08:00
|
|
|
sd->et_req = NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2013-05-11 20:16:09 -07:00
|
|
|
_type_thumb_init2(Evas_Object *obj)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
Eina_Bool ok;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
2013-05-11 20:16:09 -07:00
|
|
|
|
2013-03-11 04:44:27 -07:00
|
|
|
if ((sd->realf) && (sd->realf[0] != '/'))
|
|
|
|
{
|
2013-03-20 04:21:15 -07:00
|
|
|
/* TODO: Listen for theme cache changes */
|
|
|
|
static const char *icon_theme = NULL;
|
2016-10-09 08:17:57 -07:00
|
|
|
const char *fl = NULL;
|
2013-03-20 04:21:15 -07:00
|
|
|
|
|
|
|
if (!icon_theme)
|
2013-03-11 04:44:27 -07:00
|
|
|
{
|
2013-03-20 04:21:15 -07:00
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
|
|
|
theme = efreet_icon_theme_find(getenv("E_ICON_THEME"));
|
|
|
|
if (!theme)
|
2013-03-11 04:44:27 -07:00
|
|
|
{
|
2013-03-20 04:21:15 -07:00
|
|
|
const char **itr;
|
|
|
|
static const char *themes[] = {
|
|
|
|
"Human", "oxygen", "gnome", "hicolor", NULL
|
|
|
|
};
|
|
|
|
for (itr = themes; *itr; itr++)
|
|
|
|
{
|
|
|
|
theme = efreet_icon_theme_find(*itr);
|
2016-10-09 08:17:57 -07:00
|
|
|
if (!theme) continue;
|
2020-07-05 11:19:59 -07:00
|
|
|
//try to fetch the icon, if we don't find it, continue at other themes
|
2016-10-09 08:17:57 -07:00
|
|
|
icon_theme = eina_stringshare_add(theme->name.internal);
|
|
|
|
fl = efreet_icon_path_find(icon_theme, sd->realf, sd->iw);
|
2016-10-09 08:46:32 -07:00
|
|
|
if (fl) break;
|
2013-03-20 04:21:15 -07:00
|
|
|
}
|
2013-03-11 04:44:27 -07:00
|
|
|
}
|
2016-10-09 08:17:57 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
icon_theme = eina_stringshare_add(theme->name.internal);
|
|
|
|
}
|
2013-03-11 04:44:27 -07:00
|
|
|
}
|
2016-10-09 08:17:57 -07:00
|
|
|
if (!fl)
|
|
|
|
fl = efreet_icon_path_find(icon_theme, sd->realf, sd->iw);
|
2015-08-23 07:40:19 -07:00
|
|
|
ok = ethumb_client_file_set(et_client, fl, NULL);
|
|
|
|
if (!ok)
|
|
|
|
return -1;
|
2013-03-11 04:44:27 -07:00
|
|
|
}
|
|
|
|
else
|
2015-08-23 07:40:19 -07:00
|
|
|
{
|
|
|
|
ok = ethumb_client_file_set(et_client, sd->realf, NULL);
|
|
|
|
if (!ok)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-02-01 06:10:51 -08:00
|
|
|
sd->et_req = ethumb_client_thumb_async_get(et_client, _et_done,
|
|
|
|
_et_error, obj);
|
2013-05-11 20:16:09 -07:00
|
|
|
sd->queued = EINA_FALSE;
|
2015-08-23 07:40:19 -07:00
|
|
|
return 0;
|
2013-05-11 20:16:09 -07:00
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2013-05-11 20:16:09 -07:00
|
|
|
_type_thumb_init(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
2014-10-08 15:12:34 -07:00
|
|
|
sd->type = MEDIA_TYPE_THUMB;
|
2013-05-11 20:16:09 -07:00
|
|
|
_et_init();
|
|
|
|
o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
2014-06-29 04:42:08 -07:00
|
|
|
evas_object_image_load_orientation_set(o, EINA_TRUE);
|
2013-05-11 20:16:09 -07:00
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
|
|
|
evas_object_raise(sd->o_event);
|
|
|
|
sd->iw = 64;
|
|
|
|
sd->ih = 64;
|
|
|
|
if (!et_connected)
|
|
|
|
{
|
|
|
|
et_queue = eina_list_append(et_queue, obj);
|
|
|
|
sd->queued = EINA_TRUE;
|
2015-08-23 07:40:19 -07:00
|
|
|
return 0;
|
2013-05-11 20:16:09 -07:00
|
|
|
}
|
2015-08-23 07:40:19 -07:00
|
|
|
return _type_thumb_init2(obj);
|
2013-02-01 06:10:51 -08:00
|
|
|
}
|
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
//////////////////////// img
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_img_preloaded(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-16 22:19:21 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_show(sd->o_img);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_show(sd->clip);
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
2012-06-16 22:41:02 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_cb_img_frame(void *data)
|
|
|
|
{
|
|
|
|
double t;
|
|
|
|
int fr;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
sd->fr++;
|
|
|
|
fr = ((sd->fr - 1) % (sd->frnum)) + 1;
|
2013-07-05 20:53:46 -07:00
|
|
|
if ((sd->fr >= sd->frnum) && (fr == 1))
|
|
|
|
{
|
|
|
|
int loops;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-07-05 20:53:46 -07:00
|
|
|
if (evas_object_image_animated_loop_type_get(sd->o_img) ==
|
|
|
|
EVAS_IMAGE_ANIMATED_HINT_NONE)
|
|
|
|
{
|
|
|
|
sd->anim = NULL;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
sd->loops++;
|
|
|
|
loops = evas_object_image_animated_loop_count_get(sd->o_img);
|
|
|
|
if (loops != 0) // loop == 0 -> loop forever
|
|
|
|
{
|
|
|
|
if (loops < sd->loops)
|
|
|
|
{
|
|
|
|
sd->anim = NULL;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-16 22:41:02 -07:00
|
|
|
evas_object_image_animated_frame_set(sd->o_img, fr);
|
|
|
|
t = evas_object_image_animated_frame_duration_get(sd->o_img, fr, 0);
|
|
|
|
ecore_timer_interval_set(sd->anim, t);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2012-06-16 22:41:02 -07:00
|
|
|
_type_img_anim_handle(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
double t;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
|
|
|
if (!evas_object_image_animated_get(sd->o_img))
|
2015-09-04 11:30:29 -07:00
|
|
|
return 0;
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2012-06-16 22:41:02 -07:00
|
|
|
sd->fr = 1;
|
|
|
|
sd->frnum = evas_object_image_animated_frame_count_get(sd->o_img);
|
2015-08-23 07:40:19 -07:00
|
|
|
if (sd->frnum < 2)
|
|
|
|
return 0;
|
|
|
|
|
2012-06-16 22:41:02 -07:00
|
|
|
t = evas_object_image_animated_frame_duration_get(sd->o_img, sd->fr, 0);
|
|
|
|
sd->anim = ecore_timer_add(t, _cb_img_frame, obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
return 0;
|
2012-06-16 22:41:02 -07:00
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2012-06-16 22:19:21 -07:00
|
|
|
_type_img_init(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_IMAGE_PRELOADED,
|
|
|
|
_cb_img_preloaded, obj);
|
2014-06-24 12:41:40 -07:00
|
|
|
evas_object_image_load_orientation_set(o, EINA_TRUE);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_image_file_set(o, sd->realf, NULL);
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_image_size_get(o, &(sd->iw), &(sd->ih));
|
|
|
|
evas_object_image_preload(o, EINA_FALSE);
|
2015-08-23 07:40:19 -07:00
|
|
|
return _type_img_anim_handle(obj);
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_type_img_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
|
|
|
|
{
|
|
|
|
w = 1;
|
|
|
|
h = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 02:38:43 -07:00
|
|
|
int iw = 1, ih = 1;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-01-28 08:06:26 -08:00
|
|
|
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
|
2012-06-16 22:19:21 -07:00
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
iw = w;
|
|
|
|
ih = (sd->ih * w) / sd->iw;
|
|
|
|
if (ih < h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = (sd->iw * h) / sd->ih;
|
|
|
|
if (iw < w) iw = w;
|
|
|
|
}
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_POP)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = (sd->ih * w) / sd->iw;
|
|
|
|
if (ih > h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = (sd->iw * h) / sd->ih;
|
|
|
|
if (iw > w) iw = w;
|
|
|
|
}
|
|
|
|
if ((iw > sd->iw) || (ih > sd->ih))
|
|
|
|
{
|
|
|
|
iw = sd->iw;
|
|
|
|
ih = sd->ih;
|
|
|
|
}
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_STRETCH)
|
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = h;
|
|
|
|
}
|
2012-06-16 22:19:21 -07:00
|
|
|
x += ((w - iw) / 2);
|
|
|
|
y += ((h - ih) / 2);
|
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
}
|
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
|
|
evas_object_resize(sd->o_img, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////// scalable img
|
2012-06-16 23:01:14 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_scale_preloaded(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-16 23:01:14 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-08-08 06:15:54 -07:00
|
|
|
if (!sd->o_tmp)
|
|
|
|
{
|
|
|
|
evas_object_show(sd->o_img);
|
|
|
|
evas_object_show(sd->clip);
|
|
|
|
}
|
2012-06-16 23:01:14 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_del(sd->o_img);
|
|
|
|
sd->o_img = sd->o_tmp;
|
|
|
|
sd->o_tmp = NULL;
|
|
|
|
evas_object_show(sd->o_img);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_show(sd->clip);
|
2012-06-16 23:01:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2012-06-16 22:19:21 -07:00
|
|
|
_type_scale_init(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-06-16 23:01:14 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_IMAGE_PRELOADED,
|
|
|
|
_cb_scale_preloaded, obj);
|
2014-06-29 04:42:08 -07:00
|
|
|
evas_object_image_load_orientation_set(o, EINA_TRUE);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_image_file_set(o, sd->realf, NULL);
|
2012-06-16 23:01:14 -07:00
|
|
|
evas_object_image_size_get(o, &(sd->iw), &(sd->ih));
|
|
|
|
evas_object_image_preload(o, EINA_FALSE);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
return 0;
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
2012-06-16 23:01:14 -07:00
|
|
|
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
|
|
|
|
{
|
|
|
|
w = 1;
|
|
|
|
h = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 02:38:43 -07:00
|
|
|
int iw = 1, ih = 1;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-01-28 08:06:26 -08:00
|
|
|
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = (sd->ih * w) / sd->iw;
|
|
|
|
if (ih < h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = (sd->iw * h) / sd->ih;
|
|
|
|
if (iw < w) iw = w;
|
|
|
|
}
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_POP)
|
2012-06-16 23:01:14 -07:00
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
iw = w;
|
|
|
|
ih = (sd->ih * w) / sd->iw;
|
|
|
|
if (ih > h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = (sd->iw * h) / sd->ih;
|
|
|
|
if (iw > w) iw = w;
|
|
|
|
}
|
2012-06-16 23:01:14 -07:00
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_STRETCH)
|
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = h;
|
|
|
|
}
|
2012-06-16 23:01:14 -07:00
|
|
|
x += ((w - iw) / 2);
|
|
|
|
y += ((h - ih) / 2);
|
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
}
|
2012-07-05 20:24:43 -07:00
|
|
|
if (!sd->nosmooth)
|
2012-06-16 23:01:14 -07:00
|
|
|
{
|
2012-07-05 20:24:43 -07:00
|
|
|
Evas_Coord lw, lh;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-07-05 20:24:43 -07:00
|
|
|
lw = w;
|
|
|
|
lh = h;
|
|
|
|
if (lw < 256) lw = 256;
|
|
|
|
if (lh < 256) lh = 256;
|
|
|
|
if ((lw != sd->sw) || (lh != sd->sh))
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
|
2012-07-05 20:24:43 -07:00
|
|
|
o = sd->o_tmp = evas_object_image_filled_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-07-05 20:24:43 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_IMAGE_PRELOADED,
|
|
|
|
_cb_scale_preloaded, obj);
|
2014-06-29 04:42:08 -07:00
|
|
|
evas_object_image_load_orientation_set(o, EINA_TRUE);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_image_file_set(o, sd->realf, NULL);
|
2012-07-05 20:24:43 -07:00
|
|
|
evas_object_image_load_size_set(sd->o_tmp, lw, lh);
|
|
|
|
evas_object_image_preload(o, EINA_FALSE);
|
|
|
|
}
|
|
|
|
sd->sw = lw;
|
|
|
|
sd->sh = lh;
|
2012-06-16 23:01:14 -07:00
|
|
|
}
|
|
|
|
if (sd->o_tmp)
|
|
|
|
{
|
|
|
|
evas_object_move(sd->o_tmp, x, y);
|
|
|
|
evas_object_resize(sd->o_tmp, w, h);
|
|
|
|
}
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
|
|
evas_object_resize(sd->o_img, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////// edj
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_edje_preloaded(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_sig EINA_UNUSED,
|
|
|
|
const char *_src EINA_UNUSED)
|
2012-06-16 22:19:21 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_show(sd->o_img);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_show(sd->clip);
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2012-06-16 22:19:21 -07:00
|
|
|
_type_edje_init(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
int i;
|
|
|
|
const char *groups[] =
|
|
|
|
{
|
2020-07-05 11:19:59 -07:00
|
|
|
"terminology/background",
|
2012-06-16 22:19:21 -07:00
|
|
|
"e/desktop/background",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
o = sd->o_img = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-06-16 22:19:21 -07:00
|
|
|
for (i = 0; groups[i]; i++)
|
|
|
|
{
|
2012-08-08 06:15:54 -07:00
|
|
|
if (edje_object_file_set(o, sd->realf, groups[i]))
|
2012-06-16 22:19:21 -07:00
|
|
|
{
|
|
|
|
edje_object_signal_callback_add(o, "preload,done", "",
|
|
|
|
_cb_edje_preloaded, obj);
|
|
|
|
edje_object_preload(o, EINA_FALSE);
|
2012-06-19 08:59:49 -07:00
|
|
|
theme_auto_reload_enable(o);
|
2015-08-23 07:40:19 -07:00
|
|
|
return 0;
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
}
|
2015-08-23 07:40:19 -07:00
|
|
|
return 0;
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_type_edje_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
|
|
evas_object_resize(sd->o_img, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////// movie
|
2012-06-17 00:10:27 -07:00
|
|
|
static void _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_frame_decode(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
2012-06-24 04:55:46 -07:00
|
|
|
double len, pos;
|
2012-06-17 00:10:27 -07:00
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
|
|
|
|
evas_object_show(sd->o_img);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_show(sd->clip);
|
2012-06-17 00:10:27 -07:00
|
|
|
_type_mov_calc(data, ox, oy, ow, oh);
|
2012-06-24 04:55:46 -07:00
|
|
|
|
2014-07-22 15:07:01 -07:00
|
|
|
if (sd->pos_drag) return;
|
2012-06-24 04:55:46 -07:00
|
|
|
len = emotion_object_play_length_get(sd->o_img);
|
|
|
|
pos = emotion_object_position_get(sd->o_img);
|
|
|
|
pos /= len;
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_drag_value_set(sd->o_ctrl, "terminology.posdrag", pos, pos);
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_frame_resize(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
|
|
|
|
_type_mov_calc(data, ox, oy, ow, oh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_len_change(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cb_mov_restart(void *data)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
sd->restart_job = NULL;
|
|
|
|
emotion_object_position_set(sd->o_img, 0.0);
|
|
|
|
emotion_object_play_set(sd->o_img, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_decode_stop(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
if (sd->restart_job) ecore_job_del(sd->restart_job);
|
|
|
|
sd->restart_job = ecore_job_add(_cb_mov_restart, data);
|
2012-12-25 06:47:54 -08:00
|
|
|
evas_object_smart_callback_call(data, "loop", NULL);
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_progress(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-17 09:32:23 -07:00
|
|
|
DBG("progress: '%s' '%3.3f",
|
|
|
|
emotion_object_progress_info_get(sd->o_img),
|
|
|
|
emotion_object_progress_status_get(sd->o_img));
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_mov_ref(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-17 09:32:23 -07:00
|
|
|
DBG("ref: '%s' num '%i'",
|
|
|
|
emotion_object_ref_file_get(sd->o_img),
|
|
|
|
emotion_object_ref_num_get(sd->o_img));
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
|
|
|
|
2012-06-24 02:49:23 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_play(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-24 02:49:23 -07:00
|
|
|
{
|
|
|
|
media_play_set(data, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_pause(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-24 02:49:23 -07:00
|
|
|
{
|
|
|
|
media_play_set(data, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_stop(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-24 02:49:23 -07:00
|
|
|
{
|
2012-06-26 12:07:47 -07:00
|
|
|
media_stop(data);
|
2012-06-24 02:49:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_vol(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-24 02:49:23 -07:00
|
|
|
{
|
|
|
|
double vx, vy;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_drag_value_get(sd->o_ctrl, "terminology.voldrag", &vx, &vy);
|
2012-06-24 02:49:23 -07:00
|
|
|
media_volume_set(data, vx + vy);
|
|
|
|
}
|
|
|
|
|
2014-07-22 15:07:01 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_pos_drag_start(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2014-07-22 15:07:01 -07:00
|
|
|
{
|
|
|
|
double vx, vy;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
sd->pos_drag = 1;
|
|
|
|
edje_object_part_drag_value_get(sd->o_ctrl, "terminology.posdrag", &vx, &vy);
|
|
|
|
media_position_set(data, vx + vy);
|
|
|
|
}
|
2016-10-05 13:00:22 -07:00
|
|
|
|
2014-07-22 15:07:01 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_pos_drag_stop(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2014-07-22 15:07:01 -07:00
|
|
|
{
|
|
|
|
double pos, len;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd || !sd->pos_drag) return;
|
|
|
|
sd->pos_drag = 0;
|
|
|
|
len = emotion_object_play_length_get(sd->o_img);
|
|
|
|
pos = emotion_object_position_get(sd->o_img);
|
|
|
|
pos /= len;
|
|
|
|
edje_object_part_drag_value_set(sd->o_ctrl, "terminology.posdrag", pos, pos);
|
|
|
|
}
|
2016-10-05 13:00:22 -07:00
|
|
|
|
2012-06-24 04:55:46 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_media_pos(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-24 04:55:46 -07:00
|
|
|
{
|
|
|
|
double vx, vy;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_drag_value_get(sd->o_ctrl, "terminology.posdrag", &vx, &vy);
|
2012-06-24 04:55:46 -07:00
|
|
|
media_position_set(data, vx + vy);
|
|
|
|
}
|
|
|
|
|
2015-08-23 07:40:19 -07:00
|
|
|
static int
|
2012-06-16 22:19:21 -07:00
|
|
|
_type_mov_init(Evas_Object *obj)
|
|
|
|
{
|
2012-06-17 00:10:27 -07:00
|
|
|
Evas_Object *o;
|
2012-06-24 02:49:23 -07:00
|
|
|
double vol;
|
2012-06-16 22:19:21 -07:00
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
|
|
|
|
|
2012-06-17 00:10:27 -07:00
|
|
|
emotion_init();
|
|
|
|
o = sd->o_img = emotion_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_callback_add(o, "frame_decode",
|
|
|
|
_cb_mov_frame_decode, obj);
|
|
|
|
evas_object_smart_callback_add(o, "frame_resize",
|
|
|
|
_cb_mov_frame_resize, obj);
|
|
|
|
evas_object_smart_callback_add(o, "length_change",
|
|
|
|
_cb_mov_len_change, obj);
|
|
|
|
evas_object_smart_callback_add(o, "decode_stop",
|
|
|
|
_cb_mov_decode_stop, obj);
|
|
|
|
evas_object_smart_callback_add(o, "progress_change",
|
|
|
|
_cb_mov_progress, obj);
|
|
|
|
evas_object_smart_callback_add(o, "ref_change",
|
|
|
|
_cb_mov_ref, obj);
|
2012-08-08 06:15:54 -07:00
|
|
|
emotion_object_file_set(o, sd->realf);
|
2013-01-28 08:06:26 -08:00
|
|
|
if (((sd->mode & MEDIA_OPTIONS_MASK) & MEDIA_RECOVER)
|
2014-10-08 15:12:34 -07:00
|
|
|
&& (sd->type == MEDIA_TYPE_MOV) && (sd->o_img))
|
2013-01-28 08:06:26 -08:00
|
|
|
emotion_object_last_position_load(sd->o_img);
|
2014-04-24 02:10:28 -07:00
|
|
|
else
|
|
|
|
media_position_set(obj, 0.0);
|
2012-06-17 00:10:27 -07:00
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_clip_set(o, sd->clip);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-06-24 02:49:23 -07:00
|
|
|
|
|
|
|
o = sd->o_ctrl = edje_object_add(evas_object_evas_get(obj));
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(o, sd->config, "terminology/mediactrl",
|
|
|
|
NULL, NULL, EINA_FALSE);
|
2012-06-24 02:49:23 -07:00
|
|
|
vol = emotion_object_audio_volume_get(sd->o_img);
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_drag_value_set(o, "terminology.voldrag", vol, vol);
|
|
|
|
edje_object_signal_callback_add(o, "play", "",
|
|
|
|
_cb_media_play, obj);
|
|
|
|
edje_object_signal_callback_add(o, "pause", "",
|
|
|
|
_cb_media_pause, obj);
|
|
|
|
edje_object_signal_callback_add(o, "stop", "",
|
|
|
|
_cb_media_stop, obj);
|
2014-07-22 15:07:01 -07:00
|
|
|
edje_object_signal_callback_add(o, "pos,drag,start", "",
|
|
|
|
_cb_media_pos_drag_start, obj);
|
|
|
|
edje_object_signal_callback_add(o, "pos,drag,stop", "",
|
|
|
|
_cb_media_pos_drag_stop, obj);
|
|
|
|
edje_object_signal_callback_add(o, "pos,drag", "",
|
2012-06-24 04:55:46 -07:00
|
|
|
_cb_media_pos, obj);
|
2014-07-22 15:07:01 -07:00
|
|
|
edje_object_signal_callback_add(o, "vol,drag", "",
|
2012-06-24 04:55:46 -07:00
|
|
|
_cb_media_vol, obj);
|
2014-07-26 07:51:14 -07:00
|
|
|
evas_object_clip_set(o, sd->clip);
|
2012-06-24 02:49:23 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
media_play_set(obj, EINA_TRUE);
|
2015-08-23 07:40:19 -07:00
|
|
|
if (sd->config->mute)
|
|
|
|
media_mute_set(obj, EINA_TRUE);
|
|
|
|
if (sd->config->visualize)
|
|
|
|
media_visualize_set(obj, EINA_TRUE);
|
|
|
|
|
|
|
|
return 0;
|
2012-06-16 22:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
2012-06-24 02:49:23 -07:00
|
|
|
|
|
|
|
evas_object_move(sd->o_ctrl, x, y);
|
|
|
|
evas_object_resize(sd->o_ctrl, w, h);
|
|
|
|
|
2012-06-17 00:10:27 -07:00
|
|
|
emotion_object_size_get(sd->o_img, &(sd->iw), &(sd->ih));
|
|
|
|
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
|
|
|
|
{
|
|
|
|
w = 1;
|
|
|
|
h = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-05 02:38:43 -07:00
|
|
|
int iw = 1, ih = 1;
|
2012-06-17 00:10:27 -07:00
|
|
|
double ratio;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-06-17 00:10:27 -07:00
|
|
|
ratio = emotion_object_ratio_get(sd->o_img);
|
|
|
|
if (ratio > 0.0) sd->iw = (sd->ih * ratio) + 0.5;
|
|
|
|
else ratio = (double)sd->iw / (double)sd->ih;
|
2012-07-04 07:44:43 -07:00
|
|
|
|
2013-01-28 08:06:26 -08:00
|
|
|
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
iw = w;
|
|
|
|
ih = w / ratio;
|
|
|
|
if (ih < h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = h * ratio;
|
|
|
|
if (iw < w) iw = w;
|
|
|
|
}
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_POP)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = w / ratio;
|
|
|
|
if (ih > h)
|
|
|
|
{
|
|
|
|
ih = h;
|
|
|
|
iw = h * ratio;
|
|
|
|
if (iw > w) iw = w;
|
|
|
|
}
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_STRETCH)
|
|
|
|
{
|
|
|
|
iw = w;
|
|
|
|
ih = h;
|
|
|
|
}
|
2012-06-17 00:10:27 -07:00
|
|
|
x += ((w - iw) / 2);
|
|
|
|
y += ((h - ih) / 2);
|
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
}
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_move(sd->o_img, x, y);
|
|
|
|
evas_object_resize(sd->o_img, w, h);
|
|
|
|
}
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
static void _smart_calculate(Evas_Object *obj);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd;
|
|
|
|
Evas_Object *o;
|
2012-06-17 10:04:17 -07:00
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
sd = calloc(1, sizeof(Media));
|
2012-12-29 05:59:41 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-06-16 21:10:17 -07:00
|
|
|
evas_object_smart_data_set(obj, sd);
|
2012-12-29 05:59:41 -08:00
|
|
|
|
2012-12-29 06:02:05 -08:00
|
|
|
_parent_sc.add(obj);
|
2012-12-29 05:59:41 -08:00
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
2012-06-16 22:19:21 -07:00
|
|
|
sd->clip = o;
|
|
|
|
evas_object_color_set(o, 255, 255, 255, 255);
|
2012-06-16 21:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
2013-01-28 08:06:26 -08:00
|
|
|
if (((sd->mode & MEDIA_OPTIONS_MASK) & MEDIA_SAVE)
|
2014-10-08 15:12:34 -07:00
|
|
|
&& (sd->type == MEDIA_TYPE_MOV) && (sd->o_img))
|
2013-01-28 08:06:26 -08:00
|
|
|
emotion_object_last_position_save(sd->o_img);
|
2012-08-08 06:15:54 -07:00
|
|
|
if (sd->url)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(sd->url_prog_hand);
|
|
|
|
ecore_event_handler_del(sd->url_compl_hand);
|
|
|
|
ecore_con_url_free(sd->url);
|
|
|
|
}
|
|
|
|
sd->url = NULL;
|
|
|
|
sd->url_prog_hand = NULL;
|
|
|
|
sd->url_compl_hand = NULL;
|
|
|
|
if (sd->tmpfd >= 0)
|
|
|
|
{
|
2012-10-17 01:07:49 -07:00
|
|
|
if (sd->realf) unlink(sd->realf);
|
2012-08-08 06:15:54 -07:00
|
|
|
close(sd->tmpfd);
|
|
|
|
}
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->src);
|
|
|
|
eina_stringshare_del(sd->realf);
|
2012-06-16 22:19:21 -07:00
|
|
|
if (sd->clip) evas_object_del(sd->clip);
|
|
|
|
if (sd->o_img) evas_object_del(sd->o_img);
|
2012-06-16 23:01:14 -07:00
|
|
|
if (sd->o_tmp) evas_object_del(sd->o_tmp);
|
2012-06-24 02:49:23 -07:00
|
|
|
if (sd->o_ctrl) evas_object_del(sd->o_ctrl);
|
2012-08-08 06:15:54 -07:00
|
|
|
if (sd->o_busy) evas_object_del(sd->o_busy);
|
2013-02-18 07:31:54 -08:00
|
|
|
if (sd->o_event) evas_object_del(sd->o_event);
|
2012-06-16 22:41:02 -07:00
|
|
|
if (sd->anim) ecore_timer_del(sd->anim);
|
2012-07-05 20:24:43 -07:00
|
|
|
if (sd->smooth_timer) sd->smooth_timer = ecore_timer_del(sd->smooth_timer);
|
2012-06-17 00:10:27 -07:00
|
|
|
if (sd->restart_job) ecore_job_del(sd->restart_job);
|
2013-02-01 06:10:51 -08:00
|
|
|
if ((et_client) && (sd->et_req))
|
|
|
|
ethumb_client_thumb_async_cancel(et_client, sd->et_req);
|
2013-05-11 20:16:09 -07:00
|
|
|
if (sd->queued) et_queue = eina_list_remove(et_queue, obj);
|
2013-02-01 06:10:51 -08:00
|
|
|
sd->et_req = NULL;
|
2012-12-29 05:59:41 -08:00
|
|
|
|
2012-12-29 06:02:05 -08:00
|
|
|
_parent_sc.del(obj);
|
2021-03-18 04:21:38 -07:00
|
|
|
free(sd);
|
2012-06-16 21:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2012-06-16 22:19:21 -07:00
|
|
|
Evas_Coord ox, oy, ow, oh;
|
2012-06-16 21:10:17 -07:00
|
|
|
if (!sd) return;
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
2012-06-16 21:10:17 -07:00
|
|
|
if ((ow == w) && (oh == h)) return;
|
|
|
|
evas_object_smart_changed(obj);
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_resize(sd->clip, ow, oh);
|
2012-06-16 21:10:17 -07:00
|
|
|
}
|
|
|
|
|
2012-07-05 20:24:43 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_unsmooth_timeout(void *data)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
|
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
|
|
|
|
sd->smooth_timer = NULL;
|
|
|
|
sd->nosmooth = EINA_FALSE;
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((sd->type == MEDIA_TYPE_IMG) || (sd->type == MEDIA_TYPE_SCALE))
|
2012-07-05 20:24:43 -07:00
|
|
|
{
|
|
|
|
evas_object_image_smooth_scale_set(sd->o_img, !sd->nosmooth);
|
|
|
|
if (sd->o_tmp)
|
|
|
|
evas_object_image_smooth_scale_set(sd->o_tmp, !sd->nosmooth);
|
2014-10-08 15:12:34 -07:00
|
|
|
if (sd->type == MEDIA_TYPE_SCALE) _type_scale_calc(data, ox, oy, ow, oh);
|
2012-07-05 20:24:43 -07:00
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else if (sd->type == MEDIA_TYPE_MOV)
|
2012-07-05 20:24:43 -07:00
|
|
|
emotion_object_smooth_scale_set(sd->o_img, !sd->nosmooth);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smooth_handler(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2012-07-27 17:23:10 -07:00
|
|
|
double interval;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-07-05 20:24:43 -07:00
|
|
|
if (!sd) return;
|
|
|
|
interval = ecore_animator_frametime_get();
|
|
|
|
if (interval <= 0.0) interval = 1.0/60.0;
|
|
|
|
if (!sd->nosmooth)
|
|
|
|
{
|
|
|
|
if (sd->resizes >= 2)
|
|
|
|
{
|
|
|
|
sd->nosmooth = EINA_TRUE;
|
|
|
|
sd->resizes = 0;
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((sd->type == MEDIA_TYPE_IMG) || (sd->type == MEDIA_TYPE_SCALE))
|
2012-07-05 20:24:43 -07:00
|
|
|
{
|
|
|
|
evas_object_image_smooth_scale_set(sd->o_img, !sd->nosmooth);
|
|
|
|
if (sd->o_tmp)
|
|
|
|
evas_object_image_smooth_scale_set(sd->o_tmp, !sd->nosmooth);
|
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else if (sd->type == MEDIA_TYPE_MOV)
|
2012-07-05 20:24:43 -07:00
|
|
|
emotion_object_smooth_scale_set(sd->o_img, !sd->nosmooth);
|
|
|
|
if (sd->smooth_timer)
|
|
|
|
sd->smooth_timer = ecore_timer_del(sd->smooth_timer);
|
|
|
|
sd->smooth_timer = ecore_timer_add(interval * 10,
|
|
|
|
_unsmooth_timeout, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->smooth_timer)
|
|
|
|
sd->smooth_timer = ecore_timer_del(sd->smooth_timer);
|
|
|
|
sd->smooth_timer = ecore_timer_add(interval * 10,
|
|
|
|
_unsmooth_timeout, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
static void
|
|
|
|
_smart_calculate(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
2012-07-05 20:24:43 -07:00
|
|
|
if ((ow != sd->w) || (oh != sd->h)) sd->resizes++;
|
|
|
|
else sd->resizes = 0;
|
|
|
|
_smooth_handler(obj);
|
|
|
|
sd->w = ow;
|
|
|
|
sd->h = oh;
|
2014-10-08 15:12:34 -07:00
|
|
|
switch (sd->type)
|
|
|
|
{
|
|
|
|
case MEDIA_TYPE_IMG: _type_img_calc(obj, ox, oy, ow, oh); break;
|
|
|
|
case MEDIA_TYPE_SCALE: _type_scale_calc(obj, ox, oy, ow, oh); break;
|
|
|
|
case MEDIA_TYPE_EDJE: _type_edje_calc(obj, ox, oy, ow, oh); break;
|
|
|
|
case MEDIA_TYPE_MOV: _type_mov_calc(obj, ox, oy, ow, oh); break;
|
|
|
|
case MEDIA_TYPE_THUMB: _type_thumb_calc(obj, ox, oy, ow, oh); break;
|
|
|
|
case MEDIA_TYPE_UNKNOWN:
|
|
|
|
return;
|
|
|
|
}
|
2012-06-16 22:19:21 -07:00
|
|
|
evas_object_move(sd->clip, ox, oy);
|
|
|
|
evas_object_resize(sd->clip, ow, oh);
|
2012-08-08 06:15:54 -07:00
|
|
|
if (sd->o_busy)
|
|
|
|
{
|
|
|
|
evas_object_move(sd->o_busy, ox, oy);
|
|
|
|
evas_object_resize(sd->o_busy, ow, oh);
|
|
|
|
}
|
2013-02-18 07:31:54 -08:00
|
|
|
if (sd->o_event)
|
|
|
|
{
|
|
|
|
evas_object_move(sd->o_event, ox, oy);
|
|
|
|
evas_object_resize(sd->o_event, ow, oh);
|
|
|
|
}
|
2012-06-16 21:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_move(Evas_Object *obj,
|
|
|
|
Evas_Coord _x EINA_UNUSED,
|
|
|
|
Evas_Coord _y EINA_UNUSED)
|
2012-06-16 21:10:17 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_smart_changed(obj);
|
|
|
|
}
|
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
static Eina_Bool
|
2016-10-05 13:00:22 -07:00
|
|
|
_url_prog_cb(void *data,
|
|
|
|
int _type EINA_UNUSED,
|
|
|
|
void *event_info)
|
2012-08-08 06:15:54 -07:00
|
|
|
{
|
|
|
|
Ecore_Con_Event_Url_Progress *ev = event_info;
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return EINA_TRUE;
|
|
|
|
if (ev->url_con != sd->url) return EINA_TRUE;
|
|
|
|
if (ev->down.total > 0.0)
|
|
|
|
{
|
|
|
|
double perc;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
if (!sd->downloading)
|
|
|
|
edje_object_signal_emit(sd->o_busy, "downloading", "terminology");
|
|
|
|
sd->downloading = EINA_TRUE;
|
|
|
|
perc = ev->down.now / ev->down.total;
|
|
|
|
if (perc != sd->download_perc)
|
|
|
|
{
|
|
|
|
Edje_Message_Float msg;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
sd->download_perc = perc;
|
|
|
|
msg.val = perc;
|
|
|
|
edje_object_message_send(sd->o_busy, EDJE_MESSAGE_FLOAT, 1, &msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-10-05 13:00:22 -07:00
|
|
|
_url_compl_cb(void *data,
|
|
|
|
int _type EINA_UNUSED,
|
|
|
|
void *event_info)
|
2012-08-08 06:15:54 -07:00
|
|
|
{
|
|
|
|
Ecore_Con_Event_Url_Complete *ev = event_info;
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return EINA_TRUE;
|
|
|
|
if (ev->url_con != sd->url) return EINA_TRUE;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
|
|
|
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->o_busy, "done", "terminology");
|
2012-08-08 06:15:54 -07:00
|
|
|
ecore_event_handler_del(sd->url_prog_hand);
|
|
|
|
ecore_event_handler_del(sd->url_compl_hand);
|
|
|
|
ecore_con_url_free(sd->url);
|
|
|
|
sd->url = NULL;
|
|
|
|
sd->url_prog_hand = NULL;
|
|
|
|
sd->url_compl_hand = NULL;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
|
|
|
switch (sd->type)
|
|
|
|
{
|
|
|
|
case MEDIA_TYPE_IMG:
|
|
|
|
_type_img_init(obj);
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_SCALE:
|
|
|
|
_type_scale_init(obj);
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_EDJE:
|
|
|
|
_type_edje_init(obj);
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_MOV:
|
|
|
|
_type_mov_init(obj);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_raise(sd->o_busy);
|
2013-02-18 07:31:54 -08:00
|
|
|
evas_object_raise(sd->o_event);
|
2012-08-08 06:15:54 -07:00
|
|
|
_smart_calculate(obj);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_mouse_down_cb(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2013-02-18 07:31:54 -08:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
if (sd->down.down) return;
|
|
|
|
if (ev->button != 1) return;
|
|
|
|
sd->down.x = ev->canvas.x;
|
|
|
|
sd->down.y = ev->canvas.y;
|
|
|
|
sd->down.down = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_mouse_up_cb(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2013-02-18 07:31:54 -08:00
|
|
|
{
|
2015-03-30 12:21:18 -07:00
|
|
|
Evas_Event_Mouse_Up *ev = event;
|
2013-02-18 07:31:54 -08:00
|
|
|
Media *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
if (!sd) return;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
if (!sd->down.down) return;
|
|
|
|
sd->down.down = EINA_FALSE;
|
|
|
|
dx = abs(ev->canvas.x - sd->down.x);
|
|
|
|
dy = abs(ev->canvas.y - sd->down.y);
|
|
|
|
if ((dx <= elm_config_finger_size_get()) &&
|
|
|
|
(dy <= elm_config_finger_size_get()))
|
|
|
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
static void
|
|
|
|
_smart_init(void)
|
|
|
|
{
|
|
|
|
static Evas_Smart_Class sc;
|
|
|
|
|
2012-12-29 06:02:05 -08:00
|
|
|
evas_object_smart_clipped_smart_set(&_parent_sc);
|
|
|
|
sc = _parent_sc;
|
2012-06-16 21:10:17 -07:00
|
|
|
sc.name = "media";
|
|
|
|
sc.version = EVAS_SMART_CLASS_VERSION;
|
|
|
|
sc.add = _smart_add;
|
|
|
|
sc.del = _smart_del;
|
|
|
|
sc.resize = _smart_resize;
|
|
|
|
sc.move = _smart_move;
|
|
|
|
sc.calculate = _smart_calculate;
|
|
|
|
_smart = evas_smart_class_new(&sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Object *
|
2014-10-08 15:12:34 -07:00
|
|
|
media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
|
|
|
|
Media_Type type)
|
2012-06-16 21:10:17 -07:00
|
|
|
{
|
|
|
|
Evas *e;
|
2014-09-02 12:18:24 -07:00
|
|
|
Evas_Object *obj = NULL;
|
|
|
|
Media *sd = NULL;
|
2012-06-16 21:10:17 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
e = evas_object_evas_get(parent);
|
2015-09-04 11:30:29 -07:00
|
|
|
if (!e)
|
|
|
|
{
|
|
|
|
ERR("can not get evas");
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-06-16 21:10:17 -07:00
|
|
|
|
|
|
|
if (!_smart) _smart_init();
|
|
|
|
obj = evas_object_smart_add(e, _smart);
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2012-06-16 22:19:21 -07:00
|
|
|
sd->src = eina_stringshare_add(src);
|
2012-06-17 13:24:23 -07:00
|
|
|
sd->config = config;
|
2012-06-16 22:19:21 -07:00
|
|
|
sd->mode = mode;
|
2012-08-08 06:15:54 -07:00
|
|
|
sd->tmpfd = -1;
|
2014-10-08 15:12:34 -07:00
|
|
|
sd->type = type;
|
2012-08-08 06:15:54 -07:00
|
|
|
|
2012-09-24 05:18:52 -07:00
|
|
|
#if HAVE_MKSTEMPS
|
2014-10-08 15:12:34 -07:00
|
|
|
if (link_is_url(sd->src) && (type != MEDIA_TYPE_MOV))
|
2012-08-08 06:15:54 -07:00
|
|
|
{
|
|
|
|
const char *ext = NULL;
|
|
|
|
char *tbuf;
|
2012-10-18 00:55:53 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
if (!strncasecmp(sd->src, "www.", 4))
|
|
|
|
{
|
|
|
|
tbuf = alloca(strlen(sd->src) + 10);
|
|
|
|
strcpy(tbuf, "http://");
|
|
|
|
strcat(tbuf, sd->src);
|
|
|
|
}
|
|
|
|
else if (!strncasecmp(sd->src, "ftp.", 4))
|
|
|
|
{
|
|
|
|
tbuf = alloca(strlen(sd->src) + 10);
|
|
|
|
strcpy(tbuf, "ftp://");
|
|
|
|
strcat(tbuf, sd->src);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tbuf = (char *)sd->src;
|
|
|
|
if ((ext = _is_fmt(src, extn_img)))
|
|
|
|
sd->ext = ext;
|
|
|
|
else if ((ext = _is_fmt(src, extn_scale)))
|
|
|
|
sd->ext = ext;
|
|
|
|
else if ((ext = _is_fmt(src, extn_edj)))
|
|
|
|
sd->ext = ext;
|
|
|
|
else if ((ext = _is_fmt(src, extn_mov)))
|
|
|
|
sd->ext = ext;
|
2014-10-08 15:12:34 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case MEDIA_TYPE_IMG:
|
|
|
|
sd->ext = ".png";
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_SCALE:
|
|
|
|
sd->ext = ".svg";
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_EDJE:
|
|
|
|
sd->ext = ".edj";
|
|
|
|
break;
|
|
|
|
case MEDIA_TYPE_MOV:
|
|
|
|
case MEDIA_TYPE_UNKNOWN:
|
|
|
|
case MEDIA_TYPE_THUMB:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-08-08 06:15:54 -07:00
|
|
|
if (sd->ext)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
snprintf(buf, sizeof(buf), "/tmp/tmngyXXXXXX%s", sd->ext);
|
|
|
|
sd->tmpfd = mkstemps(buf, strlen(sd->ext));
|
|
|
|
if (sd->tmpfd >= 0)
|
|
|
|
{
|
|
|
|
sd->url = ecore_con_url_new(tbuf);
|
|
|
|
if (!sd->url)
|
|
|
|
{
|
|
|
|
unlink(buf);
|
|
|
|
close(sd->tmpfd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ecore_con_url_fd_set(sd->url, sd->tmpfd);
|
|
|
|
if (!ecore_con_url_get(sd->url))
|
|
|
|
{
|
|
|
|
unlink(buf);
|
|
|
|
close(sd->tmpfd);
|
|
|
|
sd->url = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
o = sd->o_busy = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(o, sd->config, "terminology/mediabusy",
|
|
|
|
NULL, NULL, EINA_FALSE);
|
2012-08-08 06:15:54 -07:00
|
|
|
evas_object_show(o);
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(o, "busy", "terminology");
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-08-08 06:15:54 -07:00
|
|
|
sd->realf = eina_stringshare_add(buf);
|
|
|
|
sd->url_prog_hand = ecore_event_handler_add
|
|
|
|
(ECORE_CON_EVENT_URL_PROGRESS, _url_prog_cb, obj);
|
|
|
|
sd->url_compl_hand = ecore_event_handler_add
|
|
|
|
(ECORE_CON_EVENT_URL_COMPLETE, _url_compl_cb, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR(_("Function %s failed: %s"), "mkstemps()", strerror(errno));
|
|
|
|
}
|
2012-08-08 06:15:54 -07:00
|
|
|
}
|
|
|
|
}
|
2012-09-24 05:18:52 -07:00
|
|
|
#endif
|
2012-08-08 06:15:54 -07:00
|
|
|
|
2014-11-29 12:59:00 -08:00
|
|
|
if (!sd->url)
|
2018-03-13 10:58:41 -07:00
|
|
|
sd->realf = eina_stringshare_add(sd->src);
|
2013-02-01 06:10:51 -08:00
|
|
|
|
|
|
|
if ((mode & MEDIA_SIZE_MASK) == MEDIA_THUMB)
|
2012-06-17 10:04:17 -07:00
|
|
|
{
|
2013-02-01 06:10:51 -08:00
|
|
|
// XXX: handle sd->url being true?
|
2015-08-23 07:40:19 -07:00
|
|
|
if (_type_thumb_init(obj) < 0)
|
2015-09-04 11:30:29 -07:00
|
|
|
{
|
|
|
|
ERR("failed to init '%s'", src);
|
|
|
|
goto err;
|
|
|
|
}
|
2013-02-01 06:10:51 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
switch (type)
|
2013-02-01 06:10:51 -08:00
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
case MEDIA_TYPE_IMG:
|
2015-08-23 07:40:19 -07:00
|
|
|
if (!sd->url && (_type_img_init(obj) < 0))
|
2015-09-04 11:30:29 -07:00
|
|
|
{
|
|
|
|
ERR("failed to init '%s'", src);
|
|
|
|
goto err;
|
|
|
|
}
|
2013-02-01 06:10:51 -08:00
|
|
|
break;
|
2014-10-08 15:12:34 -07:00
|
|
|
case MEDIA_TYPE_SCALE:
|
2015-08-23 07:40:19 -07:00
|
|
|
if (!sd->url && (_type_scale_init(obj) < 0))
|
2015-09-04 11:30:29 -07:00
|
|
|
{
|
|
|
|
ERR("failed to init '%s'", src);
|
|
|
|
goto err;
|
|
|
|
}
|
2013-02-01 06:10:51 -08:00
|
|
|
break;
|
2014-10-08 15:12:34 -07:00
|
|
|
case MEDIA_TYPE_EDJE:
|
2015-08-23 07:40:19 -07:00
|
|
|
if (!sd->url && (_type_edje_init(obj) < 0))
|
2015-09-04 11:30:29 -07:00
|
|
|
{
|
|
|
|
ERR("failed to init '%s'", src);
|
|
|
|
goto err;
|
|
|
|
}
|
2013-02-01 06:10:51 -08:00
|
|
|
break;
|
2014-10-08 15:12:34 -07:00
|
|
|
case MEDIA_TYPE_MOV:
|
2015-08-23 07:40:19 -07:00
|
|
|
if (!sd->url && (_type_mov_init(obj) < 0))
|
2015-09-04 11:30:29 -07:00
|
|
|
{
|
|
|
|
ERR("failed to init '%s'", src);
|
|
|
|
goto err;
|
|
|
|
}
|
2013-02-01 06:10:51 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-06-17 10:04:17 -07:00
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
sd->o_event = evas_object_rectangle_add(e);
|
|
|
|
evas_object_color_set(sd->o_event, 0, 0, 0, 0);
|
|
|
|
evas_object_repeat_events_set(sd->o_event, EINA_TRUE);
|
|
|
|
evas_object_smart_member_add(sd->o_event, obj);
|
|
|
|
evas_object_clip_set(sd->o_event, sd->clip);
|
|
|
|
evas_object_show(sd->o_event);
|
|
|
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_mouse_down_cb, obj);
|
|
|
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_mouse_up_cb, obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
return obj;
|
2014-11-29 12:59:00 -08:00
|
|
|
|
|
|
|
err:
|
|
|
|
if (obj)
|
|
|
|
evas_object_del(obj);
|
|
|
|
return NULL;
|
2012-06-16 21:10:17 -07:00
|
|
|
}
|
2012-06-17 02:26:01 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
media_mute_set(Evas_Object *obj, Eina_Bool mute)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2012-06-17 02:26:01 -07:00
|
|
|
emotion_object_audio_mute_set(sd->o_img, mute);
|
2012-06-24 02:49:23 -07:00
|
|
|
if (mute)
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->o_ctrl, "mute,set", "terminology");
|
2012-06-24 02:49:23 -07:00
|
|
|
else
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->o_ctrl, "mute,unset", "terminology");
|
2012-06-24 02:49:23 -07:00
|
|
|
}
|
|
|
|
|
2014-08-21 11:32:58 -07:00
|
|
|
void
|
|
|
|
media_visualize_set(Evas_Object *obj, Eina_Bool visualize)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2014-08-21 11:32:58 -07:00
|
|
|
if (visualize)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* FIXME: configure visualizing type, not hard coded one
|
|
|
|
*/
|
|
|
|
if (!emotion_object_vis_supported(sd->o_img, EMOTION_VIS_LIBVISUAL_INFINITE))
|
|
|
|
ERR(_("Media visualizing is not supported"));
|
|
|
|
else
|
|
|
|
emotion_object_vis_set(sd->o_img, EMOTION_VIS_LIBVISUAL_INFINITE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
emotion_object_vis_set(sd->o_img, EMOTION_VIS_NONE);
|
|
|
|
}
|
|
|
|
|
2012-06-24 02:49:23 -07:00
|
|
|
void
|
|
|
|
media_play_set(Evas_Object *obj, Eina_Bool play)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2012-06-24 02:49:23 -07:00
|
|
|
emotion_object_play_set(sd->o_img, play);
|
|
|
|
if (play)
|
2014-09-15 03:01:22 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "play", NULL);
|
|
|
|
edje_object_signal_emit(sd->o_ctrl, "play,set", "terminology");
|
|
|
|
}
|
2012-06-24 02:49:23 -07:00
|
|
|
else
|
2014-09-15 03:01:22 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "pause", NULL);
|
|
|
|
edje_object_signal_emit(sd->o_ctrl, "pause,set", "terminology");
|
|
|
|
}
|
2012-06-24 02:49:23 -07:00
|
|
|
}
|
|
|
|
|
2014-04-24 02:10:28 -07:00
|
|
|
Eina_Bool
|
2017-07-06 11:55:02 -07:00
|
|
|
media_play_get(const Evas_Object *obj)
|
2014-04-24 02:10:28 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return EINA_FALSE;
|
2014-04-24 02:10:28 -07:00
|
|
|
return emotion_object_play_get(sd->o_img);
|
|
|
|
}
|
|
|
|
|
2012-06-26 12:07:47 -07:00
|
|
|
void
|
|
|
|
media_stop(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2014-09-15 03:01:22 -07:00
|
|
|
evas_object_smart_callback_call(obj, "stop", NULL);
|
2012-06-26 12:07:47 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
2012-06-24 02:49:23 -07:00
|
|
|
void
|
|
|
|
media_position_set(Evas_Object *obj, double pos)
|
|
|
|
{
|
2012-06-24 04:55:46 -07:00
|
|
|
double len;
|
2012-06-24 02:49:23 -07:00
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2012-06-24 04:55:46 -07:00
|
|
|
len = emotion_object_play_length_get(sd->o_img);
|
|
|
|
emotion_object_position_set(sd->o_img, len * pos);
|
2012-06-24 02:49:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
media_volume_set(Evas_Object *obj, double vol)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
|
2012-06-24 02:49:23 -07:00
|
|
|
emotion_object_audio_volume_set(sd->o_img, vol);
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_drag_value_set(sd->o_ctrl, "terminology.voldrag", vol, vol);
|
2012-06-17 02:26:01 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
const char *
|
|
|
|
media_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return NULL;
|
|
|
|
return sd->realf;
|
|
|
|
}
|
|
|
|
|
2014-10-08 15:12:34 -07:00
|
|
|
Media_Type
|
2021-09-13 14:30:09 -07:00
|
|
|
media_src_type_get(const char *src, size_t len)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
Media_Type type = MEDIA_TYPE_UNKNOWN;
|
2012-10-09 07:16:45 -07:00
|
|
|
|
2021-09-13 14:30:09 -07:00
|
|
|
if (extn_matches(src, len, extn_img)) type = MEDIA_TYPE_IMG;
|
|
|
|
else if (extn_matches(src, len, extn_scale)) type = MEDIA_TYPE_SCALE;
|
|
|
|
else if (extn_matches(src, len, extn_edj)) type = MEDIA_TYPE_EDJE;
|
|
|
|
else if (extn_matches(src, len, extn_mov)) type = MEDIA_TYPE_MOV;
|
2012-07-04 07:44:43 -07:00
|
|
|
return type;
|
|
|
|
}
|
2014-08-18 08:56:58 -07:00
|
|
|
|
|
|
|
Evas_Object *
|
2017-07-06 11:55:02 -07:00
|
|
|
media_control_get(const Evas_Object *obj)
|
2014-08-18 08:56:58 -07:00
|
|
|
{
|
|
|
|
Media *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return NULL;
|
|
|
|
return sd->o_ctrl;
|
|
|
|
}
|
2018-12-17 12:51:05 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
media_unknown_handle(const char *handler, const char *src)
|
|
|
|
{
|
|
|
|
const char *cmd;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
char *escaped;
|
|
|
|
cmd = "xdg-open";
|
|
|
|
escaped = ecore_file_escape_name(src);
|
|
|
|
if (!escaped)
|
|
|
|
return;
|
|
|
|
if (handler && *handler)
|
|
|
|
cmd = handler;
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
|
|
|
|
free(escaped);
|
|
|
|
ecore_exe_run(buf, NULL);
|
|
|
|
}
|