3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.tizenopensource.org/license
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
23 #include "edit-repeat.h"
25 #define CAL_REPEAT_EVERY_2_WEEK (CAL_REPEAT_EVERY_YEAR+1)
26 #define CAL_REPEAT_EVERY_3_DAY (CAL_REPEAT_EVERY_2_WEEK+1)
28 static const char *_name = "calendar/edit/repeat";
34 Evas_Object *ly; // self
37 Evas_Object *repeat_radio_group;
38 Evas_Object *repeat_radio_group_member[7];
39 Evas_Object *repeat_until_radio_group;
41 Evas_Object *day_selector;
42 Evas_Object *repeat_occurrence_entry;
43 Evas_Object *end_date;
45 struct tm *start_date_time;
48 int repeat_occurrence;
49 struct tm repeat_end_date_time;
51 Eina_Bool is_repeat_type;
53 int selected_repeat_radio;
54 int prev_selected_repeat_radio;
55 int selected_repeat_until_radio;
57 cal_repeat_term_t repeat;
58 } cal_edit_repeat_data;
60 static char *__cal_edit_repeat_repeat_str[] = {
61 [CAL_REPEAT_NONE] = NULL,
62 [CAL_REPEAT_EVERY_DAY] = NULL,
63 [CAL_REPEAT_EVERY_WEEK] = NULL,
64 [CAL_REPEAT_EVERY_MONTH] = NULL,
65 [CAL_REPEAT_EVERY_YEAR] = NULL,
66 [CAL_REPEAT_EVERY_2_WEEK] = NULL,
67 [CAL_REPEAT_EVERY_3_DAY] = NULL,
70 static int __cal_edit_repeat_repeat_index[] = {
73 CAL_REPEAT_EVERY_WEEK,
74 CAL_REPEAT_EVERY_2_WEEK,
75 CAL_REPEAT_EVERY_MONTH,
76 CAL_REPEAT_EVERY_YEAR,
77 CAL_REPEAT_EVERY_3_DAY,
80 static const char *__cal_edit_repeat_repeat_until_str[] = {
81 [CAL_REPEAT_NONE] = NULL,
82 [CAL_REPEAT_EVERY_DAY] = NULL,
83 [CAL_REPEAT_EVERY_WEEK] = "",
86 static int __cal_edit_repeat_repeat_until_index[] = {
87 CALS_REPEAT_UNTIL_TYPE_NONE,
88 CALS_REPEAT_UNTIL_TYPE_COUNT,
89 CALS_REPEAT_UNTIL_TYPE_DATETIME,
92 static Elm_Entry_Filter_Limit_Size _limit_2char = {
95 static Elm_Entry_Filter_Accept_Set _digit_only = {
96 .accepted = "0123456789",
99 static Elm_Genlist_Item_Class itc_seperator, itc_1icon_1text, itc_1icon;
101 typedef struct __cal_edit_repeat_item_data cal_edit_repeat_item_data;
102 struct __cal_edit_repeat_item_data
104 cal_edit_repeat_data *p;
108 Evas_Object *item_radio;
111 #define is_leap_year_tm(y) (((y+1900)%4 == 0 && ((y+1900)%100 != 0 || (y+1900)%400 == 0))? 1 : 0)
113 static void __cal_edit_repeat_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
117 cal_edit_repeat_data *p = data;
122 static void __cal_edit_repeat_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
124 cal_edit_repeat_data *p;
125 Evas_Event_Mouse_Up *ev = ei;
128 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
131 p = CAL_UTIL_GET_PRIV_DATA(obj);
132 elm_radio_value_set(p->repeat_radio_group, val);
133 p->prev_selected_repeat_radio = p->selected_repeat_radio;
134 p->selected_repeat_radio = val;
137 static void __cal_edit_repeat_entry_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
142 Evas_Event_Mouse_Up *ev = ei;
145 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
148 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
149 elm_radio_value_set(p->repeat_until_radio_group, val);
151 if (CALS_REPEAT_UNTIL_TYPE_COUNT == val) {
152 elm_object_focus_set(p->repeat_occurrence_entry, EINA_TRUE);
153 elm_entry_cursor_end_set(p->repeat_occurrence_entry);
156 p->selected_repeat_until_radio = val;
158 const char* str = elm_entry_entry_get(p->repeat_occurrence_entry);
159 c_ret_if(!CAL_STRLEN(str));
161 p->repeat_occurrence = atoi(str);
164 int cal_edit_repeat_get_repeat(Evas_Object *ly, int *flag, cal_repeat_until_type_t *repeat_until_type, struct tm *repeat_end_date_time, int *occurrency)
166 c_retvm_if(!ly, CAL_REPEAT_NONE, "ly is null");
168 const char* text = NULL;
170 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
171 c_retvm_if(!p, CAL_REPEAT_NONE, "p is null");
173 c_retvm_if(CAL_STRCMP(p->name, _name), CAL_REPEAT_NONE, "Invaild object.");
174 c_retvm_if(!p->repeat_radio_group, CAL_REPEAT_NONE, "p->repeat_radio_group is null");
175 c_retvm_if(!p->repeat_until_radio_group, CAL_REPEAT_NONE, "p->repeat_until_radio_group is null");
177 int repeat = p->selected_repeat_radio;
179 int raido_value = p->selected_repeat_until_radio;
180 if (raido_value == 0)
181 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_NONE;
182 else if (raido_value == 1)
183 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_COUNT;
185 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_DATETIME;
187 switch(*repeat_until_type) {
188 case CALS_REPEAT_UNTIL_TYPE_NONE:
191 *repeat_end_date_time = *p->start_date_time;
192 cal_util_update_tm_month(repeat_end_date_time, 1);
195 case CALS_REPEAT_UNTIL_TYPE_COUNT:
196 text = elm_entry_entry_get(p->repeat_occurrence_entry);
197 c_retvm_if(!text, CAL_REPEAT_NONE, "text is null");
199 *occurrency = atoi(text);
201 *repeat_end_date_time = *p->start_date_time;
202 cal_util_update_tm_month(repeat_end_date_time, 1);
206 case CALS_REPEAT_UNTIL_TYPE_DATETIME:
209 *repeat_end_date_time = p->repeat_end_date_time;
219 void cal_edit_repeat_get_repeat_str(cal_repeat_term_t term, int flag, char *buf, int sz)
221 const char *s = __cal_edit_repeat_repeat_str[term];
222 if (CAL_REPEAT_NONE == term || !s)
223 s = S_("IDS_COM_BODY_OFF");
225 CAL_STRNCPY(buf, s, sz);
229 static char *__cal_edit_repeat_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
231 c_retv_if(!data, NULL);
233 cal_edit_repeat_item_data *item_data = data;
235 int repeat_type = item_data->repeat_type;
236 int repeat_index = item_data->repeat_index;
238 if (!CAL_STRCMP(part, "elm.text")) {
239 switch (repeat_type) {
241 return strdup(C_("IDS_CLD_BODY_REPEAT"));
243 return strdup(C_("IDS_CLD_BODY_REPEAT_UNTIL"));
245 return strdup(__cal_edit_repeat_repeat_until_str[__cal_edit_repeat_repeat_until_index[repeat_index]]);
247 return strdup(__cal_edit_repeat_repeat_str[__cal_edit_repeat_repeat_index[repeat_index]]);
256 static void __cal_edit_repeat_genlist_item_delete_callback(void *data, Evas_Object *obj)
260 cal_edit_repeat_item_data *item_data = data;
262 if (item_data->repeat_type) {
264 cal_edit_repeat_data* p = item_data->p;
266 c_ret_if(!p->repeat_radio_group_member);
268 p->repeat_radio_group_member[item_data->repeat_index] = NULL;
274 static Eina_Bool __cal_edit_repeat_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
279 static void __cal_edit_repeat_set_radio_group(cal_edit_repeat_data *p, Evas_Object *rd, int val)
281 if (p->is_repeat_type) {
284 p->repeat_radio_group = rd;
286 elm_radio_group_add(p->repeat_radio_group_member[1], p->repeat_radio_group);
287 elm_radio_group_add(p->repeat_radio_group_member[2], p->repeat_radio_group);
288 elm_radio_group_add(p->repeat_radio_group_member[3], p->repeat_radio_group);
289 elm_radio_group_add(p->repeat_radio_group_member[4], p->repeat_radio_group);
290 elm_radio_group_add(p->repeat_radio_group_member[5], p->repeat_radio_group);
291 elm_radio_group_add(p->repeat_radio_group_member[6], p->repeat_radio_group);
294 elm_radio_group_add(rd, p->repeat_radio_group);
298 p->repeat_until_radio_group = rd;
300 elm_radio_group_add(rd, p->repeat_until_radio_group);
304 static Evas_Object* __cal_edit_repeat_add_custom_text_object(cal_edit_repeat_data *p, Evas_Object *dg, const char *text)
306 Evas_Object *entry = NULL;
308 if (!text || text[0] == '\0')
311 entry = elm_entry_add(dg);
314 elm_entry_single_line_set(entry, EINA_TRUE);
315 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
316 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
317 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
318 elm_entry_editable_set(entry, EINA_FALSE);
319 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
320 elm_entry_autocapital_type_set(entry, EINA_TRUE);
322 elm_entry_entry_set(entry,text);
327 static Evas_Object* __cal_edit_repeat_add_radio(Evas_Object *dg, int val, cal_edit_repeat_data *p, cal_edit_repeat_item_data *item_data)
329 c_retvm_if(!dg, NULL, "dg is NULL.");
330 c_retvm_if(!p, NULL, "p is NULL.");
331 c_retvm_if(!item_data, NULL, "item_data is NULL.");
333 Evas_Object *rd = elm_radio_add(dg);
334 c_retvm_if(!rd, NULL, "rd is NULL.");
336 evas_object_propagate_events_set(rd, EINA_TRUE);
338 elm_radio_state_value_set(rd, val);
340 item_data->item_radio = rd;
342 if (item_data->repeat_type)
343 *(p->repeat_radio_group_member + val) = rd;
345 __cal_edit_repeat_set_radio_group(p, rd, val);
347 evas_object_show(rd);
348 evas_object_data_set(rd, "priv", p);
350 if (p->is_repeat_type)
351 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_clicked_callback, (void *)val);
352 else if (0 == val || 1 == val)
353 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)val);
358 static void __cal_edit_repeat_entry_unfocused(void *data, Evas_Object *obj, void *event_info)
360 cal_edit_repeat_data *p = (cal_edit_repeat_data *)data;
362 char times[8] = {0,};
363 snprintf(times, 7, "%d", p->repeat_occurrence);
364 elm_entry_entry_set(p->repeat_occurrence_entry, times);
368 static void __cal_edit_repeat_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
371 cal_edit_repeat_data *p = data;
373 const char *s = elm_entry_entry_get(p->repeat_occurrence_entry);
374 p->repeat_occurrence = atoi(s);
377 static Evas_Object* __cal_edit_repeat_add_entry(Evas_Object *parent, cal_edit_repeat_data *p)
380 Ecore_IMF_Context *ic;
382 e = elm_entry_add(parent);
386 elm_object_style_set(e, "font_color_black");
387 elm_entry_single_line_set(e, EINA_TRUE);
388 elm_entry_markup_filter_append(e, elm_entry_filter_limit_size, &_limit_2char);
389 elm_entry_markup_filter_append(e, elm_entry_filter_accept_set, &_digit_only);
390 elm_entry_input_panel_layout_set(e, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
391 elm_entry_context_menu_disabled_set(e, EINA_TRUE);
393 ic = elm_entry_imf_context_get(e);
397 evas_object_smart_callback_add(e, "unfocused", __cal_edit_repeat_entry_unfocused, p);
398 evas_object_smart_callback_add(e, "changed", __cal_edit_repeat_entry_changed_callback, p);
404 static Evas_Object* __cal_edit_repeat_add_times(Evas_Object *dg, const char *text, int val, cal_edit_repeat_data *p, cal_edit_repeat_item_data *item_data)
409 Evas_Object *entry_times;
410 char times[8] = {0,};
412 ly = cal_util_add_layout(dg, "dialoguegroup/repeat/times");
416 entry_times = __cal_edit_repeat_add_custom_text_object(p, dg, text);
422 elm_object_part_content_set(ly, "text", entry_times);
424 evas_object_show(ly);
425 evas_object_data_set(ly, "priv", p);
426 evas_object_event_callback_add(ly, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)val);
428 rd = elm_radio_add(dg);
434 elm_radio_state_value_set(rd, val);
435 elm_object_part_content_set(ly, "content", rd);
436 item_data->item_radio = rd;
437 __cal_edit_repeat_set_radio_group(p, rd, val);
439 entry = __cal_edit_repeat_add_entry(ly, p);
445 elm_object_part_content_set(ly, "input_sw", entry);
447 p->repeat_occurrence_entry = entry;
448 snprintf(times, 7, "%d", p->repeat_occurrence);
449 elm_entry_entry_set(p->repeat_occurrence_entry, times);
454 static void __cal_edit_repeat_end_date_changed_callback(void *data, Evas_Object *obj, void *ei)
456 cal_edit_repeat_data *p = data;
458 elm_datetime_value_get(obj, &p->repeat_end_date_time);
461 static Evas_Object* __cal_edit_repeat_add_radio_tm(Evas_Object *dg, struct tm* repeat_end_date, int val, cal_edit_repeat_data *p, cal_edit_repeat_item_data *item_data)
463 Evas_Object *ly = cal_util_add_layout(dg, "dialoguegroup/tm");
464 c_retvm_if(!ly, NULL, "ly is null");
466 evas_object_show(ly);
467 evas_object_data_set(ly, "priv", p);
469 Evas_Object *rd = elm_radio_add(dg);
475 evas_object_propagate_events_set(rd, EINA_TRUE);
477 elm_radio_state_value_set(rd, val);
479 elm_object_part_content_set(ly, "content", rd);
480 item_data->item_radio = rd;
482 if (item_data->repeat_type)
483 *(p->repeat_radio_group_member + val) = rd;
485 __cal_edit_repeat_set_radio_group(p, rd, val);
487 Evas_Object *datetime = cal_util_add_datetime(dg, NULL, repeat_end_date);
488 c_retvm_if(!datetime, NULL, "datetime is null");
490 elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
491 elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
492 elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
494 elm_datetime_field_limit_set(datetime, ELM_DATETIME_YEAR, 70, 137);
496 evas_object_smart_callback_add(datetime,"changed", __cal_edit_repeat_end_date_changed_callback, p);
498 elm_object_part_content_set(ly, "datefield", datetime);
503 static Evas_Object* __cal_edit_repeat_add_radio_group(Evas_Object *dg, const char *text, int val, cal_edit_repeat_data *p, cal_edit_repeat_item_data *item_data)
505 if (p->is_repeat_type) {
506 return __cal_edit_repeat_add_radio(dg, val, p, item_data);
511 return __cal_edit_repeat_add_radio(dg, val, p, item_data);
513 return __cal_edit_repeat_add_times(dg, text, val, p, item_data);
515 return __cal_edit_repeat_add_radio_tm(dg, &p->repeat_end_date_time, val, p, item_data);
523 static void __cal_edit_repeat_set_selected_repeat_state(cal_edit_repeat_data *p)
525 elm_radio_value_set(p->repeat_radio_group, p->selected_repeat_radio);
528 static void __cal_edit_repeat_set_selected_repeat_until_state(cal_edit_repeat_data *p)
532 char times[10] = {0};
534 switch (p->selected_repeat_until_radio) {
536 elm_radio_value_set(p->repeat_until_radio_group, 1);
537 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
538 elm_entry_entry_set(p->repeat_occurrence_entry,times);
542 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
543 elm_entry_entry_set(p->repeat_occurrence_entry,times);
544 elm_radio_value_set(p->repeat_until_radio_group, 2);
549 elm_radio_value_set(p->repeat_until_radio_group, 0);
550 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
551 elm_entry_entry_set(p->repeat_occurrence_entry,times);
557 static Evas_Object *__cal_edit_repeat_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
559 Evas_Object *e_obj = NULL;
561 if (!CAL_STRCMP(part, "elm.icon"))
563 cal_edit_repeat_item_data *item_data = (cal_edit_repeat_item_data *)data;
564 cal_edit_repeat_data *p = item_data->p;
565 int repeat_type = item_data->repeat_type;
566 int repeat_index = item_data->repeat_index;
569 p->is_repeat_type = repeat_type;
570 e_obj = __cal_edit_repeat_add_radio_group(obj, __cal_edit_repeat_repeat_str[__cal_edit_repeat_repeat_index[repeat_index]], __cal_edit_repeat_repeat_index[repeat_index], p, item_data);
571 __cal_edit_repeat_set_selected_repeat_state(p);
575 p->is_repeat_type = false;
576 e_obj = __cal_edit_repeat_add_radio_group(obj, __cal_edit_repeat_repeat_until_str[__cal_edit_repeat_repeat_until_index[repeat_index]], __cal_edit_repeat_repeat_until_index[repeat_index], p, item_data);
577 __cal_edit_repeat_set_selected_repeat_until_state(p);
585 static void __cal_edit_repeat_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
589 Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
592 elm_genlist_item_selected_set(it, EINA_FALSE);
594 cal_edit_repeat_item_data *item_data = elm_object_item_data_get(it);
595 c_ret_if(!item_data);
597 cal_edit_repeat_data *p = item_data->p;
600 int type = item_data->repeat_type;
601 int index = item_data->repeat_index;
605 p->selected_repeat_radio = __cal_edit_repeat_repeat_index[index];
606 elm_radio_value_set(p->repeat_radio_group, __cal_edit_repeat_repeat_index[index]);
607 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
611 elm_radio_value_set(p->repeat_until_radio_group, __cal_edit_repeat_repeat_until_index[index]);
612 p->selected_repeat_until_radio = __cal_edit_repeat_repeat_until_index[index];
614 if (CALS_REPEAT_UNTIL_TYPE_COUNT != __cal_edit_repeat_repeat_until_index[index])
615 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
619 static void __cal_edit_repeat_add_separator(Evas_Object *genlist, cal_edit_repeat_data *p, int index)
621 cal_edit_repeat_item_data *item_data = NULL;
622 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
624 item_data->repeat_index = index;
625 item_data->repeat_type = index;
627 item_data->it = elm_genlist_item_append(genlist, &itc_seperator, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, NULL);
629 elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_NONE);
632 static void __cal_edit_repeat_add_repeat(Evas_Object *genlist, cal_edit_repeat_data *p)
635 for (i = 0; i < sizeof(__cal_edit_repeat_repeat_index)/sizeof(__cal_edit_repeat_repeat_index[0]); i++)
637 cal_edit_repeat_item_data *item_data = NULL;
638 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
641 item_data->repeat_index = i;
642 item_data->repeat_type = EINA_TRUE;
643 item_data->it = elm_genlist_item_append(genlist, &itc_1icon_1text, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, NULL);
647 static void __cal_edit_repeat_add_repeat_until(Evas_Object *genlist, cal_edit_repeat_data *p)
650 for (i = 0; i < sizeof(__cal_edit_repeat_repeat_until_index)/sizeof(__cal_edit_repeat_repeat_until_index[0]); i++)
652 cal_edit_repeat_item_data *item_data = NULL;
653 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
656 item_data->repeat_index = i;
657 item_data->repeat_type = EINA_FALSE;
658 if (CALS_REPEAT_UNTIL_TYPE_NONE != __cal_edit_repeat_repeat_until_index[i])
660 item_data->it = elm_genlist_item_append(genlist, &itc_1icon, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, NULL);
664 item_data->it = elm_genlist_item_append(genlist, &itc_1icon_1text, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, NULL);
669 static void __cal_edit_repeat_add_genlist_item(Evas_Object *genlist, cal_edit_repeat_data *p)
671 __cal_edit_repeat_add_separator(genlist, p, -1);
672 __cal_edit_repeat_add_repeat(genlist, p);
673 __cal_edit_repeat_add_separator(genlist, p, -2);
674 __cal_edit_repeat_add_repeat_until(genlist, p);
678 static int __cal_edit_repeat_add_content(cal_edit_repeat_data *p)
680 p->genlist = elm_genlist_add(p->ly);
681 CAL_ASSERT(p->genlist);
685 itc_seperator.item_style = "dialogue/title";
686 itc_seperator.func.text_get = __cal_edit_repeat_get_genlist_item_label;
687 itc_seperator.func.state_get = __cal_edit_repeat_get_genlist_item_state;
688 itc_seperator.func.del = __cal_edit_repeat_genlist_item_delete_callback;
690 itc_1icon_1text.item_style = "dialogue/1text.1icon.2";
691 itc_1icon_1text.func.text_get = __cal_edit_repeat_get_genlist_item_label;
692 itc_1icon_1text.func.del = __cal_edit_repeat_genlist_item_delete_callback;
693 itc_1icon_1text.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
695 itc_1icon.item_style = "dialogue/1icon";
696 itc_1icon.func.text_get = __cal_edit_repeat_get_genlist_item_label;
697 itc_1icon.func.del = __cal_edit_repeat_genlist_item_delete_callback;
698 itc_1icon.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
700 __cal_edit_repeat_add_genlist_item(p->genlist, p);
702 cf = elm_conformant_add(p->ad->win);
705 evas_object_size_hint_weight_set(cf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
706 evas_object_show(cf);
707 elm_object_content_set(cf, p->genlist);
708 elm_object_style_set(cf, "internal_layout");
709 elm_object_part_content_set(p->ly, "sw", cf);
714 static void __cal_edit_repeat_set_state(cal_edit_repeat_data *p, cal_repeat_term_t term, cal_repeat_until_type_t repeat_until_type, struct tm* repeat_end_date_time, int* occurrency, int flag)
716 p->selected_repeat_radio = term;
717 p->prev_selected_repeat_radio = term;
719 if (repeat_until_type == CALS_REPEAT_UNTIL_TYPE_NONE)
720 p->selected_repeat_until_radio = 0;
721 else if (repeat_until_type == CALS_REPEAT_UNTIL_TYPE_COUNT)
722 p->selected_repeat_until_radio = 1;
724 p->selected_repeat_until_radio = 2;
726 p->repeat_week_flag = flag;
729 Evas_Object *cal_edit_repeat_create_view(Evas_Object *parent, struct appdata* ad, cal_repeat_term_t term, cal_repeat_until_type_t repeat_until_type, struct tm* start_date_time, struct tm* repeat_end_date_time, int* occurrency, int flag)
733 c_retvm_if(!parent, NULL, "parent is null");
734 c_retvm_if(!ad, NULL, "ad is null");
738 cal_edit_repeat_data *p = calloc(1, sizeof(cal_edit_repeat_data));
739 c_retvm_if(!p, NULL, "p is null");
743 p->repeat_radio_group = NULL;
744 p->repeat_until_radio_group = NULL;
748 Evas_Object *ly = cal_util_add_layout(parent, "edit");
756 p->repeat_occurrence = *occurrency;
757 p->start_date_time = start_date_time;
758 p->repeat_end_date_time = *repeat_end_date_time;
760 evas_object_data_set(ly, "priv", p);
761 __cal_edit_repeat_repeat_str[CAL_REPEAT_NONE] = S_("IDS_COM_BODY_OFF");
762 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_DAY] = C_("IDS_KC_BODY_EVERY_DAY");
763 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_WEEK] = C_("IDS_CLD_BODY_EVERY_WEEK");
764 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_MONTH] = C_("IDS_CLD_BODY_EVERY_MONTH");
765 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_YEAR] = C_("IDS_CLD_BODY_EVERY_YEAR");
767 if (!__cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_2_WEEK]) {
769 const char *string = C_("IDS_CLD_BODY_EVERY_PD_WEEKS");
770 snprintf(buf, sizeof(buf), string, 2);
771 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_2_WEEK] = strdup(buf);
775 if (!__cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_3_DAY]) {
777 const char *string = C_("IDS_CLD_BODY_EVERY_PD_DAYS");
778 snprintf(buf, sizeof(buf), string, 3);
779 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_3_DAY] = strdup(buf);
781 __cal_edit_repeat_repeat_until_str[CAL_REPEAT_NONE] = S_("IDS_COM_BODY_NONE");
782 __cal_edit_repeat_repeat_until_str[CAL_REPEAT_EVERY_DAY] = C_("IDS_COM_POP_TIMES_LC");
784 __cal_edit_repeat_set_state(p, term, repeat_until_type, repeat_end_date_time, occurrency, flag);
786 int r = __cal_edit_repeat_add_content(p);
793 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_edit_repeat_delete_layout, p);