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://floralicense.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.
19 #include "gi-radio-timepicker.h"
20 #include "gi-timepicker.h"
24 cal_radio_group_h radio_group;
25 Elm_Object_Item* timepicker;
28 } __cal_genlist_item_radio_timepicker_info;
30 static void __cal_genlist_item_radio_timepicker_radio_changed(
31 unsigned int index, bool selected, void* data)
35 __cal_genlist_item_radio_timepicker_info* info = (__cal_genlist_item_radio_timepicker_info*)data;
38 elm_object_item_del(info->timepicker);
39 info->timepicker = NULL;
43 static Evas_Object *__cal_genlist_item_radio_timepicker_icon(
44 void *data, Evas_Object *obj, const char *part)
48 __cal_genlist_item_radio_timepicker_info* info = (__cal_genlist_item_radio_timepicker_info*)data;
50 Evas_Object* rd = elm_radio_add(obj);
51 c_retvm_if(!rd, NULL, "rd is NULL");
53 elm_object_part_content_set(rd, "content", rd);
55 cal_radio_group_set_radio_object(info->radio_group, info->radio_index, rd);
58 evas_object_data_set(rd, "priv", info);
60 cal_radio_group_set_changed_callback(info->radio_group, info->radio_index,
61 __cal_genlist_item_radio_timepicker_radio_changed, info);
66 static char *__cal_genlist_item_radio_timepicker_label(void *data, Evas_Object *obj, const char *part)
68 return strdup(C_("IDS_COM_BODY_CUSTOMISE"));
71 static void __cal_genlist_item_radio_timepicker_select_callback(
72 void* data, Evas_Object* obj, void* event_info)
76 __cal_genlist_item_radio_timepicker_info* info = (__cal_genlist_item_radio_timepicker_info*)data;
77 Elm_Object_Item* item = elm_genlist_selected_item_get(obj);
79 cal_radio_group_select_radio(info->radio_group, info->radio_index);
80 elm_genlist_item_selected_set(item, EINA_FALSE);
82 if (info->timepicker == NULL) {
83 info->timepicker = cal_genlist_item_timepicker_add(obj, " ", info->value, EINA_FALSE, NULL, NULL);
87 static void __cal_genlist_item_radio_timepicker_delete_callback(void *data, Evas_Object *obj)
89 __cal_genlist_item_radio_timepicker_info* info = (__cal_genlist_item_radio_timepicker_info*)data;
93 Elm_Object_Item* cal_genlist_item_radio_timepicker_add(
94 Evas_Object* genlist, cal_radio_group_h radio_group, int radio_index,
95 bool expanded, struct tm* value, void* data)
99 static Elm_Genlist_Item_Class* itc = NULL;
101 itc = (Elm_Genlist_Item_Class*)calloc(1, sizeof(Elm_Genlist_Item_Class));
102 itc->item_style = "dialogue/1text.1icon.2";
103 itc->func.del = __cal_genlist_item_radio_timepicker_delete_callback;
104 itc->func.content_get = __cal_genlist_item_radio_timepicker_icon;
105 itc->func.text_get = __cal_genlist_item_radio_timepicker_label;
108 __cal_genlist_item_radio_timepicker_info* info =
109 (__cal_genlist_item_radio_timepicker_info*)calloc(1, sizeof(__cal_genlist_item_radio_timepicker_info));
112 info->radio_group = radio_group;
113 info->radio_index = radio_index;
116 Elm_Object_Item* item = elm_genlist_item_append(genlist, itc, info, NULL, ELM_GENLIST_ITEM_NONE,
117 __cal_genlist_item_radio_timepicker_select_callback, info);
120 info->timepicker = cal_genlist_item_timepicker_add(genlist, " ", info->value, EINA_FALSE, NULL, NULL);
122 info->timepicker = NULL;
129 void cal_genlist_item_radio_timepicker_get_time(Elm_Object_Item* radio_timepicker, struct tm* datetime)
131 c_retm_if(radio_timepicker == NULL, "radio_timepicker is null");
133 __cal_genlist_item_radio_timepicker_info* info =
134 (__cal_genlist_item_radio_timepicker_info*)elm_object_item_data_get(radio_timepicker);
136 cal_genlist_item_radio_timepicker_get_value(info->timepicker, datetime);