2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
20 #include "cst-common.h"
21 #include "cst-common-string.h"
22 #include "cst-widget.h"
24 #include "cst-prefix-dial.h"
26 static Elm_Genlist_Item_Class *itc_ime = NULL;
27 static Elm_Genlist_Item_Class *itc_1text_1icon = NULL;
29 static void __cst_on_click_prefix_dialling_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info);
30 static CstGlItemDisplayInfo_t list_dep1_prefix_dialling[] = {
31 {1, CST_STR_AUTO_AREA_CODE, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF, __cst_on_click_prefix_dialling_onoff},
32 {1, -1, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_NONE, NULL},
35 static void __cst_on_click_prefix_dialling_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info)
37 ENTER(__cst_on_click_prefix_dialling_onoff);
39 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
40 CstUgData_t *ugd = item_data->ugd;
41 Eina_Bool check_state = elm_check_state_get(item_data->eo_check);
42 if (CST_STR_AUTO_AREA_CODE == list_dep1_prefix_dialling[item_data->index].str_id) {
43 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, !check_state);
44 if (ugd->prefix_gl_list_item != NULL) {
45 Ecore_IMF_Context *imf_context;
46 imf_context = elm_entry_imf_context_get(ugd->dg_entry);
47 elm_object_item_disabled_set(ugd->prefix_gl_list_item, check_state);
48 ecore_imf_context_input_panel_enabled_set(imf_context, !(check_state));
52 elm_genlist_item_update(item_data->gl_item);
55 static void __cst_on_changed_enable_prefix_dialling_check(void *data, Evas_Object *obj, void *event_info)
57 ENTER(__cst_on_changed_enable_prefix_dialling_check);
59 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
60 CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
61 Eina_Bool check_state;
62 check_state = elm_check_state_get(obj);
64 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, check_state);
65 if (ugd->prefix_gl_list_item != NULL) {
66 Ecore_IMF_Context *imf_context;
67 imf_context = elm_entry_imf_context_get(ugd->dg_entry);
68 elm_object_item_disabled_set(ugd->prefix_gl_list_item, !(check_state));
69 ecore_imf_context_input_panel_enabled_set(imf_context, check_state);
73 static Evas_Object *__cst_gl_icon_get_prefix_dailling(void *data, Evas_Object *obj, const char *part)
75 ENTER(__cst_gl_icon_get_prefix_dailling);
76 retv_if(NULL == data, NULL);
77 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
79 if (!strcmp(part, "elm.icon")) {
80 if (CST_STR_AUTO_AREA_CODE == list_dep1_prefix_dialling[item_data->index].str_id) {
82 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &value);
83 item_data->eo_check = _cst_create_onoff_button(obj, value,
84 __cst_on_changed_enable_prefix_dialling_check, item_data);
86 return item_data->eo_check;
91 static char *__cst_gl_label_get_prefix_dailling(void *data, Evas_Object *obj, const char *part)
93 retv_if(NULL == data, NULL);
94 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
96 if (!strcmp(part, "elm.text") || !strcmp(part, "elm.text.1")) {
97 if (list_dep1_prefix_dialling[item_data->index].str_id != -1)
98 return strdup(T_(list_dep1_prefix_dialling[item_data->index].str_id));
103 static void __cst_gl_del_prefix_dailling(void *data, Evas_Object *obj)
105 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
107 if (item_data->label)
108 free(item_data->label);
115 static void __cst_gl_sel_prefix_dailling(void *data, Evas_Object *obj, void *event_info)
117 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
118 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
119 CstGlItemData_t *item_data = (CstGlItemData_t *)elm_object_item_data_get(item);
121 if (list_dep1_prefix_dialling[item_data->index].func)
122 list_dep1_prefix_dialling[item_data->index].func(item_data, NULL, obj, event_info);
126 static Evas_Object *__cst_gl_icon_get_prefix_dialling_ime(void *data, Evas_Object *obj, const char *part)
128 retv_if(data == NULL, NULL);
129 CstUgData_t *ugd = (CstUgData_t *)data;
131 if (!strcmp(part, "elm.icon")) {
132 char *buf = _cst_get_prefix_dialling_list(CST_ITEM_1);
133 return _cst_create_ime_editfield(ugd, obj, CST_IME_PREFIX_DIAL, buf);
139 static Evas_Object *__cst_create_prefix_dialling_ime_genlist(CstUgData_t *ugd)
141 ENTER(__cst_create_prefix_dialling_ime_genlist);
142 Evas_Object *genlist;
144 genlist = elm_genlist_add(ugd->nf);
145 elm_object_style_set(genlist, "dialogue");
147 _cst_create_genlist_separator(genlist, EINA_FALSE);
148 CstGlItemData_t *item_data = (CstGlItemData_t *)calloc(1, sizeof(CstGlItemData_t));
149 retv_if(item_data == NULL, NULL);
150 item_data->index = 0;
151 item_data->ugd = ugd;
153 item_data->gl_item = elm_genlist_item_append(genlist, itc_1text_1icon,
154 (void *)item_data, NULL, list_dep1_prefix_dialling[0].flags,
155 __cst_gl_sel_prefix_dailling, ugd);
157 ugd->prefix_gl_list_item = elm_genlist_item_append(genlist, itc_ime,
158 (void *)ugd, NULL, ELM_GENLIST_ITEM_NONE,
162 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &value);
163 elm_object_item_disabled_set(ugd->prefix_gl_list_item, !(value));
167 static void __cst_set_genlist_item_styles(void)
169 ENTER(__cst_set_genlist_item_styles);
172 itc_ime = elm_genlist_item_class_new();
173 if (!itc_1text_1icon)
174 itc_1text_1icon = elm_genlist_item_class_new();
176 itc_ime->item_style = "1icon";
177 itc_ime->func.text_get = NULL;
178 itc_ime->func.content_get = __cst_gl_icon_get_prefix_dialling_ime;
179 itc_ime->func.state_get = NULL;
180 itc_ime->func.del = NULL;
182 itc_1text_1icon->item_style = "dialogue/1text.1icon";
183 itc_1text_1icon->func.text_get = __cst_gl_label_get_prefix_dailling;
184 itc_1text_1icon->func.content_get = __cst_gl_icon_get_prefix_dailling;
185 itc_1text_1icon->func.state_get = NULL;
186 itc_1text_1icon->func.del = __cst_gl_del_prefix_dailling;
189 Evas_Object *_cst_create_prefix_dialling_ime(Evas_Object *parent, char *edit_string, void *data)
191 ENTER(_cst_create_prefix_dialling_ime);
192 retv_if(NULL == data, NULL);
193 CstUgData_t *ugd = (CstUgData_t *)data;
195 __cst_set_genlist_item_styles();
196 Evas_Object *genlist = __cst_create_prefix_dialling_ime_genlist(ugd);