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.
26 static const char *_name = "main/day";
32 Evas_Object *ly; // self
34 Evas_Object *time_block; // layout
40 static char* __cal_day_get_genlist_item_label(void *data, Evas_Object *obj, const char *part);
41 static Elm_Genlist_Item_Class itc = {
42 .item_style = "dialogue/1text",
43 .func.text_get = __cal_day_get_genlist_item_label,
46 static void __cal_day_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
52 struct _priv *p = data;
54 CALENDAR_SVC_FREE_CS(&p->csv);
59 static char* __cal_day_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
61 struct tmnode *tm = (struct tmnode *)data;
67 if (!CAL_STRCMP(part, "elm.text")) {
68 str = CALENDAR_SVC_STRUCT_GET_STR(tm->cs, CAL_VALUE_TXT_SUMMARY);
72 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
78 static void __cal_day_genlist_item_select_callback(void *data, Evas_Object *obj, void *ei)
81 struct tmnode* tm = (struct tmnode*)data;
82 cal_struct *cs = tm->cs;
86 it = elm_genlist_selected_item_get(obj);
88 elm_genlist_item_selected_set(it, EINA_FALSE);
90 idx = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_INDEX);
92 p = CAL_UTIL_GET_PRIV_DATA(obj);
96 memcpy(p->ad->tm, tm, sizeof(struct tmnode));
98 cal_detail_create_view(p->ad, p->parent);
101 static void __cal_day_get_events(struct _priv *p)
105 cal_util_get_day_time_t(&p->ad->base_tm, &st, &et);
107 p->csv = CALENDAR_SVC_GET_EVENT(p->ad->acct_id, st, et);
110 void cal_day_update_genlist(Evas_Object *ly)
116 struct _priv *p = CAL_UTIL_GET_PRIV_DATA (ly);
118 c_ret_if(!p->genlist);
124 elm_genlist_clear(p->genlist);
125 CALENDAR_SVC_FREE_CS(&p->csv);
127 __cal_day_get_events(p);
131 EINA_LIST_FOREACH(p->csv->tmlist, l, tm) {
134 int allday = CALENDAR_SVC_STRUCT_GET_INT(tm->cs, CAL_VALUE_INT_ALL_DAY_EVENT);
136 elm_genlist_item_append(p->genlist, &itc, tm, NULL,
137 ELM_GENLIST_ITEM_NONE, __cal_day_genlist_item_select_callback, tm);
146 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(p->ly), "go,line%d", line);
149 Evas_Object* cal_day_create_view(struct appdata *ad, Evas_Object *main)
155 Evas_Object *genlist;
156 Evas_Object *time_block;
160 CAL_CALLOC(p, 1, struct _priv);
166 ly = cal_util_add_layout(ad->nv, p->name);
170 evas_object_data_set(ly, "priv", p);
172 genlist = elm_genlist_add(ly);
175 p->genlist = genlist;
176 elm_object_part_content_set(ly, "list/sw", genlist);
177 evas_object_data_set(genlist, "priv", p);
179 time_block = cal_day_create_time_block(&ad->base_tm, ad, ly);
180 CAL_ASSERT (time_block);
182 p->time_block = time_block;
183 elm_object_part_content_set(ly, "cont/sw", time_block);
185 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_day_delete_layout, p);
190 void cal_day_update_view(Evas_Object *ly)
198 p = CAL_UTIL_GET_PRIV_DATA(ly);
199 if (!p || CAL_STRCMP(p->name, _name)) {
200 ERR("Invalid object");
204 cal_day_update_genlist(ly);
206 cal_day_time_update_time_block(p->time_block, &p->ad->base_tm);