4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * GirishAshok Joshi <girish.joshi@samsung.com>
8 * DoHyun Pyun <dh79.pyun@samsung.com>
10 * Licensed under the Flora License, Version 1.1 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.tizenopensource.org/license
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
25 #include "bt-widget.h"
26 #include "bt-main-ug.h"
27 #include "bt-type-define.h"
28 #include "bt-string-define.h"
30 Evas_Object *_bt_create_naviframe(Evas_Object *parent)
36 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL");
38 nf = elm_naviframe_add(parent);
39 elm_object_part_content_set(parent, "elm.swallow.content", nf);
47 Evas_Object *_bt_create_icon(Evas_Object *parent, char *img)
51 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL");
52 retvm_if(img == NULL, NULL, "Invalid argument: img is NULL");
53 retvm_if(strlen(img) >= BT_IMG_PATH_MAX, NULL, "image path is wrong [%s]", img);
55 ic = elm_image_add(parent);
57 elm_image_file_set(ic, BT_ICON_EDJ, img);
58 evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
59 evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
63 elm_image_resizable_set(ic, 1, 1);
70 Evas_Object *_bt_create_progressbar(Evas_Object *parent, const char *style)
74 Evas_Object *progress_bar = NULL;
76 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL");
78 progress_bar = elm_progressbar_add(parent);
81 elm_object_style_set(progress_bar, style);
83 elm_object_style_set(progress_bar, "process_large");
85 elm_progressbar_horizontal_set(progress_bar, EINA_TRUE);
86 evas_object_propagate_events_set(progress_bar, EINA_FALSE);
87 evas_object_show(progress_bar);
88 elm_progressbar_pulse(progress_bar, EINA_TRUE);
95 void _bt_update_genlist_item(Elm_Object_Item *item)
98 elm_genlist_item_fields_update(item, "*",
99 ELM_GENLIST_ITEM_FIELD_TEXT);
100 elm_genlist_item_fields_update(item, "*",
101 ELM_GENLIST_ITEM_FIELD_CONTENT);
104 static Evas_Object *__bt_create_bg(Evas_Object *parent, char *style)
110 retvm_if(!parent, NULL, "Invalid argument: parent is NULL");
112 bg = elm_bg_add(parent);
116 elm_object_style_set(bg, style);
118 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
120 evas_object_show(bg);
127 Evas_Object *_bt_main_base_layout_create(Evas_Object *parent, void *data)
131 Evas_Object *layout = NULL;
133 layout = elm_layout_add(parent);
134 retv_if(!layout, NULL);
137 elm_layout_file_set(layout, BT_COMMON_MAIN_LAYOUT_EDJ, "main_layout");
139 Evas_Object *bg = NULL;
141 elm_layout_theme_set(layout, "layout", "application", "default");
143 bg = __bt_create_bg(layout, "default");
144 elm_object_part_content_set(layout, "elm.swallow.bg", bg);
145 evas_object_show(layout);
152 void _bt_set_popup_text(void *data, Evas_Object *popup)
157 bt_ug_data *ugd = (bt_ug_data *)data;
159 char temp[BT_POPUP_STR_MAX_LEN] = { 0 };
160 char *markup_text = NULL;
161 char *popup_text = NULL;
162 switch (ugd->popup_data.type) {
163 case BT_POPUP_PAIRING_ERROR:
164 if (ugd->popup_data.data) {
165 popup_text = BT_STR_UNABLE_TO_PAIR_WITH_PS;
166 snprintf(temp, BT_POPUP_STR_MAX_LEN, popup_text, (char *)ugd->popup_data.data);
169 case BT_POPUP_CONNECTION_ERROR:
170 if (ugd->popup_data.data) {
171 popup_text = BT_STR_UNABLE_TO_CONNECT_TO_PS;
172 snprintf(temp, BT_POPUP_STR_MAX_LEN, popup_text, (char *)ugd->popup_data.data);
175 case BT_POPUP_DISCONNECT:
176 if (ugd->popup_data.data) {
177 popup_text = BT_STR_END_CONNECTION;
178 snprintf(temp, BT_POPUP_STR_MAX_LEN, popup_text, (char *)ugd->popup_data.data);
181 case BT_POPUP_GET_SERVICE_LIST_ERROR:
182 case BT_POPUP_GETTING_SERVICE_LIST:
183 case BT_POPUP_ENTER_DEVICE_NAME:
184 case BT_POPUP_LOW_BATTERY:
189 markup_text = elm_entry_utf8_to_markup(temp);
190 elm_object_text_set(popup, markup_text);
194 Evas_Object *_bt_create_popup(void *data, void *cb,
195 void *cb_data, int timer_val)
198 retvm_if(!data, NULL, "Invalid argument: ugd is NULL");
199 bt_ug_data *ugd = (bt_ug_data *)data;
200 retvm_if(!ugd->win_main, NULL, "Invalid argument: win_main is NULL");
202 Evas_Object *popup = NULL;
204 popup = elm_popup_add(ugd->win_main);
205 retvm_if(!popup, NULL, "fail to create popup");
207 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
209 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
211 switch (ugd->popup_data.type) {
212 case BT_POPUP_PAIRING_ERROR:
213 case BT_POPUP_GET_SERVICE_LIST_ERROR:
214 case BT_POPUP_CONNECTION_ERROR:
215 case BT_POPUP_ENTER_DEVICE_NAME:
216 case BT_POPUP_LOW_BATTERY:
217 elm_object_domain_translatable_part_text_set(
219 PKGNAME, "IDS_BT_HEADER_BLUETOOTH_ERROR_ABB");
222 case BT_POPUP_GETTING_SERVICE_LIST:
223 elm_object_domain_translatable_part_text_set(
225 PKGNAME, "IDS_BT_HEADER_BLUETOOTH");
227 case BT_POPUP_DISCONNECT:
228 elm_object_domain_translatable_part_text_set(
230 PKGNAME, "IDS_BT_HEADER_DISCONNECT_DEVICE_ABB");
234 /* Set content text */
235 if (ugd->popup_data.type == BT_POPUP_GET_SERVICE_LIST_ERROR)
236 elm_object_domain_translatable_text_set(
238 "IDS_BT_POP_UNABLE_TO_GET_SERVICE_LIST");
239 else if (ugd->popup_data.type == BT_POPUP_GETTING_SERVICE_LIST)
240 elm_object_domain_translatable_text_set(
242 "IDS_BT_POP_GETTINGSERVICELIST");
243 else if (ugd->popup_data.type == BT_POPUP_ENTER_DEVICE_NAME)
244 elm_object_domain_translatable_text_set(
246 "IDS_ST_POP_ENTER_DEVICE_NAME");
247 else if (ugd->popup_data.type == BT_POPUP_LOW_BATTERY)
248 elm_object_domain_translatable_text_set(
250 "IDS_ST_BODY_LEDOT_LOW_BATTERY");
252 _bt_set_popup_text(ugd, popup);
256 evas_object_smart_callback_add(popup, "block,clicked",
257 (Evas_Smart_Cb) cb, cb_data);
259 /* Set timer value */
261 elm_popup_timeout_set(popup, (double)timer_val);