#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"
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,
}
}
+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;
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;
}
}
+ /* 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;
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;
}
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)
return true;
}
+static bool setting_display_theme_change_is_supported()
+{
+ return true;
+}
+
static bool setting_display_font_change_is_supported()
{
bool value;
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;
}