From e5570a7a9f9c4cece964983739e0e8390ddbc42b Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 17 Jun 2012 07:10:27 +0000 Subject: [PATCH] and the nuttiness comes. backroung images (still), animated gifs, scalable bg's (svg, ps, pdf etc.) that re-render at new scales, edje backgrounds and... ... ....... VIDEO WALLPAPERS. that's right folks. you can now play video.. IN the background of your terminal... and it works.. even loops.. and plays audio... :) SVN revision: 72276 --- data/themes/default.edc | 42 +++++++++++ src/bin/config.c | 6 ++ src/bin/config.h | 2 + src/bin/main.c | 34 +++++++-- src/bin/media.c | 150 ++++++++++++++++++++++++++++++++++++++-- src/bin/media.h | 7 +- 6 files changed, 230 insertions(+), 11 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index e23d5986..0bb1028e 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -40,6 +40,18 @@ collections { clip_to: "fade"; description { state: "default" 0.0; } + description { state: "image" 0.0; + inherit: "default" 0.0; + } + description { state: "scale" 0.0; + inherit: "default" 0.0; + } + description { state: "edje" 0.0; + inherit: "default" 0.0; + } + description { state: "movie" 0.0; + inherit: "default" 0.0; + } } part { name: "terminology.content"; type: SWALLOW; description { state: "default" 0.0; @@ -122,6 +134,36 @@ collections { target: "shadow"; target: "fade"; } + program { name: "media_off"; + signal: "media,off"; + source: "terminology"; + action: STATE_SET "default" 0.0; + target: "terminology.background"; + } + program { name: "media_img"; + signal: "media,image"; + source: "terminology"; + action: STATE_SET "image" 0.0; + target: "terminology.background"; + } + program { name: "media_scale"; + signal: "media,scale"; + source: "terminology"; + action: STATE_SET "scale" 0.0; + target: "terminology.background"; + } + program { name: "media_edje"; + signal: "media,edje"; + source: "terminology"; + action: STATE_SET "edje" 0.0; + target: "terminology.background"; + } + program { name: "media_mov"; + signal: "media,movie"; + source: "terminology"; + action: STATE_SET "movie" 0.0; + target: "terminology.background"; + } } } } diff --git a/src/bin/config.c b/src/bin/config.c index 718ae9aa..d389ef96 100644 --- a/src/bin/config.c +++ b/src/bin/config.c @@ -46,6 +46,10 @@ config_init(void) (edd_base, Config, "translucent", translucent, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC (edd_base, Config, "wordsep", wordsep, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC + (edd_base, Config, "vidmod", vidmod, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC + (edd_base, Config, "mute", mute, EET_T_UCHAR); home = (char *)_homedir(); snprintf(buf, sizeof(buf), "%s/.terminology/config/standard/base.cfg", home); @@ -71,6 +75,8 @@ config_init(void) config->translucent = 0; config->jump_on_change = 0; config->wordsep = eina_stringshare_add(" '\"()[]{}=*!#$^\\:;,?`"); + config->vidmod = 0; + config->mute = 0; } } diff --git a/src/bin/config.h b/src/bin/config.h index be758459..d1c1a3c8 100644 --- a/src/bin/config.h +++ b/src/bin/config.h @@ -13,6 +13,8 @@ struct _Config unsigned char jump_on_change; unsigned char translucent; const char *wordsep; + int vidmod; + unsigned char mute; }; extern Config *config; diff --git a/src/bin/main.c b/src/bin/main.c index 79811442..5b7971e2 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -84,18 +84,28 @@ void main_media_update(void) { Evas_Object *o; + int type = 0; if ((config->background) && (config->background[0])) { if (media) evas_object_del(media); - o = media = media_add(win, config->background, MEDIA_BG); + o = media = media_add(win, config->background, MEDIA_BG, &type); edje_object_part_swallow(bg, "terminology.background", o); + if (type == TYPE_IMG) + edje_object_signal_emit(bg, "media,image", "terminology"); + else if (type == TYPE_SCALE) + edje_object_signal_emit(bg, "media,scale", "terminology"); + else if (type == TYPE_EDJE) + edje_object_signal_emit(bg, "media,edje", "terminology"); + else if (type == TYPE_MOV) + edje_object_signal_emit(bg, "media,movie", "terminology"); evas_object_show(o); } else { if (media) { + edje_object_signal_emit(bg, "media,off", "terminology"); evas_object_del(media); media = NULL; } @@ -122,9 +132,12 @@ elm_main(int argc, char **argv) (!strcmp(argv[i], "--help"))) { printf("Options:\n" - " -e CMD Execute command CMD instead of the users shell\n" - " -t THEME Use the named edje theme or path to theme file\n" - " -b FILE Use the named file as a background wallpaper\n"); + " -e CMD Execute command CMD instead of the users shell\n" + " -t THEME Use the named edje theme or path to theme file\n" + " -b FILE Use the named file as a background wallpaper\n" + " -m [0/1] Set mute mode for video playback\n" + " -vm MOD Set emotion module to use (auto, gstreamer, xine, generic)\n" + ); exit(0); } else if ((!strcmp(argv[i], "-e")) && (i < (argc - 1))) @@ -151,6 +164,19 @@ elm_main(int argc, char **argv) if (config->background) eina_stringshare_del(config->background); config->background = eina_stringshare_add(argv[i]); } + else if ((!strcmp(argv[i], "-m")) && (i < (argc - 1))) + { + i++; + config->mute = atoi(argv[i]); + } + else if ((!strcmp(argv[i], "-vm")) && (i < (argc - 1))) + { + i++; + if (!strcmp(argv[i], "auto")) config->vidmod = 0; + else if (!strcmp(argv[i], "gstreamer")) config->vidmod = 1; + else if (!strcmp(argv[i], "xine")) config->vidmod = 2; + else if (!strcmp(argv[i], "generic")) config->vidmod = 3; + } } win = tg_win_add(); diff --git a/src/bin/media.c b/src/bin/media.c index 597c2eb3..4555271c 100644 --- a/src/bin/media.c +++ b/src/bin/media.c @@ -1,11 +1,8 @@ #include +#include +#include "media.h" #include "config.h" -#define TYPE_IMG 0 -#define TYPE_SCALE 1 -#define TYPE_EDJE 2 -#define TYPE_MOV 3 - typedef struct _Media Media; struct _Media @@ -13,6 +10,7 @@ struct _Media Evas_Object_Smart_Clipped_Data __clipped_data; Evas_Object *clip, *o_img, *o_tmp; Ecore_Timer *anim; + Ecore_Job *restart_job; const char *src; int iw, ih; int sw, sh; @@ -289,12 +287,123 @@ _type_edje_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas } //////////////////////// movie +static void _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); + +static void +_cb_mov_frame_decode(void *data, Evas_Object *obj, void *event) +{ + 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); + evas_object_show(sd->o_img); + _type_mov_calc(data, ox, oy, ow, oh); +} + +static void +_cb_mov_frame_resize(void *data, Evas_Object *obj, void *event) +{ + 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 +_cb_mov_len_change(void *data, Evas_Object *obj, void *event) +{ + 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 +_cb_mov_decode_stop(void *data, Evas_Object *obj, void *event) +{ + 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); +} + +static void +_cb_mov_progress(void *data, Evas_Object *obj, void *event) +{ + Media *sd = evas_object_smart_data_get(data); + if (!sd) return; + printf("progress: '%s' '%3.3f\n", + emotion_object_progress_info_get(sd->o_img), + emotion_object_progress_status_get(sd->o_img)); +} + +static void +_cb_mov_ref(void *data, Evas_Object *obj, void *event) +{ + Media *sd = evas_object_smart_data_get(data); + if (!sd) return; + printf("ref: '%s' num '%i'\n", + emotion_object_ref_file_get(sd->o_img), + emotion_object_ref_num_get(sd->o_img)); +} + static void _type_mov_init(Evas_Object *obj) { + Evas_Object *o; + char *modules[] = + { + NULL, + "gstreamer", + "xine", + "generic" + }; + 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 ((config->vidmod >= 0) && + (config->vidmod < (sizeof(modules) / sizeof(modules[0])))) + mod = modules[config->vidmod]; + if (!emotion_object_init(o, mod)) + { + printf("can't init emotion module '%s'\n", mod); + evas_object_del(sd->o_img); + sd->o_img = NULL; + return; + } + 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); + emotion_object_file_set(o, sd->src); + evas_object_smart_member_add(o, obj); + evas_object_clip_set(o, sd->clip); + emotion_object_position_set(o, 0.0); + emotion_object_play_set(o, EINA_TRUE); + if (config->mute) emotion_object_audio_mute_set(o, EINA_TRUE); } static void @@ -302,6 +411,34 @@ _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_ { Media *sd = evas_object_smart_data_get(obj); if (!sd) return; + 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 + { + int iw, ih; + 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; + + iw = w; + ih = w / ratio; + if (ih < h) + { + ih = h; + iw = h * ratio; + if (iw < w) iw = w; + } + 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); } @@ -341,6 +478,7 @@ _smart_del(Evas_Object *obj) if (sd->o_img) evas_object_del(sd->o_img); if (sd->o_tmp) evas_object_del(sd->o_tmp); if (sd->anim) ecore_timer_del(sd->anim); + if (sd->restart_job) ecore_job_del(sd->restart_job); _meida_sc.del(obj); evas_object_smart_data_set(obj, NULL); } @@ -399,7 +537,7 @@ _smart_init(void) } Evas_Object * -media_add(Evas_Object *parent, const char *src, int mode) +media_add(Evas_Object *parent, const char *src, int mode, int *type) { Evas *e; Evas_Object *obj; diff --git a/src/bin/media.h b/src/bin/media.h index bca11a34..8dd30e1c 100644 --- a/src/bin/media.h +++ b/src/bin/media.h @@ -1,3 +1,8 @@ #define MEDIA_BG 0 -Evas_Object *media_add(Evas_Object *parent, const char *src, int mode); +#define TYPE_IMG 0 +#define TYPE_SCALE 1 +#define TYPE_EDJE 2 +#define TYPE_MOV 3 + +Evas_Object *media_add(Evas_Object *parent, const char *src, int mode, int *type);