about: add youtube channel

This commit is contained in:
Boris Faure 2020-07-23 22:52:47 +02:00
parent 3c21c13d39
commit 596d234ba1
Signed by untrusted user who does not match committer: borisfaure
GPG Key ID: 35C0410516166BE8
2 changed files with 329 additions and 2 deletions

View File

@ -381,12 +381,248 @@ group { name: "terminology/base";
signal: "mouse,clicked,3"; source: "twitter.txt";
action: SIGNAL_EMIT "about,twitter,ctx" "terminology";
}
part { name: "youtube.base"; type: RECT;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
visible: 0;
fixed: 1 1;
rel1 {
to_y: "terminology.about";
relative: 0.5 1.0;
}
rel2 {
relative: 1.0 1.0;
}
}
}
part { name: "youtube.txt"; type: TEXT;
mouse_events: 1;
scale: 1;
effect: GLOW;
description { state: "default" 0.0;
visible: 0;
align: 0.0 0.5;
fixed: 1 1;
rel1 {
to: "youtube.base";
relative: 0.5 0.5;
}
rel2 {
to: "youtube.base";
relative: 0.5 0.5;
}
color: 51 255 17 255;
color2: 136 255 136 40;
color3: 136 255 136 8;
text {
font: "Sans"; size: 11;
text: "Youtube channel";
align: 0.0 0.5;
min: 1 1;
}
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "youtube.bottom";
mouse_events: 0;
description { state: "default" 0.0;
fixed: 1 1;
image.normal: "lk_bottom.png";
image.border: 9 9 0 0;
align: 0.5 1.0;
min: 20 8;
rel1 {
to: "youtube.txt";
offset: -6 -2;
relative: 0.0 1.0;
}
rel2 {
to: "youtube.txt";
offset: 5 -1;
}
color: 51 255 17 255;
fill.smooth: 0;
visible: 0;
}
description { state: "visible" 0.0;
inherit: "default";
visible: 1;
}
}
part { name: "youtube.l";
mouse_events: 0;
description { state: "default" 0.0;
fixed: 1 1;
image.normal: "lk_left.png";
align: 0.0 1.0;
min: 4 4;
rel1 {
to: "youtube.txt";
offset: 6 -2;
relative: 0.0 1.0;
}
rel2 {
to: "youtube.txt";
offset: 6 -2;
relative: 0.0 1.0;
}
color: 51 255 17 255;
visible: 0;
}
description { state: "visible" 0.0;
inherit: "default";
visible: 1;
}
description { state: "out" 0.0;
fixed: 1 1;
inherit: "visible" 0.0;
min: 16 16;
rel1 {
to: "youtube.txt";
offset: -10 -2;
}
rel2 {
to: "youtube.txt";
offset: -10 -2;
}
color: 51 255 17 255;
}
description { state: "out2" 0.0;
fixed: 1 1;
inherit: "visible" 0.0;
min: 32 32;
rel1 {
to: "youtube.txt";
offset: -26 -2;
}
rel2 {
to: "youtube.txt";
offset: -26 -2;
}
color: 51 255 17 0;
}
}
part { name: "youtube.r";
mouse_events: 0;
description { state: "default" 0.0;
fixed: 1 1;
image.normal: "lk_right.png";
align: 1.0 1.0;
min: 4 4;
rel1 {
to: "youtube.txt";
offset: -5 -1;
relative: 1.0 1.0;
}
rel2 {
to: "youtube.txt";
offset: -5 -1;
relative: 1.0 1.0;
}
color: 51 255 17 0;
visible: 0;
}
description { state: "visible" 0.0;
inherit: "default";
visible: 1;
}
description { state: "out" 0.0;
fixed: 1 1;
inherit: "visible" 0.0;
min: 16 16;
rel1 {
to: "youtube.txt";
offset: 9 -2;
}
rel2 {
to: "youtube.txt";
offset: 9 -2;
}
color: 51 255 17 255;
}
description { state: "out2" 0.0;
fixed: 1 1;
inherit: "visible" 0.0;
min: 32 32;
rel1 {
to: "youtube.txt";
offset: 25 -2;
}
rel2 {
to: "youtube.txt";
offset: 25 -2;
}
color: 51 255 17 0;
}
}
program { name: "youtube.show2";
action: STATE_SET "out2" 0.0;
transition: LINEAR 0.3;
target: "youtube.l";
target: "youtube.r";
after: "youtube.show3";
}
program { name: "youtube.show3";
action: STATE_SET "default" 0.0;
target: "youtube.l";
target: "youtube.r";
after: "youtube.show";
}
program {
name: "youtube.show_bottom";
signal: "mouse,in"; source: "youtube.txt";
action: STATE_SET "visible" 0.0;
target: "youtube.bottom";
}
program {
name: "youtube.show";
signal: "mouse,in"; source: "youtube.txt";
action: STATE_SET "out" 0.0;
transition: LINEAR 0.3;
target: "youtube.l";
target: "youtube.r";
after: "youtube.show2";
}
program {
signal: "mouse,out"; source: "youtube.txt";
action: STATE_SET "visible" 0.0;
target: "youtube.txt";
}
program {
signal: "mouse,out"; source: "youtube.txt";
action: ACTION_STOP;
target: "youtube.show";
target: "youtube.show2";
target: "youtube.show3";
}
program {
signal: "mouse,out"; source: "youtube.txt";
action: STATE_SET "default" 0.0;
target: "youtube.bottom";
target: "youtube.l";
target: "youtube.r";
}
program {
signal: "mouse,clicked,1"; source: "youtube.txt";
action: SIGNAL_EMIT "about,youtube" "terminology";
}
program {
signal: "mouse,clicked,3"; source: "youtube.txt";
action: SIGNAL_EMIT "about,youtube,ctx" "terminology";
}
program {
signal: "about,show"; source: "terminology";
action: STATE_SET "visible" 0.0;
transition: SPRING 1.2 2.0 6;
target: "terminology.about";
target: "twitter.txt";
target: "youtube.txt";
}
program {
signal: "about,hide"; source: "terminology";
@ -394,6 +630,7 @@ group { name: "terminology/base";
transition: DECELERATE 0.6;
target: "terminology.about";
target: "twitter.txt";
target: "youtube.txt";
}

View File

@ -7,6 +7,7 @@
#include "termio.h"
#define TWITTER_HANDLE "@_Terminology_"
#define YOUTUBE_URL "https://www.youtube.com/channel/UCZ2iBYbbxvcZfcUmnz-rmlQ"
typedef struct _about_ctx {
Evas_Object *layout;
@ -67,6 +68,8 @@ _cb_ctxpopup_dismissed(void *data,
evas_object_del(obj);
}
/* Twitter {{{ */
static void
_cb_ctxpopup_copy_twitter(void *data,
Evas_Object *obj,
@ -95,8 +98,6 @@ _cb_ctxpopup_open_twitter_as_url(void *data,
evas_object_del(obj);
}
static void
_cb_twitter(void *data,
Evas_Object *_obj EINA_UNUSED,
@ -139,6 +140,82 @@ _cb_twitter_ctx(void *data,
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
_cb_ctxpopup_del, ctx);
}
/* }}} */
/* Youtube {{{ */
static void
_cb_ctxpopup_copy_youtube(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
About_Ctx *ctx = data;
elm_cnp_selection_set(ctx->win, ELM_SEL_TYPE_CLIPBOARD,
ELM_SEL_FORMAT_TEXT,
YOUTUBE_URL,
strlen(YOUTUBE_URL));
ctx->ctxpopup = NULL;
evas_object_del(obj);
}
static void
_cb_ctxpopup_open_youtube_as_url(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
About_Ctx *ctx = data;
_run_url(ctx, YOUTUBE_URL);
ctx->ctxpopup = NULL;
evas_object_del(obj);
}
static void
_cb_youtube(void *data,
Evas_Object *_obj EINA_UNUSED,
const char *_sig EINA_UNUSED,
const char *_src EINA_UNUSED)
{
About_Ctx *ctx = data;
_run_url(ctx, YOUTUBE_URL);
}
static void
_cb_youtube_ctx(void *data,
Evas_Object *_obj EINA_UNUSED,
const char *_sig EINA_UNUSED,
const char *_src EINA_UNUSED)
{
About_Ctx *ctx = data;
Evas_Object *popup;
const char *fmt;
Evas *e = evas_object_evas_get(ctx->base);
Evas_Coord x;
Evas_Coord y;
evas_pointer_canvas_xy_get(e, &x, &y);
popup = elm_ctxpopup_add(ctx->win);
ctx->ctxpopup = popup;
fmt = eina_stringshare_printf(_("Copy '%s'"),
YOUTUBE_URL);
elm_ctxpopup_item_append(popup, fmt, NULL,
_cb_ctxpopup_copy_youtube, ctx);
elm_ctxpopup_item_append(popup, _("Open"), NULL,
_cb_ctxpopup_open_youtube_as_url, ctx);
evas_object_move(popup, x, y);
evas_object_show(popup);
evas_object_smart_callback_add(popup, "dismissed",
_cb_ctxpopup_dismissed, ctx);
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
_cb_ctxpopup_del, ctx);
}
/* }}} */
static void
_cb_mouse_down(void *data,
@ -165,6 +242,11 @@ _cb_mouse_down(void *data,
elm_layout_signal_callback_del(ctx->base, "about,twitter,ctx", "*",
_cb_twitter_ctx);
elm_layout_signal_callback_del(ctx->base, "about,youtube", "*",
_cb_youtube);
elm_layout_signal_callback_del(ctx->base, "about,youtube,ctx", "*",
_cb_youtube_ctx);
free(ctx);
}
@ -189,6 +271,8 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
elm_object_part_text_set(base, "twitter.txt",
_("Twitter: @_Terminology_"));
elm_object_part_text_set(base, "youtube.txt",
_("Youtube channel"));
ctx->layout = o = elm_layout_add(win);
if (elm_layout_file_set(o, config_theme_path_get(config),
@ -321,6 +405,12 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
elm_layout_signal_callback_add(base, "about,twitter,ctx", "*",
_cb_twitter_ctx, ctx);
elm_layout_signal_callback_add(base, "about,youtube", "*",
_cb_youtube, ctx);
elm_layout_signal_callback_add(base, "about,youtube,ctx", "*",
_cb_youtube_ctx, ctx);
elm_layout_signal_emit(base, "about,show", "terminology");
elm_object_signal_emit(ctx->layout, "begin" ,"terminology");
elm_object_focus_set(ctx->layout, EINA_TRUE);