set media type as an enum

This commit is contained in:
Boris Faure 2014-10-09 00:12:34 +02:00
parent c7f71d75e8
commit 2568c50a40
7 changed files with 250 additions and 178 deletions

View File

@ -26,20 +26,27 @@ int _gravatar_log_dom = -1;
#define GRAVATAR_URL_START "http://www.gravatar.com/avatar/"
#define GRAVATAR_URL_END ""
typedef struct _Gravatar {
const char *url;
Config *config;
} Gravatar;
static Evas_Object *
_tooltip_content(void *data,
Evas_Object *obj,
Evas_Object *tt EINA_UNUSED)
{
const char *url = data;
Gravatar *g = data;
Evas_Object *o;
int type;
o = elm_label_add(obj);
elm_object_text_set(o, url);
DBG("url:%s", url);
//o = elm_label_add(obj);
//elm_object_text_set(o, url);
DBG("url:%s", g->url);
/* TODO */
//o = media_add(obj, url, config, MEDIA_TOOLTIP, &type);
o = media_add(obj, g->url, g->config, MEDIA_TOOLTIP, &type);
/* TODO: handle Gravatar leak */
return o;
}
@ -48,13 +55,14 @@ _tooltip_del(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
const char *url = data;
DBG("url:%s", url);
eina_stringshare_del(data);
Gravatar *g = data;
DBG("url:%s", g->url);
eina_stringshare_del(g->url);
free(g);
}
void
gravatar_tooltip(Evas_Object *obj, char *email)
gravatar_tooltip(Evas_Object *obj, Config *config, char *email)
{
int n;
MD5_CTX ctx;
@ -62,8 +70,11 @@ gravatar_tooltip(Evas_Object *obj, char *email)
unsigned char hash[MD5_HASHBYTES];
static const char hex[] = "0123456789abcdef";
const char *url;
//int type;
//Config *config = termio_config_get(obj);
Gravatar *g;
g = calloc(sizeof(Gravatar), 1);
if (!g) return;
g->config = config;
DBG("need to show tooltip for email:%s", email);
eina_str_tolower(&email);
@ -87,8 +98,9 @@ gravatar_tooltip(Evas_Object *obj, char *email)
DBG("url:%s", url);
g->url = url;
elm_object_tooltip_content_cb_set(obj, _tooltip_content,
(void *) url,
g,
_tooltip_del);
}

View File

@ -1,8 +1,10 @@
#ifndef _GRAVATAR_H__
#define _GRAVATAR_H__ 1
#include "config.h"
void
gravatar_tooltip(Evas_Object *obj, char *email);
gravatar_tooltip(Evas_Object *obj, Config *config, char *email);
void gravatar_init(void);
void gravatar_shutdown(void);

View File

@ -60,7 +60,7 @@ struct _Term
Evas_Object *sel;
Evas_Object *tabcount_spacer;
Eina_List *popmedia_queue;
int poptype, mediatype;
Media_Type poptype, mediatype;
int step_x, step_y, min_w, min_h, req_w, req_h;
struct {
int x, y;
@ -1135,7 +1135,7 @@ _popmedia_show(Term *term, const char *src)
{
Evas_Object *o;
Config *config = termio_config_get(term->term);
int type = 0;
Media_Type type;
if (!config) return;
ty_dbus_link_hide();
@ -1153,7 +1153,8 @@ _popmedia_show(Term *term, const char *src)
return;
}
termio_mouseover_suspend_pushpop(term->term, 1);
term->popmedia = o = media_add(term->wn->win, src, config, MEDIA_POP, &type);
type = media_src_type_get(src);
term->popmedia = o = media_add(term->wn->win, src, config, MEDIA_POP, type);
term->popmedia_deleted = EINA_FALSE;
evas_object_smart_callback_add(o, "loop", _cb_media_loop, term);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _cb_popmedia_del, term);
@ -1162,18 +1163,21 @@ _popmedia_show(Term *term, const char *src)
term->poptype = type;
switch (type)
{
case TYPE_IMG:
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "popmedia,image", "terminology");
break;
case TYPE_SCALE:
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "popmedia,scale", "terminology");
break;
case TYPE_EDJE:
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "popmedia,edje", "terminology");
break;
case TYPE_MOV:
case MEDIA_TYPE_MOV:
edje_object_signal_emit(term->bg, "popmedia,movie", "terminology");
break;
case MEDIA_TYPE_UNKNOWN:
default:
break;
}
}
@ -1903,7 +1907,7 @@ _term_media_update(Term *term, const Config *config)
if ((config->background) && (config->background[0]))
{
Evas_Object *o;
int type = 0;
Media_Type type;
if (term->media)
{
@ -1912,33 +1916,36 @@ _term_media_update(Term *term, const Config *config)
_cb_media_del);
evas_object_del(term->media);
}
type = media_src_type_get(config->background);
term->media = o = media_add(term->wn->win,
config->background, config,
MEDIA_BG, &type);
MEDIA_BG, type);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
_cb_media_del, term);
edje_object_part_swallow(term->base, "terminology.background", o);
evas_object_show(o);
term->mediatype = type;
if (type == TYPE_IMG)
switch (type)
{
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "media,image", "terminology");
edje_object_signal_emit(term->base, "media,image", "terminology");
}
else if (type == TYPE_SCALE)
{
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "media,scale", "terminology");
edje_object_signal_emit(term->base, "media,scale", "terminology");
}
else if (type == TYPE_EDJE)
{
break;
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "media,edje", "terminology");
edje_object_signal_emit(term->base, "media,edje", "terminology");
}
else if (type == TYPE_MOV)
{
break;
case MEDIA_TYPE_MOV:
edje_object_signal_emit(term->bg, "media,movie", "terminology");
edje_object_signal_emit(term->base, "media,movie", "terminology");
break;
case MEDIA_TYPE_UNKNOWN:
default:
break;
}
}
else
@ -2221,37 +2228,48 @@ main_term_bg_config(Term *term)
if (term->popmedia)
{
edje_object_part_swallow(term->bg, "terminology.popmedia", term->popmedia);
if (term->poptype == TYPE_IMG)
switch (term->poptype)
{
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "popmedia,image", "terminology");
else if (term->poptype == TYPE_SCALE)
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "popmedia,scale", "terminology");
else if (term->poptype == TYPE_EDJE)
break;
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "popmedia,edje", "terminology");
else if (term->poptype == TYPE_MOV)
break;
case MEDIA_TYPE_MOV:
edje_object_signal_emit(term->bg, "popmedia,movie", "terminology");
break;
default:
break;
}
}
if (term->media)
{
edje_object_part_swallow(term->base, "terminology.background", term->media);
if (term->mediatype == TYPE_IMG)
switch (term->mediatype)
{
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "media,image", "terminology");
edje_object_signal_emit(term->base, "media,image", "terminology");
}
else if (term->mediatype == TYPE_SCALE)
{
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "media,scale", "terminology");
edje_object_signal_emit(term->base, "media,scale", "terminology");
}
else if (term->mediatype == TYPE_EDJE)
{
break;
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "media,edje", "terminology");
edje_object_signal_emit(term->base, "media,edje", "terminology");
}
else if (term->mediatype == TYPE_MOV)
{
break;
case MEDIA_TYPE_MOV:
edje_object_signal_emit(term->bg, "media,movie", "terminology");
edje_object_signal_emit(term->base, "media,movie", "terminology");
break;
case MEDIA_TYPE_UNKNOWN:
default:
break;
}
}

View File

@ -32,7 +32,8 @@ struct _Media
int iw, ih;
int sw, sh;
int fr, frnum, loops;
int mode, type;
int mode;
Media_Type type;
int resizes;
struct {
Evas_Coord x, y;
@ -234,7 +235,7 @@ _type_thumb_init(Evas_Object *obj)
Evas_Object *o;
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->type = TYPE_THUMB;
sd->type = MEDIA_TYPE_THUMB;
_et_init();
o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
evas_object_image_load_orientation_set(o, EINA_TRUE);
@ -318,7 +319,6 @@ _type_img_init(Evas_Object *obj)
Evas_Object *o;
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->type = TYPE_IMG;
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);
@ -414,7 +414,6 @@ _type_scale_init(Evas_Object *obj)
Evas_Object *o;
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->type = TYPE_SCALE;
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);
@ -530,7 +529,6 @@ _type_edje_init(Evas_Object *obj)
};
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->type = TYPE_EDJE;
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);
@ -715,7 +713,6 @@ _type_mov_init(Evas_Object *obj)
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->type = TYPE_MOV;
emotion_init();
o = sd->o_img = emotion_object_add(evas_object_evas_get(obj));
if ((sd->config->vidmod >= 0) &&
@ -742,7 +739,7 @@ _type_mov_init(Evas_Object *obj)
_cb_mov_ref, obj);
emotion_object_file_set(o, sd->realf);
if (((sd->mode & MEDIA_OPTIONS_MASK) & MEDIA_RECOVER)
&& (sd->type == TYPE_MOV) && (sd->o_img))
&& (sd->type == MEDIA_TYPE_MOV) && (sd->o_img))
emotion_object_last_position_load(sd->o_img);
else
media_position_set(obj, 0.0);
@ -862,7 +859,7 @@ _smart_del(Evas_Object *obj)
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (((sd->mode & MEDIA_OPTIONS_MASK) & MEDIA_SAVE)
&& (sd->type == TYPE_MOV) && (sd->o_img))
&& (sd->type == MEDIA_TYPE_MOV) && (sd->o_img))
emotion_object_last_position_save(sd->o_img);
if (sd->url)
{
@ -921,14 +918,14 @@ _unsmooth_timeout(void *data)
evas_object_geometry_get(data, &ox, &oy, &ow, &oh);
sd->smooth_timer = NULL;
sd->nosmooth = EINA_FALSE;
if ((sd->type == TYPE_IMG) || (sd->type == TYPE_SCALE))
if ((sd->type == MEDIA_TYPE_IMG) || (sd->type == MEDIA_TYPE_SCALE))
{
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);
if (sd->type == TYPE_SCALE) _type_scale_calc(data, ox, oy, ow, oh);
if (sd->type == MEDIA_TYPE_SCALE) _type_scale_calc(data, ox, oy, ow, oh);
}
else if (sd->type == TYPE_MOV)
else if (sd->type == MEDIA_TYPE_MOV)
emotion_object_smooth_scale_set(sd->o_img, !sd->nosmooth);
return EINA_FALSE;
}
@ -948,13 +945,13 @@ _smooth_handler(Evas_Object *obj)
{
sd->nosmooth = EINA_TRUE;
sd->resizes = 0;
if ((sd->type == TYPE_IMG) || (sd->type == TYPE_SCALE))
if ((sd->type == MEDIA_TYPE_IMG) || (sd->type == MEDIA_TYPE_SCALE))
{
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);
}
else if (sd->type == TYPE_MOV)
else if (sd->type == MEDIA_TYPE_MOV)
emotion_object_smooth_scale_set(sd->o_img, !sd->nosmooth);
if (sd->smooth_timer)
sd->smooth_timer = ecore_timer_del(sd->smooth_timer);
@ -984,11 +981,16 @@ _smart_calculate(Evas_Object *obj)
_smooth_handler(obj);
sd->w = ow;
sd->h = oh;
if (sd->type == TYPE_IMG) _type_img_calc(obj, ox, oy, ow, oh);
else if (sd->type == TYPE_SCALE) _type_scale_calc(obj, ox, oy, ow, oh);
else if (sd->type == TYPE_EDJE) _type_edje_calc(obj, ox, oy, ow, oh);
else if (sd->type == TYPE_MOV) _type_mov_calc(obj, ox, oy, ow, oh);
else if (sd->type == TYPE_THUMB) _type_thumb_calc(obj, ox, oy, ow, oh);
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;
}
evas_object_move(sd->clip, ox, oy);
evas_object_resize(sd->clip, ow, oh);
if (sd->o_busy)
@ -1048,6 +1050,7 @@ _url_compl_cb(void *data, int type EINA_UNUSED, void *event_info)
if (!sd) return EINA_TRUE;
if (ev->url_con != sd->url) return EINA_TRUE;
edje_object_signal_emit(sd->o_busy, "done", "terminology");
ecore_event_handler_del(sd->url_prog_hand);
ecore_event_handler_del(sd->url_compl_hand);
@ -1058,17 +1061,23 @@ _url_compl_cb(void *data, int type EINA_UNUSED, void *event_info)
sd->url_prog_hand = NULL;
sd->url_compl_hand = NULL;
if (_is_fmt(sd->src, extn_img))
switch (sd->type)
{
case MEDIA_TYPE_IMG:
_type_img_init(obj);
else if (_is_fmt(sd->src, extn_scale))
break;
case MEDIA_TYPE_SCALE:
_type_scale_init(obj);
else if (_is_fmt(sd->src, extn_edj))
break;
case MEDIA_TYPE_EDJE:
_type_edje_init(obj);
// FIXME: handle audio specially
else if (_is_fmt(sd->src, extn_aud))
_type_mov_init(obj);
else if (_is_fmt(sd->src, extn_mov))
break;
case MEDIA_TYPE_MOV:
_type_mov_init(obj);
break;
default:
break;
}
evas_object_raise(sd->o_busy);
evas_object_raise(sd->o_event);
_smart_calculate(obj);
@ -1124,12 +1133,12 @@ _smart_init(void)
}
Evas_Object *
media_add(Evas_Object *parent, const char *src, const Config *config, int mode, int *type)
media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
Media_Type type)
{
Evas *e;
Evas_Object *obj = NULL;
Media *sd = NULL;
int t;
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
e = evas_object_evas_get(parent);
@ -1144,11 +1153,10 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
sd->config = config;
sd->mode = mode;
sd->tmpfd = -1;
t = media_src_type_get(sd->src);
sd->type = type;
#if HAVE_MKSTEMPS
if (link_is_url(sd->src) && (t != TYPE_MOV))
if (link_is_url(sd->src) && (type != MEDIA_TYPE_MOV))
{
const char *ext = NULL;
char *tbuf;
@ -1175,6 +1183,27 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
sd->ext = ext;
else if ((ext = _is_fmt(src, extn_mov)))
sd->ext = ext;
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:
sd->ext = ".avi";
break;
case MEDIA_TYPE_UNKNOWN:
case MEDIA_TYPE_THUMB:
break;
}
}
if (sd->ext)
{
char buf[4096];
@ -1222,6 +1251,10 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
}
}
}
else
{
ERR(_("Function %s failed: %s"), "mkstemps()", strerror(errno));
}
}
}
#endif
@ -1249,18 +1282,18 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
}
else
{
switch (t)
switch (type)
{
case TYPE_IMG:
case MEDIA_TYPE_IMG:
if (!sd->url) _type_img_init(obj);
break;
case TYPE_SCALE:
case MEDIA_TYPE_SCALE:
if (!sd->url) _type_scale_init(obj);
break;
case TYPE_EDJE:
case MEDIA_TYPE_EDJE:
if (!sd->url) _type_edje_init(obj);
break;
case TYPE_MOV:
case MEDIA_TYPE_MOV:
if (!sd->url) _type_mov_init(obj);
break;
default:
@ -1279,7 +1312,6 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_UP,
_mouse_up_cb, obj);
if (type) *type = t;
return obj;
err:
@ -1292,7 +1324,7 @@ void
media_mute_set(Evas_Object *obj, Eina_Bool mute)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
emotion_object_audio_mute_set(sd->o_img, mute);
if (mute)
edje_object_signal_emit(sd->o_ctrl, "mute,set", "terminology");
@ -1304,7 +1336,7 @@ void
media_visualize_set(Evas_Object *obj, Eina_Bool visualize)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
if (visualize)
{
/*
@ -1323,7 +1355,7 @@ void
media_play_set(Evas_Object *obj, Eina_Bool play)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
emotion_object_play_set(sd->o_img, play);
if (play)
{
@ -1341,7 +1373,7 @@ Eina_Bool
media_play_get(Evas_Object *obj)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return EINA_FALSE;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return EINA_FALSE;
return emotion_object_play_get(sd->o_img);
}
@ -1349,7 +1381,7 @@ void
media_stop(Evas_Object *obj)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
evas_object_smart_callback_call(obj, "stop", NULL);
evas_object_del(obj);
}
@ -1359,7 +1391,7 @@ media_position_set(Evas_Object *obj, double pos)
{
double len;
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
len = emotion_object_play_length_get(sd->o_img);
emotion_object_position_set(sd->o_img, len * pos);
}
@ -1368,7 +1400,7 @@ void
media_volume_set(Evas_Object *obj, double vol)
{
Media *sd = evas_object_smart_data_get(obj);
if ((!sd) || (sd->type != TYPE_MOV)) return;
if ((!sd) || (sd->type != MEDIA_TYPE_MOV)) return;
emotion_object_audio_volume_set(sd->o_img, vol);
edje_object_part_drag_value_set(sd->o_ctrl, "terminology.voldrag", vol, vol);
}
@ -1381,15 +1413,15 @@ media_get(const Evas_Object *obj)
return sd->realf;
}
int
Media_Type
media_src_type_get(const char *src)
{
int type = TYPE_UNKNOWN;
Media_Type type = MEDIA_TYPE_UNKNOWN;
if (_is_fmt(src, extn_img)) type = TYPE_IMG;
else if (_is_fmt(src, extn_scale)) type = TYPE_SCALE;
else if (_is_fmt(src, extn_edj)) type = TYPE_EDJE;
else if (_is_fmt(src, extn_mov)) type = TYPE_MOV;
if (_is_fmt(src, extn_img)) type = MEDIA_TYPE_IMG;
else if (_is_fmt(src, extn_scale)) type = MEDIA_TYPE_SCALE;
else if (_is_fmt(src, extn_edj)) type = MEDIA_TYPE_EDJE;
else if (_is_fmt(src, extn_mov)) type = MEDIA_TYPE_MOV;
return type;
}

View File

@ -8,21 +8,26 @@
#define MEDIA_POP 0x0001
#define MEDIA_STRETCH 0x0002
#define MEDIA_THUMB 0x0003
#define MEDIA_TOOLTIP 0x0004
// bitmask for options - on or off
#define MEDIA_RECOVER 0x0010
#define MEDIA_SAVE 0x0020
#define TYPE_UNKNOWN -1
#define TYPE_IMG 0
#define TYPE_SCALE 1
#define TYPE_EDJE 2
#define TYPE_MOV 3
#define TYPE_THUMB 4
#define TYPE_ICON 5
typedef enum _Media_Type Media_Type;
enum _Media_Type {
MEDIA_TYPE_UNKNOWN,
MEDIA_TYPE_IMG,
MEDIA_TYPE_SCALE,
MEDIA_TYPE_EDJE,
MEDIA_TYPE_MOV,
MEDIA_TYPE_THUMB,
};
#include "config.h"
Evas_Object *media_add(Evas_Object *parent, const char *src, const Config *config, int mode, int *type);
Evas_Object *media_add(Evas_Object *parent, const char *src, const Config *config, int mode, Media_Type type);
void media_mute_set(Evas_Object *obj, Eina_Bool mute);
void media_play_set(Evas_Object *obj, Eina_Bool play);
Eina_Bool media_play_get(Evas_Object *obj);
@ -31,7 +36,7 @@ void media_volume_set(Evas_Object *obj, double vol);
void media_visualize_set(Evas_Object *obj, Eina_Bool visualize);
void media_stop(Evas_Object *obj);
const char *media_get(const Evas_Object *obj);
int media_src_type_get(const char *src);
Media_Type media_src_type_get(const char *src);
Evas_Object *media_control_get(Evas_Object *obj);
#endif

View File

@ -114,14 +114,16 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
{
if (item->path)
{
int i, ret = 0;
int i;
Media_Type type;
for (i = 0; extn_edj[i]; i++)
{
if (eina_str_has_extension(item->path, extn_edj[i]))
return media_add(obj, item->path, config,
MEDIA_BG, &ret);
MEDIA_BG, MEDIA_TYPE_EDJE);
}
return media_add(obj, item->path, config, MEDIA_THUMB, &ret);
type = media_src_type_get(item->path);
return media_add(obj, item->path, config, MEDIA_THUMB, type);
}
else
{

View File

@ -771,14 +771,14 @@ _activate_link(Evas_Object *obj, Eina_Bool may_inline)
type = media_src_type_get(sd->link.string);
if (may_inline && _should_inline(obj))
{
if ((type == TYPE_IMG) ||
(type == TYPE_SCALE) ||
(type == TYPE_EDJE))
if ((type == MEDIA_TYPE_IMG) ||
(type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE))
{
evas_object_smart_callback_call(obj, "popup", NULL);
handled = EINA_TRUE;
}
else if (type == TYPE_MOV)
else if (type == MEDIA_TYPE_MOV)
{
evas_object_smart_callback_call(obj, "popup", NULL);
handled = EINA_TRUE;
@ -786,15 +786,15 @@ _activate_link(Evas_Object *obj, Eina_Bool may_inline)
}
if (!handled)
{
if ((type == TYPE_IMG) ||
(type == TYPE_SCALE) ||
(type == TYPE_EDJE))
if ((type == MEDIA_TYPE_IMG) ||
(type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE))
{
if ((config->helper.local.image) &&
(config->helper.local.image[0]))
cmd = config->helper.local.image;
}
else if (type == TYPE_MOV)
else if (type == MEDIA_TYPE_MOV)
{
if ((config->helper.local.video) &&
(config->helper.local.video[0]))
@ -822,15 +822,15 @@ _activate_link(Evas_Object *obj, Eina_Bool may_inline)
type = media_src_type_get(sd->link.string);
if (may_inline && _should_inline(obj))
{
if ((type == TYPE_IMG) ||
(type == TYPE_SCALE) ||
(type == TYPE_EDJE))
if ((type == MEDIA_TYPE_IMG) ||
(type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE))
{
// XXX: begin fetch of url, once done, show
evas_object_smart_callback_call(obj, "popup", NULL);
handled = EINA_TRUE;
}
else if (type == TYPE_MOV)
else if (type == MEDIA_TYPE_MOV)
{
// XXX: if no http:// add
evas_object_smart_callback_call(obj, "popup", NULL);
@ -839,15 +839,15 @@ _activate_link(Evas_Object *obj, Eina_Bool may_inline)
}
if (!handled)
{
if ((type == TYPE_IMG) ||
(type == TYPE_SCALE) ||
(type == TYPE_EDJE))
if ((type == MEDIA_TYPE_IMG) ||
(type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE))
{
if ((config->helper.url.image) &&
(config->helper.url.image[0]))
cmd = config->helper.url.image;
}
else if (type == TYPE_MOV)
else if (type == MEDIA_TYPE_MOV)
{
if ((config->helper.url.video) &&
(config->helper.url.video[0]))
@ -939,10 +939,10 @@ _cb_link_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
{
int type = media_src_type_get(sd->link.string);
if ((type == TYPE_IMG) ||
(type == TYPE_SCALE) ||
(type == TYPE_EDJE) ||
(type == TYPE_MOV))
if ((type == MEDIA_TYPE_IMG) ||
(type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE) ||
(type == MEDIA_TYPE_MOV))
elm_ctxpopup_item_append(ctxp, _("Preview"), NULL,
_cb_ctxp_link_preview, sd->self);
}
@ -1193,7 +1193,7 @@ _update_link(Evas_Object *obj, Termio *sd,
_cb_link_move, obj);
if ((!popup_exists) && link_is_email(sd->link.string))
{
gravatar_tooltip(o, sd->link.string);
gravatar_tooltip(o, sd->config, sd->link.string);
}
}
}
@ -1257,8 +1257,8 @@ _smart_media_clicked(void *data, Evas_Object *obj, void *info EINA_UNUSED)
if (config)
{
if ((!config->helper.inline_please) ||
(!((type == TYPE_IMG) || (type == TYPE_SCALE) ||
(type == TYPE_EDJE) || (type == TYPE_MOV))))
(!((type == MEDIA_TYPE_IMG) || (type == MEDIA_TYPE_SCALE) ||
(type == MEDIA_TYPE_EDJE) || (type == MEDIA_TYPE_MOV))))
{
const char *cmd = NULL;
@ -1807,7 +1807,7 @@ static void
_block_media_activate(Evas_Object *obj, Termblock *blk)
{
Termio *sd = evas_object_smart_data_get(obj);
int type = 0;
Media_Type type;
int media = MEDIA_STRETCH;
Evas_Object *mctrl;
@ -1821,8 +1821,9 @@ _block_media_activate(Evas_Object *obj, Termblock *blk)
media |= MEDIA_SAVE;
else
media |= MEDIA_RECOVER | MEDIA_SAVE;
blk->obj = media_add(obj, blk->path, sd->config, media, &type);
if (type == TYPE_MOV)
type = media_src_type_get(blk->path);
blk->obj = media_add(obj, blk->path, sd->config, media, type);
if (type == MEDIA_TYPE_MOV)
media_play_set(blk->obj, blk->mov_state == MOVIE_STATE_PLAY);
evas_object_event_callback_add
(blk->obj, EVAS_CALLBACK_DEL, _smart_media_del, blk);