From 8a1bb55c4857c77c75220e3584b69b0ef8268c5f Mon Sep 17 00:00:00 2001 From: "kiso.chang" Date: Thu, 6 May 2021 17:35:44 +0900 Subject: [PATCH] Add NUI Theme menu Change-Id: Ic36fee58ce2029c4a3542ef47595203be61d05d4 Signed-off-by: kiso.chang --- .../org.tizen.setting-profile_common.spec | 1 + resource/po/en.po | 5 +- resource/po/ko_KR.po | 3 + .../include/setting-common-string.h | 1 + setting-display/CMakeLists.txt | 1 + setting-display/include/setting-display.h | 3 + setting-display/src/setting-display-main.c | 295 +++++++++++++++++- 7 files changed, 307 insertions(+), 2 deletions(-) diff --git a/packaging/org.tizen.setting-profile_common.spec b/packaging/org.tizen.setting-profile_common.spec index 7c2ca92..aceafd5 100755 --- a/packaging/org.tizen.setting-profile_common.spec +++ b/packaging/org.tizen.setting-profile_common.spec @@ -29,6 +29,7 @@ BuildRequires: pkgconfig(capi-appfw-event) BuildRequires: pkgconfig(capi-appfw-preference) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-appfw-package-manager) +BuildRequires: pkgconfig(capi-appfw-tizen-theme) BuildRequires: pkgconfig(capi-base-utils-i18n) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(capi-network-bluetooth) diff --git a/resource/po/en.po b/resource/po/en.po index b45f09f..10102f3 100644 --- a/resource/po/en.po +++ b/resource/po/en.po @@ -2756,4 +2756,7 @@ msgid "IDS_MSG_RESET_CANNOT_BE_UNDONE" msgstr "This action cannot be undone." msgid "IDS_ST_BODY_SHOW_NETWORK_STATUS_AND_OTHER_INFORMATION" -msgstr "show network status and other information." \ No newline at end of file +msgstr "show network status and other information." + +msgid "IDS_ST_BODY_THEME" +msgstr "Theme" diff --git a/resource/po/ko_KR.po b/resource/po/ko_KR.po index 2a249a3..10f4b14a 100644 --- a/resource/po/ko_KR.po +++ b/resource/po/ko_KR.po @@ -2799,3 +2799,6 @@ msgstr "상태" msgid "IDS_ST_BODY_DEVICE_NAMES_ARE_DISPLAYED" msgstr "블루투스, Wi-Fi Direct 등에서 장치를 구별하기 위해 디바이스 이름이 표시됩니다." + +msgid "IDS_ST_BODY_THEME" +msgstr "테마" diff --git a/setting-common/include/setting-common-string.h b/setting-common/include/setting-common-string.h index eda2780..1f008fe 100755 --- a/setting-common/include/setting-common-string.h +++ b/setting-common/include/setting-common-string.h @@ -84,6 +84,7 @@ #define KeyStr_Backlight_2_MIN_STR "IDS_ST_BODY_2_MINUTES" #define KeyStr_Backlight_5_MIN_STR "IDS_ST_BODY_5_MINUTES" #define KeyStr_Backlight_10_MIN_STR "IDS_ST_BODY_10_MINUTES" +#define KeyStr_Theme "IDS_ST_BODY_THEME" #define KeyStr_DateTime "IDS_ST_BODY_DATE_AND_TIME" #define KeyStr_LanguageInput "IDS_ST_HEADER_LANGUAGE_AND_INPUT" diff --git a/setting-display/CMakeLists.txt b/setting-display/CMakeLists.txt index ca56b43..5ce8ddd 100755 --- a/setting-display/CMakeLists.txt +++ b/setting-display/CMakeLists.txt @@ -6,6 +6,7 @@ SET(SETTING_PKG_DISPLAY "org.tizen.setting-display") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs_display REQUIRED elementary capi-appfw-application + capi-appfw-tizen-theme deviced glib-2.0 dlog diff --git a/setting-display/include/setting-display.h b/setting-display/include/setting-display.h index 9bf382a..3676ea8 100644 --- a/setting-display/include/setting-display.h +++ b/setting-display/include/setting-display.h @@ -98,12 +98,15 @@ typedef struct _SettingDisplay { Evas_Object *screen_timeout_popup; Evas_Object *screen_timeout_rdg; + Evas_Object *theme_popup; + Evas_Object *theme_rdg; Setting_GenGroupItem_Data *data_screen_mode; Setting_GenGroupItem_Data *data_br; Setting_GenGroupItem_Data *data_font; Setting_GenGroupItem_Data *data_back; + Setting_GenGroupItem_Data *data_theme; /*Setting_GenGroupItem_Data *data_touchkey_light_duration; */ Setting_GenGroupItem_Data *data_br_auto; Setting_GenGroupItem_Data *data_br_sli; diff --git a/setting-display/src/setting-display-main.c b/setting-display/src/setting-display-main.c index 6f82ea2..dbb39f3 100755 --- a/setting-display/src/setting-display-main.c +++ b/setting-display/src/setting-display-main.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "setting-display-main.h" #include "setting-common-draw-widget.h" @@ -50,6 +52,77 @@ static int setting_display_main_destroy(void *cb); static int setting_display_main_update(void *cb); static bool setting_display_screen_timeout_change_is_supported(); static bool setting_display_font_change_is_supported(); +static bool setting_display_theme_change_is_supported(); + +static char *get_current_theme_str() +{ + SETTING_TRACE_BEGIN; + + theme_loader_h tl_handle; + int result = theme_loader_create(&tl_handle); + if(result != THEME_MANAGER_ERROR_NONE){ + SETTING_TRACE_ERROR("error %x: theme_loader_create()", result); + return (char *)g_strdup(_("IDS_ST_HEADER_UNAVAILABLE")); + } + + char **ids; + int count; + result = theme_loader_query_id(tl_handle, &ids, &count); + if(result == THEME_MANAGER_ERROR_NONE){ + SETTING_TRACE_DEBUG("ids : %d", count); + for (int i = 0; i < count; i++) { + SETTING_TRACE_DEBUG("%d : %s", i, ids[i]); + + theme_h t_handle; + result = theme_loader_load(tl_handle, ids[i], &t_handle); + if(result == THEME_MANAGER_ERROR_NONE){ + char *theme_title; + result = theme_get_title(t_handle, &theme_title); + if(result == THEME_MANAGER_ERROR_NONE){ + SETTING_TRACE_DEBUG("%d's title : %s", i, theme_title); + } + theme_destroy(t_handle); + } + + free(ids[i]); + } + free(ids); + } + + theme_h t_handle; + result = theme_loader_load_current(tl_handle, &t_handle); + if(result != THEME_MANAGER_ERROR_NONE){ + if(result == THEME_MANAGER_ERROR_NO_SUCH_THEME) { + SETTING_TRACE_ERROR("error NO_SUCH_THEME: theme_loader_load_current()"); + theme_loader_destroy(tl_handle); + return (char *)g_strdup("No Such Theme"); + } + + SETTING_TRACE_ERROR("error : theme_loader_load_current()"); + theme_loader_destroy(tl_handle); + return (char *)g_strdup(_("IDS_ST_HEADER_UNAVAILABLE")); + } + + char *theme_title; + result = theme_get_title(t_handle, &theme_title); + if(result != THEME_MANAGER_ERROR_NONE){ + if(result == THEME_MANAGER_ERROR_INVALID_PARAMETER) + SETTING_TRACE_ERROR("error INVALID_PARAMETER: theme_get_title()"); + else if(result == THEME_MANAGER_ERROR_OUT_OF_MEMORY) + SETTING_TRACE_ERROR("error OUT_OF_MEMORY: theme_get_title()"); + else + SETTING_TRACE_ERROR("error : theme_get_title()"); + + theme_destroy(t_handle); + theme_loader_destroy(tl_handle); + return (char *)g_strdup(_("IDS_ST_HEADER_UNAVAILABLE")); + } + + theme_destroy(t_handle); + theme_loader_destroy(tl_handle); + + return (char *)g_strdup(theme_title); +} setting_view setting_view_display_main = { .create = setting_display_main_create, @@ -113,6 +186,43 @@ static void __screen_timeout_cb(void *data, Evas_Object *obj, void *event_info) } } +static void __theme_cb(void *data, Evas_Object *obj, void *event_info) +{ + SETTING_TRACE_BEGIN; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + SettingDisplay *ad = data; + + ret_if(data == NULL); + retm_if(event_info == NULL, "Invalid argument: event info is NULL"); + + elm_genlist_item_selected_set(item, 0); + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item); + + SETTING_TRACE("clicking item[%s, %s]", _(list_item->keyStr), list_item->sub_desc); + + theme_loader_h tl_handle; + int result = theme_loader_create(&tl_handle); + if(result == THEME_MANAGER_ERROR_NONE) { + + SETTING_TRACE_DEBUG("call theme_loader_set_current(): %s", list_item->sub_desc); + result = theme_loader_set_current(tl_handle, list_item->sub_desc); + if(result != THEME_MANAGER_ERROR_NONE) { + SETTING_TRACE_ERROR("error : theme_loader_set_current()"); + } + theme_loader_destroy(tl_handle); + } + else{ + SETTING_TRACE_ERROR("error : theme_loader_create()"); + } + + if (ad->theme_popup) { + evas_object_del(ad->theme_popup); + ad->theme_popup = NULL; + } + +} + static int get_max_inactivity_time_device_lock_handler(int *max_inactivity_time) { device_policy_manager_h handle; @@ -343,6 +453,139 @@ static void setting_display_screen_timeout_popup(void *data) elm_radio_value_set(rdg, radio_num + 6); } +static void setting_display_theme_popup(void *data) +{ + SETTING_TRACE_BEGIN; + + SettingDisplay *ad = (SettingDisplay *)data; + Evas_Object *menu_glist = NULL; + Evas_Object *rdg = NULL; + + + setting_retm_if(data == NULL, "data is NULL"); + + int max_inactivity_time = -1; + get_max_inactivity_time_device_lock_handler(&max_inactivity_time); + SETTING_TRACE(" -----------------> max_inactivity_time = %d", + max_inactivity_time); + + + ad->theme_popup = setting_create_popup_with_list( + &menu_glist, ad, ad->md.window, + KeyStr_Theme, NULL, 0, false, false, 0); + if(ad->theme_popup) + evas_object_event_callback_add(ad->theme_popup, + EVAS_CALLBACK_DEL, setting_protect_cb, &(ad->theme_popup)); + + rdg = elm_radio_add(menu_glist); + elm_object_style_set(rdg, "list"); + evas_object_propagate_events_set(rdg, EINA_TRUE); + elm_radio_state_value_set(rdg, -1); + evas_object_data_set(menu_glist, "radio", rdg); + ad->theme_rdg = rdg; + + + + + + + theme_loader_h tl_handle; + int result = theme_loader_create(&tl_handle); + if(result != THEME_MANAGER_ERROR_NONE){ + SETTING_TRACE_ERROR("error %x: theme_loader_create()", result); + return; + } + + + + theme_h t_handle; + char *curtheme_title = 0; + result = theme_loader_load_current(tl_handle, &t_handle); + if(result == THEME_MANAGER_ERROR_NONE){ + char *theme_title; + result = theme_get_title(t_handle, &theme_title); + if(result == THEME_MANAGER_ERROR_NONE){ + curtheme_title = theme_title; + SETTING_TRACE_DEBUG("curtheme_title : %s", curtheme_title); + } + + theme_destroy(t_handle); + } + else{ + if(result == THEME_MANAGER_ERROR_NO_SUCH_THEME) { + SETTING_TRACE_ERROR("error NO_SUCH_THEME: theme_loader_load_current()"); + } + else + SETTING_TRACE_ERROR("error : theme_loader_load_current()"); + } + + int cur_radio_num = -1; + + char **ids; + int count; + result = theme_loader_query_id(tl_handle, &ids, &count); + if(result == THEME_MANAGER_ERROR_NONE){ + int radio_num = 0; + SETTING_TRACE_DEBUG("ids : %d", count); + for (int i = 0; i < count; i++) { + SETTING_TRACE_DEBUG("%d : %s", i, ids[i]); + + result = theme_loader_load(tl_handle, ids[i], &t_handle); + if(result == THEME_MANAGER_ERROR_NONE){ + char *theme_title; + result = theme_get_title(t_handle, &theme_title); + if(result == THEME_MANAGER_ERROR_NONE){ + SETTING_TRACE_DEBUG("%d's title : %s", i, theme_title); + + { + + Setting_GenGroupItem_Data *data_theme = setting_create_Gendial_field_1radio( + menu_glist, + &(ad->itc_1line), + __theme_cb, + ad, + SWALLOW_Type_1RADIO_RIGHT, + rdg, + radio_num, /* Always ON */ + theme_title, + NULL); + + if (data_theme) { + data_theme->sub_desc = (char *)g_strdup(ids[i]); + data_theme->userdata = ad; + __BACK_POINTER_SET(data_theme); + + } else { + SETTING_TRACE_ERROR("data_theme is NULL"); + } + + if(!isEmptyStr(curtheme_title) && !safeStrCmp(theme_title, curtheme_title)) { + cur_radio_num = radio_num; + SETTING_TRACE_DEBUG("cur_radio_num : %d", cur_radio_num); + } + + radio_num++; + } + + } + theme_destroy(t_handle); + } + + free(ids[i]); + } + free(ids); + } + + + + + theme_loader_destroy(tl_handle); + + /* update radio */ + if(cur_radio_num>=0) + elm_radio_value_set(rdg, cur_radio_num); +} + static int setting_display_main_create(void *cb) { SETTING_TRACE_BEGIN; @@ -434,6 +677,41 @@ static int setting_display_main_create(void *cb) } } + /* separator */ + setting_create_Gendial_field_titleItem( + ad->md.genlist, + &(ad->itc_group), + NULL, + NULL); + + /* THEME */ + char *pa_theme = "theme 1"; + if (setting_display_theme_change_is_supported()) + pa_theme = get_current_theme_str(); + else + pa_theme = g_strdup(_("IDS_ST_HEADER_UNAVAILABLE")); + + + ad->data_theme = + setting_create_Gendial_field_def( + ad->md.genlist, + &(ad->itc_2line), + setting_display_main_mouse_up_Gendial_list_cb, + ad, + SWALLOW_Type_INVALID, NULL, NULL, + 0, KeyStr_Theme, + pa_theme, + NULL); + + if (ad->data_theme) { + if (!setting_display_theme_change_is_supported()) + elm_object_item_disabled_set(ad->data_theme->item, EINA_TRUE); + __BACK_POINTER_SET(ad->data_theme); + } else { + SETTING_TRACE_ERROR("ad->data_theme is NULL"); + } + + setting_view_display_main.is_create = 1; return SETTING_RETURN_SUCCESS; @@ -498,6 +776,14 @@ static int setting_display_main_update(void *cb) elm_genlist_item_update(ad->data_back->item); } + if (ad->data_theme) { + G_FREE(ad->data_theme->sub_desc); + ad->data_theme->sub_desc = get_current_theme_str(); + elm_object_item_data_set( + ad->data_theme->item, ad->data_theme); + elm_genlist_item_update(ad->data_theme->item); + } + return SETTING_RETURN_SUCCESS; } @@ -559,6 +845,8 @@ static void setting_display_main_mouse_up_Gendial_list_cb(void *data, setting_display_create_font_sg(ad); else if (!safeStrCmp(KeyStr_BacklightTime, list_item->keyStr)) setting_display_screen_timeout_popup(ad); + else if (!safeStrCmp(KeyStr_Theme, list_item->keyStr)) + setting_display_theme_popup(ad); } static Eina_Bool _main_view_pop_cb(void *data, Elm_Object_Item *it) @@ -626,6 +914,11 @@ static bool setting_display_screen_timeout_change_is_supported() return true; } +static bool setting_display_theme_change_is_supported() +{ + return true; +} + static bool setting_display_font_change_is_supported() { bool value; @@ -634,6 +927,6 @@ static bool setting_display_font_change_is_supported() SETTING_TRACE_ERROR("system_info_get_platform_bool failed for http://tizen.org/feature/systemsetting.font: %s", get_error_message(err)); return false; } - SETTING_TRACE_ERROR("http://tizen.org/feature/systemsetting.font: %d", value); + SETTING_TRACE_DEBUG("http://tizen.org/feature/systemsetting.font: %d", value); return value; } -- 2.34.1