Add NUI Theme menu 12/257912/2 accepted/tizen/unified/20210509.123839 submit/tizen/20210507.073846
authorkiso.chang <kiso.chang@samsung.com>
Thu, 6 May 2021 08:35:44 +0000 (17:35 +0900)
committerkiso.chang <kiso.chang@samsung.com>
Fri, 7 May 2021 07:16:16 +0000 (16:16 +0900)
Change-Id: Ic36fee58ce2029c4a3542ef47595203be61d05d4
Signed-off-by: kiso.chang <kiso.chang@samsung.com>
packaging/org.tizen.setting-profile_common.spec
resource/po/en.po
resource/po/ko_KR.po
setting-common/include/setting-common-string.h
setting-display/CMakeLists.txt
setting-display/include/setting-display.h
setting-display/src/setting-display-main.c

index 7c2ca92a242db7643fa6540c7a74cea12280c98b..aceafd5c4236ab2dc002588e7f2e9ad39e900e50 100755 (executable)
@@ -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)
index b45f09f3920104a14888df792add7dd9cc63681b..10102f330718670306cd31299468f3bd93b977e0 100644 (file)
@@ -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"
index 2a249a303564e95beb9490386fb62c57f8b66f4d..10f4b14a91e66013a4d181a130a764f1b1893a4f 100644 (file)
@@ -2799,3 +2799,6 @@ msgstr "상태"
 
 msgid "IDS_ST_BODY_DEVICE_NAMES_ARE_DISPLAYED"
 msgstr "블루투스, Wi-Fi Direct 등에서 장치를 구별하기 위해 디바이스 이름이 표시됩니다."
+
+msgid "IDS_ST_BODY_THEME"
+msgstr "테마"
index eda2780b954f7df7afedd4482117ab26d3e1e4f1..1f008fe55a68debd8eee0317792766f6cdc674f6 100755 (executable)
@@ -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"
index ca56b436d8c0a18cf3f9aab3c20b33376fa76807..5ce8ddd1216b032b3dc4a136843d7965ced05b9c 100755 (executable)
@@ -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
index 9bf382a17d84296835831ac96217e01d47ef1702..3676ea848a79cf86913e7889b341c8663514a507 100644 (file)
@@ -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;
index 6f82ea27000ce59f2a140035322a7921d555c8f8..dbb39f3db29742f243686de5397852acfd27bf6f 100755 (executable)
@@ -23,6 +23,8 @@
 #include <system_settings.h>
 #include <dpm/password.h>
 #include <system_info.h>
+#include <theme.h>
+#include <theme_loader.h>
 
 #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;
 }