summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2020-07-23 22:52:47 +0200
committerBoris Faure <billiob@gmail.com>2020-07-23 22:52:47 +0200
commit596d234ba1852d8e2f0cced4f6aceba89bd2e6ef (patch)
tree067283a72042ee230af709f9485410ec161392d6
parent3c21c13d39ed9a48c4ea5a56c4d901525465f1fc (diff)
about: add youtube channel
-rw-r--r--data/themes/default/base.edc237
-rw-r--r--src/bin/about.c94
2 files changed, 329 insertions, 2 deletions
diff --git a/data/themes/default/base.edc b/data/themes/default/base.edc
index e835479..b1b848b 100644
--- a/data/themes/default/base.edc
+++ b/data/themes/default/base.edc
@@ -381,12 +381,248 @@ group { name: "terminology/base";
381 signal: "mouse,clicked,3"; source: "twitter.txt"; 381 signal: "mouse,clicked,3"; source: "twitter.txt";
382 action: SIGNAL_EMIT "about,twitter,ctx" "terminology"; 382 action: SIGNAL_EMIT "about,twitter,ctx" "terminology";
383 } 383 }
384
385 part { name: "youtube.base"; type: RECT;
386 mouse_events: 0;
387 scale: 1;
388 description { state: "default" 0.0;
389 visible: 0;
390 fixed: 1 1;
391 rel1 {
392 to_y: "terminology.about";
393 relative: 0.5 1.0;
394 }
395 rel2 {
396 relative: 1.0 1.0;
397 }
398 }
399 }
400 part { name: "youtube.txt"; type: TEXT;
401 mouse_events: 1;
402 scale: 1;
403 effect: GLOW;
404 description { state: "default" 0.0;
405 visible: 0;
406 align: 0.0 0.5;
407 fixed: 1 1;
408 rel1 {
409 to: "youtube.base";
410 relative: 0.5 0.5;
411 }
412 rel2 {
413 to: "youtube.base";
414 relative: 0.5 0.5;
415 }
416 color: 51 255 17 255;
417 color2: 136 255 136 40;
418 color3: 136 255 136 8;
419 text {
420 font: "Sans"; size: 11;
421 text: "Youtube channel";
422 align: 0.0 0.5;
423 min: 1 1;
424 }
425 }
426 description { state: "visible" 0.0;
427 inherit: "default" 0.0;
428 visible: 1;
429 }
430 }
431 part { name: "youtube.bottom";
432 mouse_events: 0;
433 description { state: "default" 0.0;
434 fixed: 1 1;
435 image.normal: "lk_bottom.png";
436 image.border: 9 9 0 0;
437 align: 0.5 1.0;
438 min: 20 8;
439 rel1 {
440 to: "youtube.txt";
441 offset: -6 -2;
442 relative: 0.0 1.0;
443 }
444 rel2 {
445 to: "youtube.txt";
446 offset: 5 -1;
447 }
448 color: 51 255 17 255;
449 fill.smooth: 0;
450 visible: 0;
451 }
452 description { state: "visible" 0.0;
453 inherit: "default";
454 visible: 1;
455 }
456 }
457 part { name: "youtube.l";
458 mouse_events: 0;
459 description { state: "default" 0.0;
460 fixed: 1 1;
461 image.normal: "lk_left.png";
462 align: 0.0 1.0;
463 min: 4 4;
464 rel1 {
465 to: "youtube.txt";
466 offset: 6 -2;
467 relative: 0.0 1.0;
468 }
469 rel2 {
470 to: "youtube.txt";
471 offset: 6 -2;
472 relative: 0.0 1.0;
473 }
474 color: 51 255 17 255;
475 visible: 0;
476 }
477 description { state: "visible" 0.0;
478 inherit: "default";
479 visible: 1;
480 }
481 description { state: "out" 0.0;
482 fixed: 1 1;
483 inherit: "visible" 0.0;
484 min: 16 16;
485 rel1 {
486 to: "youtube.txt";
487 offset: -10 -2;
488 }
489 rel2 {
490 to: "youtube.txt";
491 offset: -10 -2;
492 }
493 color: 51 255 17 255;
494 }
495 description { state: "out2" 0.0;
496 fixed: 1 1;
497 inherit: "visible" 0.0;
498 min: 32 32;
499 rel1 {
500 to: "youtube.txt";
501 offset: -26 -2;
502 }
503 rel2 {
504 to: "youtube.txt";
505 offset: -26 -2;
506 }
507 color: 51 255 17 0;
508 }
509 }
510 part { name: "youtube.r";
511 mouse_events: 0;
512 description { state: "default" 0.0;
513 fixed: 1 1;
514 image.normal: "lk_right.png";
515 align: 1.0 1.0;
516 min: 4 4;
517 rel1 {
518 to: "youtube.txt";
519 offset: -5 -1;
520 relative: 1.0 1.0;
521 }
522 rel2 {
523 to: "youtube.txt";
524 offset: -5 -1;
525 relative: 1.0 1.0;
526 }
527 color: 51 255 17 0;
528 visible: 0;
529 }
530 description { state: "visible" 0.0;
531 inherit: "default";
532 visible: 1;
533 }
534 description { state: "out" 0.0;
535 fixed: 1 1;
536 inherit: "visible" 0.0;
537 min: 16 16;
538 rel1 {
539 to: "youtube.txt";
540 offset: 9 -2;
541 }
542 rel2 {
543 to: "youtube.txt";
544 offset: 9 -2;
545 }
546 color: 51 255 17 255;
547 }
548 description { state: "out2" 0.0;
549 fixed: 1 1;
550 inherit: "visible" 0.0;
551 min: 32 32;
552 rel1 {
553 to: "youtube.txt";
554 offset: 25 -2;
555 }
556 rel2 {
557 to: "youtube.txt";
558 offset: 25 -2;
559 }
560 color: 51 255 17 0;
561 }
562 }
563 program { name: "youtube.show2";
564 action: STATE_SET "out2" 0.0;
565 transition: LINEAR 0.3;
566 target: "youtube.l";
567 target: "youtube.r";
568 after: "youtube.show3";
569 }
570 program { name: "youtube.show3";
571 action: STATE_SET "default" 0.0;
572 target: "youtube.l";
573 target: "youtube.r";
574 after: "youtube.show";
575 }
576 program {
577 name: "youtube.show_bottom";
578 signal: "mouse,in"; source: "youtube.txt";
579 action: STATE_SET "visible" 0.0;
580 target: "youtube.bottom";
581 }
582 program {
583 name: "youtube.show";
584 signal: "mouse,in"; source: "youtube.txt";
585 action: STATE_SET "out" 0.0;
586 transition: LINEAR 0.3;
587 target: "youtube.l";
588 target: "youtube.r";
589 after: "youtube.show2";
590 }
591 program {
592 signal: "mouse,out"; source: "youtube.txt";
593 action: STATE_SET "visible" 0.0;
594 target: "youtube.txt";
595 }
596 program {
597 signal: "mouse,out"; source: "youtube.txt";
598 action: ACTION_STOP;
599 target: "youtube.show";
600 target: "youtube.show2";
601 target: "youtube.show3";
602 }
603 program {
604 signal: "mouse,out"; source: "youtube.txt";
605 action: STATE_SET "default" 0.0;
606 target: "youtube.bottom";
607 target: "youtube.l";
608 target: "youtube.r";
609 }
610 program {
611 signal: "mouse,clicked,1"; source: "youtube.txt";
612 action: SIGNAL_EMIT "about,youtube" "terminology";
613 }
614 program {
615 signal: "mouse,clicked,3"; source: "youtube.txt";
616 action: SIGNAL_EMIT "about,youtube,ctx" "terminology";
617 }
618
384 program { 619 program {
385 signal: "about,show"; source: "terminology"; 620 signal: "about,show"; source: "terminology";
386 action: STATE_SET "visible" 0.0; 621 action: STATE_SET "visible" 0.0;
387 transition: SPRING 1.2 2.0 6; 622 transition: SPRING 1.2 2.0 6;
388 target: "terminology.about"; 623 target: "terminology.about";
389 target: "twitter.txt"; 624 target: "twitter.txt";
625 target: "youtube.txt";
390 } 626 }
391 program { 627 program {
392 signal: "about,hide"; source: "terminology"; 628 signal: "about,hide"; source: "terminology";
@@ -394,6 +630,7 @@ group { name: "terminology/base";
394 transition: DECELERATE 0.6; 630 transition: DECELERATE 0.6;
395 target: "terminology.about"; 631 target: "terminology.about";
396 target: "twitter.txt"; 632 target: "twitter.txt";
633 target: "youtube.txt";
397 } 634 }
398 635
399 636
diff --git a/src/bin/about.c b/src/bin/about.c
index c19278c..787e7fd 100644
--- a/src/bin/about.c
+++ b/src/bin/about.c
@@ -7,6 +7,7 @@
7#include "termio.h" 7#include "termio.h"
8 8
9#define TWITTER_HANDLE "@_Terminology_" 9#define TWITTER_HANDLE "@_Terminology_"
10#define YOUTUBE_URL "https://www.youtube.com/channel/UCZ2iBYbbxvcZfcUmnz-rmlQ"
10 11
11typedef struct _about_ctx { 12typedef struct _about_ctx {
12 Evas_Object *layout; 13 Evas_Object *layout;
@@ -67,6 +68,8 @@ _cb_ctxpopup_dismissed(void *data,
67 evas_object_del(obj); 68 evas_object_del(obj);
68} 69}
69 70
71/* Twitter {{{ */
72
70static void 73static void
71_cb_ctxpopup_copy_twitter(void *data, 74_cb_ctxpopup_copy_twitter(void *data,
72 Evas_Object *obj, 75 Evas_Object *obj,
@@ -95,8 +98,6 @@ _cb_ctxpopup_open_twitter_as_url(void *data,
95 evas_object_del(obj); 98 evas_object_del(obj);
96} 99}
97 100
98
99
100static void 101static void
101_cb_twitter(void *data, 102_cb_twitter(void *data,
102 Evas_Object *_obj EINA_UNUSED, 103 Evas_Object *_obj EINA_UNUSED,
@@ -139,6 +140,82 @@ _cb_twitter_ctx(void *data,
139 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, 140 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
140 _cb_ctxpopup_del, ctx); 141 _cb_ctxpopup_del, ctx);
141} 142}
143/* }}} */
144/* Youtube {{{ */
145
146static void
147_cb_ctxpopup_copy_youtube(void *data,
148 Evas_Object *obj,
149 void *_event EINA_UNUSED)
150{
151 About_Ctx *ctx = data;
152
153 elm_cnp_selection_set(ctx->win, ELM_SEL_TYPE_CLIPBOARD,
154 ELM_SEL_FORMAT_TEXT,
155 YOUTUBE_URL,
156 strlen(YOUTUBE_URL));
157 ctx->ctxpopup = NULL;
158 evas_object_del(obj);
159}
160
161static void
162_cb_ctxpopup_open_youtube_as_url(void *data,
163 Evas_Object *obj,
164 void *_event EINA_UNUSED)
165{
166 About_Ctx *ctx = data;
167
168 _run_url(ctx, YOUTUBE_URL);
169
170 ctx->ctxpopup = NULL;
171 evas_object_del(obj);
172}
173
174
175
176static void
177_cb_youtube(void *data,
178 Evas_Object *_obj EINA_UNUSED,
179 const char *_sig EINA_UNUSED,
180 const char *_src EINA_UNUSED)
181{
182 About_Ctx *ctx = data;
183
184 _run_url(ctx, YOUTUBE_URL);
185}
186
187static void
188_cb_youtube_ctx(void *data,
189 Evas_Object *_obj EINA_UNUSED,
190 const char *_sig EINA_UNUSED,
191 const char *_src EINA_UNUSED)
192{
193 About_Ctx *ctx = data;
194 Evas_Object *popup;
195 const char *fmt;
196 Evas *e = evas_object_evas_get(ctx->base);
197 Evas_Coord x;
198 Evas_Coord y;
199
200 evas_pointer_canvas_xy_get(e, &x, &y);
201
202 popup = elm_ctxpopup_add(ctx->win);
203 ctx->ctxpopup = popup;
204 fmt = eina_stringshare_printf(_("Copy '%s'"),
205 YOUTUBE_URL);
206
207 elm_ctxpopup_item_append(popup, fmt, NULL,
208 _cb_ctxpopup_copy_youtube, ctx);
209 elm_ctxpopup_item_append(popup, _("Open"), NULL,
210 _cb_ctxpopup_open_youtube_as_url, ctx);
211 evas_object_move(popup, x, y);
212 evas_object_show(popup);
213 evas_object_smart_callback_add(popup, "dismissed",
214 _cb_ctxpopup_dismissed, ctx);
215 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
216 _cb_ctxpopup_del, ctx);
217}
218/* }}} */
142 219
143static void 220static void
144_cb_mouse_down(void *data, 221_cb_mouse_down(void *data,
@@ -165,6 +242,11 @@ _cb_mouse_down(void *data,
165 elm_layout_signal_callback_del(ctx->base, "about,twitter,ctx", "*", 242 elm_layout_signal_callback_del(ctx->base, "about,twitter,ctx", "*",
166 _cb_twitter_ctx); 243 _cb_twitter_ctx);
167 244
245 elm_layout_signal_callback_del(ctx->base, "about,youtube", "*",
246 _cb_youtube);
247 elm_layout_signal_callback_del(ctx->base, "about,youtube,ctx", "*",
248 _cb_youtube_ctx);
249
168 free(ctx); 250 free(ctx);
169} 251}
170 252
@@ -189,6 +271,8 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
189 271
190 elm_object_part_text_set(base, "twitter.txt", 272 elm_object_part_text_set(base, "twitter.txt",
191 _("Twitter: @_Terminology_")); 273 _("Twitter: @_Terminology_"));
274 elm_object_part_text_set(base, "youtube.txt",
275 _("Youtube channel"));
192 276
193 ctx->layout = o = elm_layout_add(win); 277 ctx->layout = o = elm_layout_add(win);
194 if (elm_layout_file_set(o, config_theme_path_get(config), 278 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,
321 elm_layout_signal_callback_add(base, "about,twitter,ctx", "*", 405 elm_layout_signal_callback_add(base, "about,twitter,ctx", "*",
322 _cb_twitter_ctx, ctx); 406 _cb_twitter_ctx, ctx);
323 407
408 elm_layout_signal_callback_add(base, "about,youtube", "*",
409 _cb_youtube, ctx);
410 elm_layout_signal_callback_add(base, "about,youtube,ctx", "*",
411 _cb_youtube_ctx, ctx);
412
413
324 elm_layout_signal_emit(base, "about,show", "terminology"); 414 elm_layout_signal_emit(base, "about,show", "terminology");
325 elm_object_signal_emit(ctx->layout, "begin" ,"terminology"); 415 elm_object_signal_emit(ctx->layout, "begin" ,"terminology");
326 elm_object_focus_set(ctx->layout, EINA_TRUE); 416 elm_object_focus_set(ctx->layout, EINA_TRUE);