set media type as an enum

devs/discomfitor/cc
Boris Faure 8 years ago
parent c7f71d75e8
commit 2568c50a40
  1. 36
      src/bin/gravatar.c
  2. 4
      src/bin/gravatar.h
  3. 124
      src/bin/main.c
  4. 184
      src/bin/media.c
  5. 23
      src/bin/media.h
  6. 8
      src/bin/options_wallpaper.c
  7. 53
      src/bin/termio.c

@ -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);
}

@ -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);

@ -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,8 +1907,8 @@ _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)
{
evas_object_event_callback_del(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)
{
edje_object_signal_emit(term->bg, "media,image", "terminology");
edje_object_signal_emit(term->base, "media,image", "terminology");
}
else if (type == 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)
{
edje_object_signal_emit(term->bg, "media,edje", "terminology");
edje_object_signal_emit(term->base, "media,edje", "terminology");
}
else if (type == TYPE_MOV)
{
edje_object_signal_emit(term->bg, "media,movie", "terminology");
edje_object_signal_emit(term->base, "media,movie", "terminology");
switch (type)
{
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "media,image", "terminology");
edje_object_signal_emit(term->base, "media,image", "terminology");
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "media,scale", "terminology");
edje_object_signal_emit(term->base, "media,scale", "terminology");
break;
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "media,edje", "terminology");
edje_object_signal_emit(term->base, "media,edje", "terminology");
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,40 +2228,51 @@ main_term_bg_config(Term *term)
if (term->popmedia)
{
edje_object_part_swallow(term->bg, "terminology.popmedia", term->popmedia);
if (term->poptype == TYPE_IMG)
edje_object_signal_emit(term->bg, "popmedia,image", "terminology");
else if (term->poptype == TYPE_SCALE)
edje_object_signal_emit(term->bg, "popmedia,scale", "terminology");
else if (term->poptype == TYPE_EDJE)
edje_object_signal_emit(term->bg, "popmedia,edje", "terminology");
else if (term->poptype == TYPE_MOV)
edje_object_signal_emit(term->bg, "popmedia,movie", "terminology");
switch (term->poptype)
{
case MEDIA_TYPE_IMG:
edje_object_signal_emit(term->bg, "popmedia,image", "terminology");
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "popmedia,scale", "terminology");
break;
case MEDIA_TYPE_EDJE:
edje_object_signal_emit(term->bg, "popmedia,edje", "terminology");
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)
{
edje_object_signal_emit(term->bg, "media,image", "terminology");
edje_object_signal_emit(term->base, "media,image", "terminology");
}
else if (term->mediatype == 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)
{
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");
break;
case MEDIA_TYPE_SCALE:
edje_object_signal_emit(term->bg, "media,scale", "terminology");
edje_object_signal_emit(term->base, "media,scale", "terminology");
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;
}
}
if ((term->focused) && (term->wn->focused))
{
edje_object_signal_emit(term->bg, "focus,in", "terminology");

@ -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;
@ -53,7 +54,7 @@ static const char *
_is_fmt(const char *f, const char **extn)
{
int i, len, l;
len = strlen(f);
for (i = 0; extn[i]; i++)
{
@ -89,7 +90,7 @@ _et_connect(void *data EINA_UNUSED, Ethumb_Client *c, Eina_Bool ok)
if (ok)
{
Evas_Object *o;
et_connected = EINA_TRUE;
ethumb_client_on_server_die_callback_set(c, _et_disconnect,
NULL, NULL);
@ -123,7 +124,7 @@ _type_thumb_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Eva
else
{
int iw = 1, ih = 1;
iw = w;
ih = (sd->ih * w) / sd->iw;
if (ih > h)
@ -165,7 +166,7 @@ _et_done(Ethumb_Client *c EINA_UNUSED, const char *file, const char *key, void *
Evas_Object *obj = data;
Media *sd = evas_object_smart_data_get(obj);
if (!sd) return;
// if (c != et_client) return;
sd->et_req = NULL;
evas_object_event_callback_add(sd->o_img, EVAS_CALLBACK_IMAGE_PRELOADED,
@ -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);
@ -274,7 +275,7 @@ _cb_img_frame(void *data)
if ((sd->fr >= sd->frnum) && (fr == 1))
{
int loops;
if (evas_object_image_animated_loop_type_get(sd->o_img) ==
EVAS_IMAGE_ANIMATED_HINT_NONE)
{
@ -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);
@ -345,7 +345,7 @@ _type_img_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_
else
{
int iw = 1, ih = 1;
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
{
iw = w;
@ -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);
@ -441,7 +440,7 @@ _type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Eva
else
{
int iw = 1, ih = 1;
if ((sd->mode & MEDIA_SIZE_MASK) == MEDIA_BG)
{
iw = w;
@ -477,7 +476,7 @@ _type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Eva
if (!sd->nosmooth)
{
Evas_Coord lw, lh;
lw = w;
lh = h;
if (lw < 256) lw = 256;
@ -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);
@ -712,13 +710,12 @@ _type_mov_init(Evas_Object *obj)
"gstreamer1"
};
char *mod = NULL;
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) &&
if ((sd->config->vidmod >= 0) &&
(sd->config->vidmod < (int)EINA_C_ARRAY_LENGTH(modules)))
mod = modules[sd->config->vidmod];
if (!emotion_object_init(o, mod))
@ -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);
@ -795,7 +792,7 @@ _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_
{
int iw = 1, ih = 1;
double ratio;
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;
@ -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;
}
@ -938,7 +935,7 @@ _smooth_handler(Evas_Object *obj)
{
Media *sd = evas_object_smart_data_get(obj);
double interval;
if (!sd) return;
interval = ecore_animator_frametime_get();
if (interval <= 0.0) interval = 1.0/60.0;
@ -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)
@ -1022,7 +1024,7 @@ _url_prog_cb(void *data, int type EINA_UNUSED, void *event_info)
if (ev->down.total > 0.0)
{
double perc;
if (!sd->downloading)
edje_object_signal_emit(sd->o_busy, "downloading", "terminology");
sd->downloading = EINA_TRUE;
@ -1030,7 +1032,7 @@ _url_prog_cb(void *data, int type EINA_UNUSED, void *event_info)
if (perc != sd->download_perc)
{
Edje_Message_Float msg;
sd->download_perc = perc;
msg.val = perc;
edje_object_message_send(sd->o_busy, EDJE_MESSAGE_FLOAT, 1, &msg);
@ -1047,7 +1049,8 @@ _url_compl_cb(void *data, int type EINA_UNUSED, void *event_info)
Media *sd = evas_object_smart_data_get(obj);
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);
@ -1057,18 +1060,24 @@ _url_compl_cb(void *data, int type EINA_UNUSED, void *event_info)
sd->url = NULL;
sd->url_prog_hand = NULL;
sd->url_compl_hand = NULL;
if (_is_fmt(sd->src, extn_img))
_type_img_init(obj);
else if (_is_fmt(sd->src, extn_scale))
_type_scale_init(obj);
else if (_is_fmt(sd->src, extn_edj))
_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))
_type_mov_init(obj);
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;
}
evas_object_raise(sd->o_busy);
evas_object_raise(sd->o_event);
_smart_calculate(obj);
@ -1081,7 +1090,7 @@ _mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
Evas_Event_Mouse_Down *ev = event;
Media *sd = evas_object_smart_data_get(data);
if (!sd) return;
if (sd->down.down) return;
if (ev->button != 1) return;
sd->down.x = ev->canvas.x;
@ -1096,7 +1105,7 @@ _mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
Media *sd = evas_object_smart_data_get(data);
Evas_Coord dx, dy;
if (!sd) return;
if (!sd->down.down) return;
sd->down.down = EINA_FALSE;
dx = abs(ev->canvas.x - sd->down.x);
@ -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;
sd->type = type;
t = media_src_type_get(sd->src);
#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,10 +1183,31 @@ 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];
snprintf(buf, sizeof(buf), "/tmp/tmngyXXXXXX%s", sd->ext);
sd->tmpfd = mkstemps(buf, strlen(sd->ext));
if (sd->tmpfd >= 0)
@ -1207,13 +1236,13 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
else
{
Evas_Object *o;
o = sd->o_busy = edje_object_add(evas_object_evas_get(obj));
evas_object_smart_member_add(o, obj);
theme_apply(o, sd->config, "terminology/mediabusy");
evas_object_show(o);
edje_object_signal_emit(o, "busy", "terminology");
sd->realf = eina_stringshare_add(buf);
sd->url_prog_hand = ecore_event_handler_add
(ECORE_CON_EVENT_URL_PROGRESS, _url_prog_cb, obj);
@ -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,25 +1282,25 @@ 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:
break;
}
}
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);
@ -1278,8 +1311,7 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
_mouse_down_cb, obj);
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;
}

@ -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

@ -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
{

@ -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);

Loading…
Cancel
Save