3 Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
5 This file is part of org.tizen.efl-calendar
6 Written by Taeho Kang <taeho84.kang@samsung.com>
8 PROPRIETARY/CONFIDENTIAL
10 This software is the confidential and proprietary information of
11 SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
12 disclose such Confidential Information and shall use it only in
13 accordance with the terms of the license agreement you entered
14 into with SAMSUNG ELECTRONICS.
16 SAMSUNG make no representations or warranties about the suitability
17 of the software, either express or implied, including but not limited
18 to the implied warranties of merchantability, fitness for a particular
19 purpose, or non-infringement. SAMSUNG shall not be liable for any
20 damages suffered by licensee as a result of using, modifying or
21 distributing this software or its derivatives.
26 #include "edit-repeat.h"
28 #define CAL_REPEAT_EVERY_2_WEEK (CAL_REPEAT_EVERY_YEAR+1)
29 #define CAL_REPEAT_EVERY_3_DAY (CAL_REPEAT_EVERY_2_WEEK+1)
31 static const char *_name = "calendar/edit/repeat";
37 Evas_Object *ly; // self
40 Evas_Object *repeat_radio_group;
41 Evas_Object *repeat_radio_group_member[7];
42 Evas_Object *repeat_until_radio_group;
44 Evas_Object *day_selector;
45 Evas_Object *repeat_occurrence_entry;
46 Evas_Object *end_date;
48 struct tm *start_date_time;
51 int repeat_occurrence;
52 struct tm repeat_end_date_time;
54 Eina_Bool is_repeat_type;
56 int selected_repeat_radio;
57 int prev_selected_repeat_radio;
58 int selected_repeat_until_radio;
60 cal_repeat_term_t repeat;
61 } cal_edit_repeat_data;
63 static char *__cal_edit_repeat_repeat_str[] = {
64 [CAL_REPEAT_NONE] = NULL,
65 [CAL_REPEAT_EVERY_DAY] = NULL,
66 [CAL_REPEAT_EVERY_WEEK] = NULL,
67 [CAL_REPEAT_EVERY_MONTH] = NULL,
68 [CAL_REPEAT_EVERY_YEAR] = NULL,
69 [CAL_REPEAT_EVERY_2_WEEK] = NULL,
70 [CAL_REPEAT_EVERY_3_DAY] = NULL,
73 static int __cal_edit_repeat_repeat_index[] = {
76 CAL_REPEAT_EVERY_WEEK,
77 CAL_REPEAT_EVERY_2_WEEK,
78 CAL_REPEAT_EVERY_MONTH,
79 CAL_REPEAT_EVERY_YEAR,
80 CAL_REPEAT_EVERY_3_DAY,
83 static const char *__cal_edit_repeat_repeat_until_str[] = {
84 [CAL_REPEAT_NONE] = NULL,
85 [CAL_REPEAT_EVERY_DAY] = NULL,
86 [CAL_REPEAT_EVERY_WEEK] = "",
89 static int __cal_edit_repeat_repeat_until_index[] = {
90 CALS_REPEAT_UNTIL_TYPE_NONE,
91 CALS_REPEAT_UNTIL_TYPE_COUNT,
92 CALS_REPEAT_UNTIL_TYPE_DATETIME,
95 static Elm_Entry_Filter_Limit_Size _limit_2char = {
98 static Elm_Entry_Filter_Accept_Set _digit_only = {
99 .accepted = "0123456789",
102 static Elm_Genlist_Item_Class itc_seperator, itc_1icon_1text, itc_1icon;
104 typedef struct __cal_edit_repeat_item_data cal_edit_repeat_item_data;
105 struct __cal_edit_repeat_item_data
107 cal_edit_repeat_data *p;
111 Evas_Object *item_radio;
114 #define is_leap_year_tm(y) (((y+1900)%4 == 0 && ((y+1900)%100 != 0 || (y+1900)%400 == 0))? 1 : 0)
116 static void __cal_edit_repeat_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
120 cal_edit_repeat_data *p = data;
125 static void __cal_edit_repeat_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
127 cal_edit_repeat_data *p;
128 Evas_Event_Mouse_Up *ev = ei;
131 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
134 p = CAL_UTIL_GET_PRIV_DATA(obj);
135 elm_radio_value_set(p->repeat_radio_group, val);
136 p->prev_selected_repeat_radio = p->selected_repeat_radio;
137 p->selected_repeat_radio = val;
140 static void __cal_edit_repeat_entry_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
145 Evas_Event_Mouse_Up *ev = ei;
148 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
151 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
152 elm_radio_value_set(p->repeat_until_radio_group, val);
154 if (CALS_REPEAT_UNTIL_TYPE_COUNT == val) {
155 elm_object_focus_set(p->repeat_occurrence_entry, EINA_TRUE);
156 elm_entry_cursor_end_set(p->repeat_occurrence_entry);
159 p->selected_repeat_until_radio = val;
161 const char* str = elm_entry_entry_get(p->repeat_occurrence_entry);
162 c_ret_if(!CAL_STRLEN(str));
164 p->repeat_occurrence = atoi(str);
167 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)
169 c_retvm_if(!ly, CAL_REPEAT_NONE, "ly is null");
171 const char* text = NULL;
173 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
174 c_retvm_if(!p, CAL_REPEAT_NONE, "p is null");
176 c_retvm_if(CAL_STRCMP(p->name, _name), CAL_REPEAT_NONE, "Invaild object.");
177 c_retvm_if(!p->repeat_radio_group, CAL_REPEAT_NONE, "p->repeat_radio_group is null");
178 c_retvm_if(!p->repeat_until_radio_group, CAL_REPEAT_NONE, "p->repeat_until_radio_group is null");
180 int repeat = p->selected_repeat_radio;
182 int raido_value = p->selected_repeat_until_radio;
183 if (raido_value == 0)
184 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_NONE;
185 else if (raido_value == 1)
186 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_COUNT;
188 *repeat_until_type = CALS_REPEAT_UNTIL_TYPE_DATETIME;
190 switch(*repeat_until_type) {
191 case CALS_REPEAT_UNTIL_TYPE_NONE:
194 *repeat_end_date_time = *p->start_date_time;
195 cal_util_update_tm_month(repeat_end_date_time, 1);
198 case CALS_REPEAT_UNTIL_TYPE_COUNT:
199 text = elm_entry_entry_get(p->repeat_occurrence_entry);
200 c_retvm_if(!text, CAL_REPEAT_NONE, "text is null");
202 *occurrency = atoi(text);
204 *repeat_end_date_time = *p->start_date_time;
205 cal_util_update_tm_month(repeat_end_date_time, 1);
209 case CALS_REPEAT_UNTIL_TYPE_DATETIME:
212 *repeat_end_date_time = p->repeat_end_date_time;
222 void cal_edit_repeat_get_repeat_str(cal_repeat_term_t term, int flag, char *buf, int sz)
224 const char *s = __cal_edit_repeat_repeat_str[term];
225 if (CAL_REPEAT_NONE == term || !s)
226 s = S_("IDS_COM_BODY_OFF");
228 CAL_STRNCPY(buf, s, sz);
232 static char *__cal_edit_repeat_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
234 c_retv_if(!data, NULL);
236 cal_edit_repeat_item_data *item_data = data;
238 int repeat_type = item_data->repeat_type;
239 int repeat_index = item_data->repeat_index;
241 if (!CAL_STRCMP(part, "elm.text")) {
242 switch (repeat_type) {
244 return strdup(C_("IDS_CLD_BODY_REPEAT"));
246 return strdup(C_("IDS_CLD_BODY_REPEAT_UNTIL"));
248 return strdup(__cal_edit_repeat_repeat_until_str[__cal_edit_repeat_repeat_until_index[repeat_index]]);
250 return strdup(__cal_edit_repeat_repeat_str[__cal_edit_repeat_repeat_index[repeat_index]]);
259 static void __cal_edit_repeat_genlist_item_delete_callback(void *data, Evas_Object *obj)
263 cal_edit_repeat_item_data *item_data = data;
265 if (item_data->repeat_type) {
267 cal_edit_repeat_data* p = item_data->p;
269 c_ret_if(!p->repeat_radio_group_member);
271 p->repeat_radio_group_member[item_data->repeat_index] = NULL;
277 static Eina_Bool __cal_edit_repeat_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
282 static void __cal_edit_repeat_set_radio_group(cal_edit_repeat_data *p, Evas_Object *rd, int val)
284 if (p->is_repeat_type) {
287 p->repeat_radio_group = rd;
289 elm_radio_group_add(p->repeat_radio_group_member[1], p->repeat_radio_group);
290 elm_radio_group_add(p->repeat_radio_group_member[2], p->repeat_radio_group);
291 elm_radio_group_add(p->repeat_radio_group_member[3], p->repeat_radio_group);
292 elm_radio_group_add(p->repeat_radio_group_member[4], p->repeat_radio_group);
293 elm_radio_group_add(p->repeat_radio_group_member[5], p->repeat_radio_group);
294 elm_radio_group_add(p->repeat_radio_group_member[6], p->repeat_radio_group);
297 elm_radio_group_add(rd, p->repeat_radio_group);
301 p->repeat_until_radio_group = rd;
303 elm_radio_group_add(rd, p->repeat_until_radio_group);
307 static Evas_Object* __cal_edit_repeat_add_custom_text_object(cal_edit_repeat_data *p, Evas_Object *dg, const char *text)
309 Evas_Object *entry = NULL;
311 if (!text || text[0] == '\0')
314 entry = elm_entry_add(dg);
317 elm_entry_single_line_set(entry, EINA_TRUE);
318 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
319 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
320 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
321 elm_entry_editable_set(entry, EINA_FALSE);
322 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
323 elm_entry_autocapital_type_set(entry, EINA_TRUE);
325 elm_entry_entry_set(entry,text);
330 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)
332 c_retvm_if(!dg, NULL, "dg is NULL.");
333 c_retvm_if(!p, NULL, "p is NULL.");
334 c_retvm_if(!item_data, NULL, "item_data is NULL.");
336 Evas_Object *rd = elm_radio_add(dg);
337 c_retvm_if(!rd, NULL, "rd is NULL.");
339 evas_object_propagate_events_set(rd, EINA_TRUE);
341 elm_radio_state_value_set(rd, val);
343 item_data->item_radio = rd;
345 if (item_data->repeat_type)
346 *(p->repeat_radio_group_member + val) = rd;
348 __cal_edit_repeat_set_radio_group(p, rd, val);
350 evas_object_show(rd);
351 evas_object_data_set(rd, "priv", p);
353 if (p->is_repeat_type)
354 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_clicked_callback, (void *)val);
355 else if (0 == val || 1 == val)
356 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)val);
361 static void __cal_edit_repeat_entry_unfocused(void *data, Evas_Object *obj, void *event_info)
363 cal_edit_repeat_data *p = (cal_edit_repeat_data *)data;
365 char times[8] = {0,};
366 snprintf(times, 7, "%d", p->repeat_occurrence);
367 elm_entry_entry_set(p->repeat_occurrence_entry, times);
371 static void __cal_edit_repeat_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
374 cal_edit_repeat_data *p = data;
376 const char *s = elm_entry_entry_get(p->repeat_occurrence_entry);
377 p->repeat_occurrence = atoi(s);
380 static Evas_Object* __cal_edit_repeat_add_entry(Evas_Object *parent, cal_edit_repeat_data *p)
383 Ecore_IMF_Context *ic;
385 e = elm_entry_add(parent);
389 elm_object_style_set(e, "font_color_black");
390 elm_entry_single_line_set(e, EINA_TRUE);
391 elm_entry_markup_filter_append(e, elm_entry_filter_limit_size, &_limit_2char);
392 elm_entry_markup_filter_append(e, elm_entry_filter_accept_set, &_digit_only);
393 elm_entry_input_panel_layout_set(e, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
394 elm_entry_context_menu_disabled_set(e, EINA_TRUE);
396 ic = elm_entry_imf_context_get(e);
400 evas_object_smart_callback_add(e, "unfocused", __cal_edit_repeat_entry_unfocused, p);
401 evas_object_smart_callback_add(e, "changed", __cal_edit_repeat_entry_changed_callback, p);
407 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)
412 Evas_Object *entry_times;
413 char times[8] = {0,};
415 ly = cal_util_add_layout(dg, "dialoguegroup/repeat/times");
419 entry_times = __cal_edit_repeat_add_custom_text_object(p, dg, text);
425 elm_object_part_content_set(ly, "text", entry_times);
427 evas_object_show(ly);
428 evas_object_data_set(ly, "priv", p);
429 evas_object_event_callback_add(ly, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)val);
431 rd = elm_radio_add(dg);
437 elm_radio_state_value_set(rd, val);
438 elm_object_part_content_set(ly, "content", rd);
439 item_data->item_radio = rd;
440 __cal_edit_repeat_set_radio_group(p, rd, val);
442 entry = __cal_edit_repeat_add_entry(ly, p);
448 elm_object_part_content_set(ly, "input_sw", entry);
450 p->repeat_occurrence_entry = entry;
451 snprintf(times, 7, "%d", p->repeat_occurrence);
452 elm_entry_entry_set(p->repeat_occurrence_entry, times);
457 static void __cal_edit_repeat_end_date_changed_callback(void *data, Evas_Object *obj, void *ei)
459 cal_edit_repeat_data *p = data;
461 elm_datetime_value_get(obj, &p->repeat_end_date_time);
464 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)
466 Evas_Object *ly = cal_util_add_layout(dg, "dialoguegroup/tm");
467 c_retvm_if(!ly, NULL, "ly is null");
469 evas_object_show(ly);
470 evas_object_data_set(ly, "priv", p);
472 Evas_Object *rd = elm_radio_add(dg);
478 evas_object_propagate_events_set(rd, EINA_TRUE);
480 elm_radio_state_value_set(rd, val);
482 elm_object_part_content_set(ly, "content", rd);
483 item_data->item_radio = rd;
485 if (item_data->repeat_type)
486 *(p->repeat_radio_group_member + val) = rd;
488 __cal_edit_repeat_set_radio_group(p, rd, val);
490 Evas_Object *datetime = cal_util_add_datetime(dg, NULL, repeat_end_date);
491 c_retvm_if(!datetime, NULL, "datetime is null");
493 elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
494 elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
495 elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
497 elm_datetime_field_limit_set(datetime, ELM_DATETIME_YEAR, 70, 137);
499 evas_object_smart_callback_add(datetime,"changed", __cal_edit_repeat_end_date_changed_callback, p);
501 elm_object_part_content_set(ly, "datefield", datetime);
506 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)
508 if (p->is_repeat_type) {
509 return __cal_edit_repeat_add_radio(dg, val, p, item_data);
514 return __cal_edit_repeat_add_radio(dg, val, p, item_data);
516 return __cal_edit_repeat_add_times(dg, text, val, p, item_data);
518 return __cal_edit_repeat_add_radio_tm(dg, &p->repeat_end_date_time, val, p, item_data);
526 static void __cal_edit_repeat_set_selected_repeat_state(cal_edit_repeat_data *p)
528 elm_radio_value_set(p->repeat_radio_group, p->selected_repeat_radio);
531 static void __cal_edit_repeat_set_selected_repeat_until_state(cal_edit_repeat_data *p)
535 char times[10] = {0};
537 switch (p->selected_repeat_until_radio) {
539 elm_radio_value_set(p->repeat_until_radio_group, 1);
540 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
541 elm_entry_entry_set(p->repeat_occurrence_entry,times);
545 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
546 elm_entry_entry_set(p->repeat_occurrence_entry,times);
547 elm_radio_value_set(p->repeat_until_radio_group, 2);
552 elm_radio_value_set(p->repeat_until_radio_group, 0);
553 snprintf(times,sizeof(times),"%d", p->repeat_occurrence);
554 elm_entry_entry_set(p->repeat_occurrence_entry,times);
560 static Evas_Object *__cal_edit_repeat_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
562 Evas_Object *e_obj = NULL;
564 if (!CAL_STRCMP(part, "elm.icon"))
566 cal_edit_repeat_item_data *item_data = (cal_edit_repeat_item_data *)data;
567 cal_edit_repeat_data *p = item_data->p;
568 int repeat_type = item_data->repeat_type;
569 int repeat_index = item_data->repeat_index;
572 p->is_repeat_type = repeat_type;
573 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);
574 __cal_edit_repeat_set_selected_repeat_state(p);
578 p->is_repeat_type = false;
579 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);
580 __cal_edit_repeat_set_selected_repeat_until_state(p);
588 static void __cal_edit_repeat_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
592 Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
595 elm_genlist_item_selected_set(it, EINA_FALSE);
597 cal_edit_repeat_item_data *item_data = elm_object_item_data_get(it);
598 c_ret_if(!item_data);
600 cal_edit_repeat_data *p = item_data->p;
603 int type = item_data->repeat_type;
604 int index = item_data->repeat_index;
608 p->selected_repeat_radio = __cal_edit_repeat_repeat_index[index];
609 elm_radio_value_set(p->repeat_radio_group, __cal_edit_repeat_repeat_index[index]);
610 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
614 elm_radio_value_set(p->repeat_until_radio_group, __cal_edit_repeat_repeat_until_index[index]);
615 p->selected_repeat_until_radio = __cal_edit_repeat_repeat_until_index[index];
617 if (CALS_REPEAT_UNTIL_TYPE_COUNT != __cal_edit_repeat_repeat_until_index[index])
618 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
622 static void __cal_edit_repeat_add_separator(Evas_Object *genlist, cal_edit_repeat_data *p, int index)
624 cal_edit_repeat_item_data *item_data = NULL;
625 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
627 item_data->repeat_index = index;
628 item_data->repeat_type = index;
630 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);
632 elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_NONE);
635 static void __cal_edit_repeat_add_repeat(Evas_Object *genlist, cal_edit_repeat_data *p)
638 for (i = 0; i < sizeof(__cal_edit_repeat_repeat_index)/sizeof(__cal_edit_repeat_repeat_index[0]); i++)
640 cal_edit_repeat_item_data *item_data = NULL;
641 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
644 item_data->repeat_index = i;
645 item_data->repeat_type = EINA_TRUE;
646 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);
650 static void __cal_edit_repeat_add_repeat_until(Evas_Object *genlist, cal_edit_repeat_data *p)
653 for (i = 0; i < sizeof(__cal_edit_repeat_repeat_until_index)/sizeof(__cal_edit_repeat_repeat_until_index[0]); i++)
655 cal_edit_repeat_item_data *item_data = NULL;
656 CAL_CALLOC(item_data, 1, cal_edit_repeat_item_data);
659 item_data->repeat_index = i;
660 item_data->repeat_type = EINA_FALSE;
661 if (CALS_REPEAT_UNTIL_TYPE_NONE != __cal_edit_repeat_repeat_until_index[i])
663 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);
667 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);
672 static void __cal_edit_repeat_add_genlist_item(Evas_Object *genlist, cal_edit_repeat_data *p)
674 __cal_edit_repeat_add_separator(genlist, p, -1);
675 __cal_edit_repeat_add_repeat(genlist, p);
676 __cal_edit_repeat_add_separator(genlist, p, -2);
677 __cal_edit_repeat_add_repeat_until(genlist, p);
681 static int __cal_edit_repeat_add_content(cal_edit_repeat_data *p)
683 p->genlist = elm_genlist_add(p->ly);
684 CAL_ASSERT(p->genlist);
688 itc_seperator.item_style = "dialogue/title";
689 itc_seperator.func.text_get = __cal_edit_repeat_get_genlist_item_label;
690 itc_seperator.func.state_get = __cal_edit_repeat_get_genlist_item_state;
691 itc_seperator.func.del = __cal_edit_repeat_genlist_item_delete_callback;
693 itc_1icon_1text.item_style = "dialogue/1text.1icon.2";
694 itc_1icon_1text.func.text_get = __cal_edit_repeat_get_genlist_item_label;
695 itc_1icon_1text.func.del = __cal_edit_repeat_genlist_item_delete_callback;
696 itc_1icon_1text.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
698 itc_1icon.item_style = "dialogue/1icon";
699 itc_1icon.func.text_get = __cal_edit_repeat_get_genlist_item_label;
700 itc_1icon.func.del = __cal_edit_repeat_genlist_item_delete_callback;
701 itc_1icon.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
703 __cal_edit_repeat_add_genlist_item(p->genlist, p);
705 cf = elm_conformant_add(p->ad->win);
708 evas_object_size_hint_weight_set(cf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
709 evas_object_show(cf);
710 elm_object_content_set(cf, p->genlist);
711 elm_object_style_set(cf, "internal_layout");
712 elm_object_part_content_set(p->ly, "sw", cf);
717 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)
719 p->selected_repeat_radio = term;
720 p->prev_selected_repeat_radio = term;
722 if (repeat_until_type == CALS_REPEAT_UNTIL_TYPE_NONE)
723 p->selected_repeat_until_radio = 0;
724 else if (repeat_until_type == CALS_REPEAT_UNTIL_TYPE_COUNT)
725 p->selected_repeat_until_radio = 1;
727 p->selected_repeat_until_radio = 2;
729 p->repeat_week_flag = flag;
732 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)
736 c_retvm_if(!parent, NULL, "parent is null");
737 c_retvm_if(!ad, NULL, "ad is null");
741 cal_edit_repeat_data *p = calloc(1, sizeof(cal_edit_repeat_data));
742 c_retvm_if(!p, NULL, "p is null");
746 p->repeat_radio_group = NULL;
747 p->repeat_until_radio_group = NULL;
751 Evas_Object *ly = cal_util_add_layout(parent, "edit");
759 p->repeat_occurrence = *occurrency;
760 p->start_date_time = start_date_time;
761 p->repeat_end_date_time = *repeat_end_date_time;
763 evas_object_data_set(ly, "priv", p);
764 __cal_edit_repeat_repeat_str[CAL_REPEAT_NONE] = S_("IDS_COM_BODY_OFF");
765 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_DAY] = C_("IDS_KC_BODY_EVERY_DAY");
766 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_WEEK] = C_("IDS_CLD_BODY_EVERY_WEEK");
767 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_MONTH] = C_("IDS_CLD_BODY_EVERY_MONTH");
768 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_YEAR] = C_("IDS_CLD_BODY_EVERY_YEAR");
770 if (!__cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_2_WEEK]) {
772 const char *string = C_("IDS_CLD_BODY_EVERY_PD_WEEKS");
773 snprintf(buf, sizeof(buf), string, 2);
774 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_2_WEEK] = strdup(buf);
778 if (!__cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_3_DAY]) {
780 const char *string = C_("IDS_CLD_BODY_EVERY_PD_DAYS");
781 snprintf(buf, sizeof(buf), string, 3);
782 __cal_edit_repeat_repeat_str[CAL_REPEAT_EVERY_3_DAY] = strdup(buf);
784 __cal_edit_repeat_repeat_until_str[CAL_REPEAT_NONE] = S_("IDS_COM_BODY_NONE");
785 __cal_edit_repeat_repeat_until_str[CAL_REPEAT_EVERY_DAY] = C_("IDS_COM_POP_TIMES_LC");
787 __cal_edit_repeat_set_state(p, term, repeat_until_type, repeat_end_date_time, occurrency, flag);
789 int r = __cal_edit_repeat_add_content(p);
796 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_edit_repeat_delete_layout, p);