2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.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.
18 #include "ug-nfc-share-popup.h"
21 #define NFC_POPUP_AUTO_TIMEOUT_SEC 3.0
24 static Evas_Object *_popup = NULL;
25 static UG_NFC_POPUP_USER_RESP_CB _user_response_cb;
26 static void *_user_data = NULL;
29 static void _ug_nfc_share_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
33 int btn_type = (int)data;
34 UG_NFC_POPUP_USER_RESP_CB temp_cb = _user_response_cb;
35 void *temp_data = _user_data;
37 UG_NFC_SHARE_DEBUG("btn_type: %d", (int)btn_type);
38 UG_NFC_SHARE_DEBUG("Popup is removed: [%p]", obj);
39 evas_object_del(_popup);
42 _user_response_cb = NULL;
46 temp_cb(temp_data, obj, (void*)btn_type);
51 static Eina_Bool _ug_nfc_share_popup_show_cb(void *data)
53 UG_NFC_SHARE_BEGIN();;
56 evas_object_show(_popup);
60 return ECORE_CALLBACK_CANCEL;
63 static void _ug_nfc_share_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
67 _ug_nfc_share_popup_response_cb((void*)UG_NFC_POPUP_RESP_CLOSE, _popup, NULL);
72 Evas_Object *ug_nfc_share_create_popup(void *data,
73 Evas_Object *parent_layout,
74 const char *description,
75 const char *btn1_text,
77 const char *btn2_text,
79 const char *btn3_text,
83 UG_NFC_POPUP_USER_RESP_CB response_cb)
87 Evas_Object *btn = NULL;
89 retv_if(NULL == data, NULL);
92 ug_nfc_share_close_popup(_popup);
96 _popup = elm_popup_add(parent_layout);
97 UG_NFC_SHARE_DEBUG("Popup is created: [%p]", _popup);
98 evas_object_size_hint_weight_set(_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100 elm_object_text_set(_popup, description);
103 btn = elm_button_add(_popup);
104 elm_object_style_set (btn, "popup_button/default");
105 elm_object_text_set(btn, btn1_text);
106 elm_object_part_content_set(_popup, "button1", btn);
107 evas_object_smart_callback_add(btn, "clicked", _ug_nfc_share_popup_response_cb, (void*)btn1_type);
110 btn = elm_button_add(_popup);
111 elm_object_style_set (btn, "popup_button/default");
112 elm_object_text_set(btn, btn2_text);
113 elm_object_part_content_set(_popup, "button2", btn);
114 evas_object_smart_callback_add(btn, "clicked", _ug_nfc_share_popup_response_cb, (void*)btn2_type);
117 btn = elm_button_add(_popup);
118 elm_object_style_set (btn, "popup_button/default");
119 elm_object_text_set(btn, btn3_text);
120 elm_object_part_content_set(_popup, "button3", btn);
121 evas_object_smart_callback_add(btn, "clicked", _ug_nfc_share_popup_response_cb, (void*)btn3_type);
124 _user_response_cb = response_cb;
128 evas_object_smart_callback_add(_popup, "block,clicked", _ug_nfc_share_popup_block_clicked_cb, NULL);
133 elm_popup_timeout_set(_popup, NFC_POPUP_AUTO_TIMEOUT_SEC);
134 evas_object_smart_callback_add(_popup, "timeout", _ug_nfc_share_popup_response_cb, NULL);
137 _ug_nfc_share_popup_show_cb(NULL);
145 void ug_nfc_share_close_popup(Evas_Object* popup)
147 UG_NFC_SHARE_BEGIN();
149 if (NULL == popup || NULL == _popup || _popup != popup) {
150 UG_NFC_SHARE_DEBUG_ERR("NULL == popup || NULL == _popup || _popup != popup");
153 _ug_nfc_share_popup_response_cb((void*)UG_NFC_POPUP_RESP_CLOSE, _popup, NULL);