4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <setting-datausage-change-cycle.h>
24 static int __setting_datausage_change_cycle_create(void *cb);
25 static int __setting_datausage_change_cycle_destroy(void *cb);
26 static int __setting_datausage_change_cycle_update(void *cb);
27 static int __setting_datausage_change_cycle_cleanup(void *cb);
29 setting_view setting_view_datausage_change_cycle = {
30 .create = __setting_datausage_change_cycle_create,
31 .destroy = __setting_datausage_change_cycle_destroy,
32 .update = __setting_datausage_change_cycle_update,
33 .cleanup = __setting_datausage_change_cycle_cleanup,
36 static char *_item_label_get(void *data, Evas_Object *obj, const char *part)
39 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
41 if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
42 if (item_data->keyStr) {
43 return (char *)g_strdup(_(item_data->keyStr));
45 } else if (!safeStrCmp(part, "elm.text.2")) { /* bottom or right */
46 if (item_data->sub_desc) {
47 return (char *)g_strdup(item_data->sub_desc);
55 static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part)
58 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
59 //int width = (int) (690 * elm_scale_get());
61 if (!safeStrCmp(part, "elm.icon") || !safeStrCmp(part, "elm.icon.1")) {
62 Evas_Object *datetimefield = elm_datetime_add(obj);
63 item_data->eo_check = datetimefield;
65 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_YEAR, EINA_FALSE);
66 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_MONTH, EINA_FALSE);
67 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_HOUR, EINA_FALSE);
68 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_MINUTE, EINA_FALSE);
69 elm_datetime_field_visible_set(datetimefield, ELM_DATETIME_AMPM, EINA_FALSE);
71 evas_object_size_hint_weight_set(datetimefield, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
72 evas_object_size_hint_align_set(datetimefield, 0.5, 0.5);
73 evas_object_show(datetimefield);
75 char date_format[MAX_DATETIME_FORMAT_LEN + 1] = {0, };
76 const char *time_format = "%H : %M";
78 snprintf(date_format, MAX_DATETIME_FORMAT_LEN,
79 "%s %s", item_data->sub_desc, time_format);
80 elm_datetime_format_set(datetimefield, date_format);
83 time_t ctime = time(NULL);
84 struct tm *ts = localtime_r(&ctime, &ts_ret);
86 ts_ret.tm_mday = item_data->chk_status;
88 elm_datetime_value_set(datetimefield, &ts_ret);
90 if (item_data->chk_change_cb) {
91 evas_object_smart_callback_add(datetimefield, "changed",
92 item_data->chk_change_cb, item_data);
100 static void _item_del(void *data, Evas_Object *obj)
102 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
104 G_FREE(item_data->keyStr);
105 G_FREE(item_data->sub_desc);
110 /* ***************************************************
114 ** **************************************************/
116 static int __setting_datausage_change_cycle_create(void *cb)
120 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
122 SettingDatausageUG *ad = (SettingDatausageUG *) cb;
123 Evas_Object *scroller;
125 setting_push_layout_navi_bar_genlist(ad->win_main_layout,
127 _(SETTING_DATAUSAGE_CHANGE_CYCLE_STR),
128 _("IDS_COM_BODY_BACK"),
130 __setting_datausage_change_cycle_back_cb,
132 ad, &scroller, ad->navibar);
134 setting_retvm_if(scroller == NULL, SETTING_RETURN_FAIL, "scroller is NULL");
136 Elm_Object_Item *item = NULL;;
138 item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
139 ELM_GENLIST_ITEM_NONE, NULL, NULL);
140 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
142 ad->itc_layout.item_style = "dialogue/1text.1icon.5";
143 ad->itc_layout.func.text_get = _item_label_get;
144 ad->itc_layout.func.content_get = _item_content_get;
145 ad->itc_layout.func.state_get = NULL;
146 ad->itc_layout.func.del = _item_del;
153 ret = setting_get_int_slp_key(INT_SLP_SETTING_DATAUSAGE_DATA_EACH_MONTH_INT, &value, &err);
155 SETTING_TRACE_ERROR("get vconf failed");
158 ad->change_data = setting_create_Gendial_field_def(scroller, &(ad->itc_layout),
160 ad, SWALLOW_Type_LAYOUT_DATEFIELD,
162 SETTING_DATAUSAGE_ON_THIS_DATE_EACH_MONTH_STR,
166 setting_view_datausage_change_cycle.is_create = 1;
167 return SETTING_RETURN_SUCCESS;
170 static int __setting_datausage_change_cycle_destroy(void *cb)
174 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
175 SettingDatausageUG *ad = (SettingDatausageUG *) cb;
177 elm_naviframe_item_pop(ad->navibar);
178 setting_view_datausage_change_cycle.is_create = 0;
179 return SETTING_RETURN_SUCCESS;
182 static int __setting_datausage_change_cycle_update(void *cb)
185 return SETTING_RETURN_SUCCESS;
188 static int __setting_datausage_change_cycle_cleanup(void *cb)
191 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
192 __setting_datausage_change_cycle_destroy(cb);
193 return SETTING_RETURN_SUCCESS;
196 /* ***************************************************
200 ** **************************************************/
201 static void __setting_datausage_change_cycle_back_cb(void *data, Evas_Object * obj, void *event_info)
204 ret_if(data == NULL);
205 SettingDatausageUG *ad = (SettingDatausageUG *) data;
207 setting_view_change(&setting_view_datausage_change_cycle, &setting_view_datausage_main, ad);