summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2018-11-02 17:32:56 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2018-11-02 17:42:18 +0900
commit619e59b3c243a3918c533587e9a7308b44b7119c (patch)
tree3ccf93d41249786f7ab2ebcd56ec2335a873ac81
parent9a4b0efe61cbb8c0e09c8ff81dad240bc9543b7b (diff)
efl_ui_theme: Introduce3devs/jaehyun/efl_ui_theme
-rw-r--r--src/lib/elementary/elm_theme.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/src/lib/elementary/elm_theme.c b/src/lib/elementary/elm_theme.c
index 16cd7cf323..b0484ad2f5 100644
--- a/src/lib/elementary/elm_theme.c
+++ b/src/lib/elementary/elm_theme.c
@@ -9,12 +9,12 @@
9 9
10#include "efl_ui_theme.eo.h" 10#include "efl_ui_theme.eo.h"
11 11
12static Efl_Ui_Theme *theme_default_eo = NULL; //Eo handle for efl_ui_theme_default_get()
13
14static Elm_Theme theme_default = 12static Elm_Theme theme_default =
15{ 13{
16 NULL, NULL, NULL, 14 NULL, NULL, NULL,
17 NULL, NULL, NULL, NULL, NULL, 1, NULL 15 NULL, NULL, NULL, NULL, NULL, 1, NULL,
16 NULL, NULL, NULL,
17 NULL
18}; 18};
19 19
20static Eina_List *themes = NULL; 20static Eina_List *themes = NULL;
@@ -332,7 +332,7 @@ _elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *grou
332 const char *style_sep = ":"; 332 const char *style_sep = ":";
333 333
334 if ((!clas) || !o) return EFL_UI_THEME_APPLY_FAILED; 334 if ((!clas) || !o) return EFL_UI_THEME_APPLY_FAILED;
335 if (!th) th = &(theme_default); 335 if (!th) th = elm_theme_default_get();
336 if (is_legacy) 336 if (is_legacy)
337 snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, (group) ? group : "base", (style) ? style : "default"); 337 snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, (group) ? group : "base", (style) ? style : "default");
338 else 338 else
@@ -383,7 +383,7 @@ _elm_theme_icon_set(Elm_Theme *th,
383 return EINA_TRUE; 383 return EINA_TRUE;
384 } 384 }
385 385
386 if (!th) th = &(theme_default); 386 if (!th) th = elm_theme_default_get();
387 snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style); 387 snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style);
388 file = _elm_theme_group_file_find(th, buf2); 388 file = _elm_theme_group_file_find(th, buf2);
389 if (file) 389 if (file)
@@ -409,7 +409,7 @@ _elm_theme_parse(Elm_Theme *th, const char *theme)
409 Eina_List *names = NULL; 409 Eina_List *names = NULL;
410 const char *p, *pe; 410 const char *p, *pe;
411 411
412 if (!th) th = &(theme_default); 412 if (!th) th = elm_theme_default_get();
413 if (theme) 413 if (theme)
414 { 414 {
415 Eina_Strbuf *buf; 415 Eina_Strbuf *buf;
@@ -483,7 +483,7 @@ void
483_elm_theme_shutdown(void) 483_elm_theme_shutdown(void)
484{ 484{
485 Elm_Theme *th; 485 Elm_Theme *th;
486 _elm_theme_clear(&(theme_default)); 486 _elm_theme_clear(elm_theme_default_get());
487 EINA_LIST_FREE(themes, th) 487 EINA_LIST_FREE(themes, th)
488 { 488 {
489 _elm_theme_clear(th); 489 _elm_theme_clear(th);
@@ -522,6 +522,9 @@ EAPI void
522elm_theme_free(Elm_Theme *th) 522elm_theme_free(Elm_Theme *th)
523{ 523{
524 EINA_SAFETY_ON_NULL_RETURN(th); 524 EINA_SAFETY_ON_NULL_RETURN(th);
525
526 if (th == elm_theme_default_get()) return;
527
525 efl_unref(th->obj); 528 efl_unref(th->obj);
526} 529}
527 530
@@ -542,8 +545,8 @@ elm_theme_files_copy(Eina_Inlist **dst, Eina_Inlist **src)
542EAPI void 545EAPI void
543elm_theme_copy(Elm_Theme *th, Elm_Theme *thdst) 546elm_theme_copy(Elm_Theme *th, Elm_Theme *thdst)
544{ 547{
545 if (!th) th = &(theme_default); 548 if (!th) th = elm_theme_default_get();
546 if (!thdst) thdst = &(theme_default); 549 if (!thdst) thdst = elm_theme_default_get();
547 _elm_theme_clear(thdst); 550 _elm_theme_clear(thdst);
548 if (th->ref_theme) 551 if (th->ref_theme)
549 { 552 {
@@ -563,8 +566,8 @@ elm_theme_copy(Elm_Theme *th, Elm_Theme *thdst)
563EAPI void 566EAPI void
564elm_theme_ref_set(Elm_Theme *th, Elm_Theme *thref) 567elm_theme_ref_set(Elm_Theme *th, Elm_Theme *thref)
565{ 568{
566 if (!th) th = &(theme_default); 569 if (!th) th = elm_theme_default_get();
567 if (!thref) thref = &(theme_default); 570 if (!thref) thref = elm_theme_default_get();
568 if (th->ref_theme == thref) return; 571 if (th->ref_theme == thref) return;
569 _elm_theme_clear(th); 572 _elm_theme_clear(th);
570 if (thref) 573 if (thref)
@@ -579,13 +582,15 @@ elm_theme_ref_set(Elm_Theme *th, Elm_Theme *thref)
579EAPI Elm_Theme * 582EAPI Elm_Theme *
580elm_theme_ref_get(const Elm_Theme *th) 583elm_theme_ref_get(const Elm_Theme *th)
581{ 584{
582 if (!th) th = &(theme_default); 585 if (!th) th = elm_theme_default_get();
583 return th->ref_theme; 586 return th->ref_theme;
584} 587}
585 588
586EAPI Elm_Theme * 589EAPI Elm_Theme *
587elm_theme_default_get(void) 590elm_theme_default_get(void)
588{ 591{
592 if (!theme_default.obj)
593 efl_ui_theme_default_get(NULL);
589 return &theme_default; 594 return &theme_default;
590} 595}
591 596
@@ -601,7 +606,7 @@ _elm_theme_overlay_add_internal(Elm_Theme *th, const char *item)
601EAPI void 606EAPI void
602elm_theme_overlay_add(Elm_Theme *th, const char *item) 607elm_theme_overlay_add(Elm_Theme *th, const char *item)
603{ 608{
604 if (!th) th = &(theme_default); 609 if (!th) th = elm_theme_default_get();
605 efl_ui_theme_overlay_add(th->obj, item); 610 efl_ui_theme_overlay_add(th->obj, item);
606} 611}
607 612
@@ -617,7 +622,7 @@ _elm_theme_overlay_del_internal(Elm_Theme *th, const char *item)
617EAPI void 622EAPI void
618elm_theme_overlay_del(Elm_Theme *th, const char *item) 623elm_theme_overlay_del(Elm_Theme *th, const char *item)
619{ 624{
620 if (!th) th = &(theme_default); 625 if (!th) th = elm_theme_default_get();
621 efl_ui_theme_overlay_del(th->obj, item); 626 efl_ui_theme_overlay_del(th->obj, item);
622} 627}
623 628
@@ -626,7 +631,7 @@ elm_theme_overlay_mmap_add(Elm_Theme *th, const Eina_File *f)
626{ 631{
627 Eina_File *file = eina_file_dup(f); 632 Eina_File *file = eina_file_dup(f);
628 633
629 if (!th) th = &(theme_default); 634 if (!th) th = elm_theme_default_get();
630 th->overlay_items = eina_list_free(th->overlay_items); 635 th->overlay_items = eina_list_free(th->overlay_items);
631 _elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file, EINA_TRUE, EINA_FALSE); 636 _elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file, EINA_TRUE, EINA_FALSE);
632 elm_theme_flush(th); 637 elm_theme_flush(th);
@@ -636,7 +641,7 @@ EAPI void
636elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f) 641elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f)
637{ 642{
638 if (!f) return; 643 if (!f) return;
639 if (!th) th = &(theme_default); 644 if (!th) th = elm_theme_default_get();
640 th->overlay_items = eina_list_free(th->overlay_items); 645 th->overlay_items = eina_list_free(th->overlay_items);
641 _elm_theme_file_mmap_del(&th->overlay, f); 646 _elm_theme_file_mmap_del(&th->overlay, f);
642 elm_theme_flush(th); 647 elm_theme_flush(th);
@@ -645,7 +650,7 @@ elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f)
645EAPI const Eina_List * 650EAPI const Eina_List *
646elm_theme_overlay_list_get(const Elm_Theme *th) 651elm_theme_overlay_list_get(const Elm_Theme *th)
647{ 652{
648 if (!th) th = &(theme_default); 653 if (!th) th = elm_theme_default_get();
649 if (!th->overlay_items) 654 if (!th->overlay_items)
650 { 655 {
651 Elm_Theme_File *etf; 656 Elm_Theme_File *etf;
@@ -668,7 +673,7 @@ _elm_theme_extension_add_internal(Elm_Theme *th, const char *item)
668EAPI void 673EAPI void
669elm_theme_extension_add(Elm_Theme *th, const char *item) 674elm_theme_extension_add(Elm_Theme *th, const char *item)
670{ 675{
671 if (!th) th = &(theme_default); 676 if (!th) th = elm_theme_default_get();
672 efl_ui_theme_extension_add(th->obj, item); 677 efl_ui_theme_extension_add(th->obj, item);
673} 678}
674 679
@@ -684,7 +689,7 @@ _elm_theme_extension_del_internal(Elm_Theme *th, const char *item)
684EAPI void 689EAPI void
685elm_theme_extension_del(Elm_Theme *th, const char *item) 690elm_theme_extension_del(Elm_Theme *th, const char *item)
686{ 691{
687 if (!th) th = &(theme_default); 692 if (!th) th = elm_theme_default_get();
688 efl_ui_theme_extension_del(th->obj, item); 693 efl_ui_theme_extension_del(th->obj, item);
689} 694}
690 695
@@ -694,7 +699,7 @@ elm_theme_extension_mmap_add(Elm_Theme *th, const Eina_File *f)
694 Eina_File *file = eina_file_dup(f); 699 Eina_File *file = eina_file_dup(f);
695 700
696 if (!f) return; 701 if (!f) return;
697 if (!th) th = &(theme_default); 702 if (!th) th = elm_theme_default_get();
698 th->extension_items = eina_list_free(th->extension_items); 703 th->extension_items = eina_list_free(th->extension_items);
699 _elm_theme_item_finalize(&th->extension, eina_file_filename_get(file), file, EINA_FALSE, EINA_FALSE); 704 _elm_theme_item_finalize(&th->extension, eina_file_filename_get(file), file, EINA_FALSE, EINA_FALSE);
700 elm_theme_flush(th); 705 elm_theme_flush(th);
@@ -704,7 +709,7 @@ EAPI void
704elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f) 709elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f)
705{ 710{
706 if (!f) return; 711 if (!f) return;
707 if (!th) th = &(theme_default); 712 if (!th) th = elm_theme_default_get();
708 th->extension_items = eina_list_free(th->extension_items); 713 th->extension_items = eina_list_free(th->extension_items);
709 _elm_theme_file_mmap_del(&th->extension, f); 714 _elm_theme_file_mmap_del(&th->extension, f);
710 elm_theme_flush(th); 715 elm_theme_flush(th);
@@ -713,7 +718,7 @@ elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f)
713EAPI const Eina_List * 718EAPI const Eina_List *
714elm_theme_extension_list_get(const Elm_Theme *th) 719elm_theme_extension_list_get(const Elm_Theme *th)
715{ 720{
716 if (!th) th = &(theme_default); 721 if (!th) th = elm_theme_default_get();
717 if (!th->extension_items) 722 if (!th->extension_items)
718 { 723 {
719 Elm_Theme_File *etf; 724 Elm_Theme_File *etf;
@@ -727,18 +732,18 @@ elm_theme_extension_list_get(const Elm_Theme *th)
727EAPI void 732EAPI void
728elm_theme_set(Elm_Theme *th, const char *theme) 733elm_theme_set(Elm_Theme *th, const char *theme)
729{ 734{
730 if (!th) th = &(theme_default); 735 if (!th) th = elm_theme_default_get();
731 _elm_theme_parse(th, theme); 736 _elm_theme_parse(th, theme);
732 ELM_SAFE_FREE(th->theme, eina_stringshare_del); 737 ELM_SAFE_FREE(th->theme, eina_stringshare_del);
733 elm_theme_flush(th); 738 elm_theme_flush(th);
734 if (th == &(theme_default)) 739 if (th == elm_theme_default_get())
735 eina_stringshare_replace(&_elm_config->theme, theme); 740 eina_stringshare_replace(&_elm_config->theme, theme);
736} 741}
737 742
738EAPI const char * 743EAPI const char *
739elm_theme_get(Elm_Theme *th) 744elm_theme_get(Elm_Theme *th)
740{ 745{
741 if (!th) th = &(theme_default); 746 if (!th) th = elm_theme_default_get();
742 if (!th->theme) 747 if (!th->theme)
743 { 748 {
744 Eina_Strbuf *buf; 749 Eina_Strbuf *buf;
@@ -769,7 +774,7 @@ elm_theme_get(Elm_Theme *th)
769EAPI const Eina_List * 774EAPI const Eina_List *
770elm_theme_list_get(const Elm_Theme *th) 775elm_theme_list_get(const Elm_Theme *th)
771{ 776{
772 if (!th) th = &(theme_default); 777 if (!th) th = elm_theme_default_get();
773 if (!th->theme_items) 778 if (!th->theme_items)
774 { 779 {
775 Elm_Theme_File *etf; 780 Elm_Theme_File *etf;
@@ -832,7 +837,7 @@ elm_theme_list_item_path_get(const char *f, Eina_Bool *in_search_path)
832EAPI void 837EAPI void
833elm_theme_flush(Elm_Theme *th) 838elm_theme_flush(Elm_Theme *th)
834{ 839{
835 if (!th) th = &(theme_default); 840 if (!th) th = elm_theme_default_get();
836 if (th->cache) eina_hash_free(th->cache); 841 if (th->cache) eina_hash_free(th->cache);
837 th->cache = eina_hash_string_superfast_new(EINA_FREE_CB(eina_file_close)); 842 th->cache = eina_hash_string_superfast_new(EINA_FREE_CB(eina_file_close));
838 if (th->cache_data) eina_hash_free(th->cache_data); 843 if (th->cache_data) eina_hash_free(th->cache_data);
@@ -860,7 +865,7 @@ elm_theme_full_flush(void)
860 { 865 {
861 elm_theme_flush(th); 866 elm_theme_flush(th);
862 } 867 }
863 elm_theme_flush(&(theme_default)); 868 elm_theme_flush(elm_theme_default_get());
864} 869}
865 870
866EAPI Eina_List * 871EAPI Eina_List *
@@ -952,7 +957,7 @@ elm_object_theme_get(const Evas_Object *obj)
952EAPI const char * 957EAPI const char *
953elm_theme_data_get(Elm_Theme *th, const char *key) 958elm_theme_data_get(Elm_Theme *th, const char *key)
954{ 959{
955 if (!th) th = &(theme_default); 960 if (!th) th = elm_theme_default_get();
956 return _elm_theme_data_find(th, key); 961 return _elm_theme_data_find(th, key);
957} 962}
958 963
@@ -961,7 +966,7 @@ elm_theme_group_path_find(Elm_Theme *th, const char *group)
961{ 966{
962 EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL); 967 EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL);
963 Eina_File *th_file = NULL; 968 Eina_File *th_file = NULL;
964 if (!th) th = &(theme_default); 969 if (!th) th = elm_theme_default_get();
965 970
966 th_file = _elm_theme_group_file_find(th, group); 971 th_file = _elm_theme_group_file_find(th, group);
967 if (th_file) 972 if (th_file)
@@ -1010,7 +1015,7 @@ elm_theme_group_base_list(Elm_Theme *th, const char *base)
1010 int len; 1015 int len;
1011 1016
1012 EINA_SAFETY_ON_NULL_RETURN_VAL(base, NULL); 1017 EINA_SAFETY_ON_NULL_RETURN_VAL(base, NULL);
1013 if (!th) th = &(theme_default); 1018 if (!th) th = elm_theme_default_get();
1014 1019
1015 // XXX: look results up in a hash for speed 1020 // XXX: look results up in a hash for speed
1016 len = strlen(base); 1021 len = strlen(base);
@@ -1061,11 +1066,9 @@ elm_theme_user_dir_get(void)
1061EOLIAN static Eo * 1066EOLIAN static Eo *
1062_efl_ui_theme_efl_object_constructor(Eo *obj, Efl_Ui_Theme_Data *pd) 1067_efl_ui_theme_efl_object_constructor(Eo *obj, Efl_Ui_Theme_Data *pd)
1063{ 1068{
1064 ERR("[CJH] Begin obj(%p)", obj);
1065 pd->th = _elm_theme_new_internal(obj);
1066
1067 obj = efl_constructor(efl_super(obj, EFL_UI_THEME_CLASS)); 1069 obj = efl_constructor(efl_super(obj, EFL_UI_THEME_CLASS));
1068 ERR("[CJH] End obj(%p)", obj); 1070
1071 pd->th = _elm_theme_new_internal(obj);
1069 1072
1070 return obj; 1073 return obj;
1071} 1074}
@@ -1081,19 +1084,20 @@ _efl_ui_theme_efl_object_destructor(Eo *obj, Efl_Ui_Theme_Data *pd)
1081EOLIAN static Efl_Ui_Theme * 1084EOLIAN static Efl_Ui_Theme *
1082_efl_ui_theme_default_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED) 1085_efl_ui_theme_default_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
1083{ 1086{
1084 if (!theme_default_eo) 1087 if (!(theme_default.obj))
1085 { 1088 {
1086 //Construct Efl_Ui_Theme object for default theme 1089 //Construct Efl_Ui_Theme object for default theme
1087 theme_default_eo = efl_add(EFL_UI_THEME_CLASS, efl_main_loop_get()); 1090 Eo *theme_obj = efl_add(EFL_UI_THEME_CLASS, efl_main_loop_get());
1088 Efl_Ui_Theme_Data *td = efl_data_scope_get(theme_default_eo, EFL_UI_THEME_CLASS); 1091 Efl_Ui_Theme_Data *td = efl_data_scope_get(theme_obj, EFL_UI_THEME_CLASS);
1089 1092
1090 //Free automatically allocated Elm_Theme handle 1093 //Free automatically allocated Elm_Theme handle
1091 _elm_theme_free_internal(td->th); 1094 _elm_theme_free_internal(td->th);
1092 1095
1093 //Assign default Elm_Theme to Efl_Ui_Theme object data 1096 //Assign default Elm_Theme and Efl_Ui_Theme object
1094 td->th = elm_theme_default_get(); 1097 td->th = elm_theme_default_get();
1098 theme_default.obj = theme_obj;
1095 } 1099 }
1096 return theme_default_eo; 1100 return theme_default.obj;
1097} 1101}
1098 1102
1099EOLIAN static void 1103EOLIAN static void