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://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 "cam_popup.h"
19 #include "cam_debug.h"
22 static GList *g_pop_list = NULL;
24 static double bar_percent = 0;
25 static char *bar_text = NULL;
26 static gboolean add_progress_bar = FALSE;
29 /* remove popup which is add by cam_app_*_popup() functions */
30 void cam_popup_remove(Evas_Object *popup)
34 GList *popup_list = NULL;
35 popup_list = g_pop_list;
36 g_pop_list = g_list_remove(popup_list, popup);
37 evas_object_del(popup);
41 void cam_popup_remove_all(void)
43 GList *popup_list = NULL;
44 popup_list = g_pop_list;
48 GList *next = popup_list->next;
49 evas_object_del(popup_list->data);
50 popup_list->data = NULL;
53 g_list_free(popup_list);
59 #ifdef USE_ELM_POPUP /*it is not use*/
61 /* popup with one button, ELM_POPUP_RESPONSE_OK is sent along with response signal. */
62 void cam_popup_confirm_add(Evas_Object *window, const char *message,
63 const char *btn_name, cam_popup_respons_cb callback,
67 Evas_Object *popup = NULL;
69 if (callback == NULL) { /* response_cb should be set */
71 "add info popup [%s] failed, callback is NULL ",
76 popup = elm_popup_add_with_buttons(window, NULL, message,
77 1, btn_name, ELM_POPUP_RESPONSE_OK,
81 cam_critical(LOG_UI, "add confirm popup [%s] failed ",
85 evas_object_smart_callback_add(popup, "response", callback, user_data);
86 evas_object_show(popup);
88 g_pop_list = g_list_append(g_pop_list, popup);
93 /* popup with two button, ELM_POPUP_RESPONSE_OK/ELM_POPUP_RESPONSE_CANCEL is sent along with response signal. */
94 void cam_popup_question_add(Evas_Object *window, const char *message,
95 const char *btn_n_1, const char *btn_n_2,
96 cam_popup_respons_cb callback, void *user_data)
98 Evas_Object *popup = NULL;
100 if (callback == NULL) { /* response_cb should be set */
102 "add info popup [%s] failed, callback is NULL ",
107 popup = elm_popup_add_with_buttons(window, NULL, message, 2,
109 ELM_POPUP_RESPONSE_OK,
110 ELM_POPUP_RESPONSE_CANCEL, NULL);
113 cam_critical(LOG_UI, "add question popup [%s] failed ",
117 evas_object_smart_callback_add(popup, "response", callback, user_data);
118 evas_object_show(popup);
120 g_pop_list = g_list_append(g_pop_list, popup);
124 #else /* #ifdef USE_ELM_POPUP */
126 cam_popup_question_add(Evas_Object *window, const char *message,
127 const char *lbtn_name, void (*left_btn_cb) (void *data,
132 const char *rbtn_name, void (*right_btn_cb) (void *data,
138 Evas_Object *notify = NULL;
139 Evas_Object *layout = NULL;
140 Evas_Object *label = NULL;
141 Evas_Object *button = NULL;
143 char buf[50] = { '\0', };
145 notify = elm_notify_add(window);
146 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND,
148 elm_notify_align_set(notify, 0.5, 0.5);
149 elm_notify_allow_events_set(notify, EINA_FALSE);
150 evas_object_show(notify);
152 layout = elm_layout_add(window);
153 elm_layout_theme_set(layout, "standard", "notify", "style3");
154 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
156 elm_object_content_set(notify, layout);
157 evas_object_show(layout);
159 label = elm_label_add(window);
161 elm_object_style_set(label, "popup/description");
162 edje_object_part_geometry_get((Evas_Object *)
163 elm_layout_edje_get(layout),
164 "elm.swallow.content", NULL, NULL, &width,
166 elm_label_line_wrap_set(label, EINA_TRUE);
167 elm_label_wrap_width_set(label, width);
169 snprintf(buf, sizeof(buf), "<align=middle>%s", message);
171 elm_object_text_set(label, buf);
172 elm_object_part_content_set(layout, "elm.swallow.content", label);
173 evas_object_show(label);
175 if (lbtn_name && left_btn_cb) {
176 button = elm_button_add(window);
177 elm_object_text_set(button, lbtn_name);
178 elm_object_part_content_set(layout, "elm.swallow.left", button);
179 evas_object_smart_callback_add(button, "focused", left_btn_cb,
181 evas_object_show(button);
184 if (rbtn_name && right_btn_cb) {
185 button = elm_button_add(window);
186 elm_object_text_set(button, rbtn_name);
187 elm_object_part_content_set(layout, "elm.swallow.right", button);
188 evas_object_smart_callback_add(button, "focused", right_btn_cb,
190 evas_object_show(button);
193 g_pop_list = g_list_append(g_pop_list, notify);
197 #endif /* #ifdef USE_ELM_POPUP */
199 Evas_Object *cam_popup_guide_screen_add(Evas_Object *window, const char *message)
201 cam_debug(LOG_UI, "");
203 Evas_Object *ctxpopup = NULL;
204 ctxpopup = elm_ctxpopup_add(window);
207 cam_critical(LOG_UI, "critical : can't make ctx popup");
210 elm_object_style_set(ctxpopup, "beat_winset_test/imageeditor");
211 elm_ctxpopup_item_append(ctxpopup, _("Flickr"), NULL, NULL,
213 evas_object_move(ctxpopup, 200, 200);
214 evas_object_show(ctxpopup);
221 gboolean cam_popup_create(void *data)
223 struct appdata *ad = (struct appdata *)data;
224 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
226 if (ad->progress_popup != NULL)
227 cam_popup_delete(ad);
229 elm_object_part_content_unset(ad->ug_base, "progress_popup_layout");
232 ad->progress_popup = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "progress_popup");
234 cam_retvm_if(ad->progress_popup == NULL, FALSE, "progress_popup is NULL");
235 elm_object_part_content_set(ad->ug_base, "progress_popup_layout", ad->progress_popup);
237 switch (ad->target_direction) {
238 case CAM_TARGET_DIRECTION_LANDSCAPE:
239 case CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE:
240 edje_object_signal_emit(_EDJ(ad->progress_popup), "progress_popup,default", "prog");
242 case CAM_TARGET_DIRECTION_PORTRAIT:
243 case CAM_TARGET_DIRECTION_PORTRAIT_INVERSE:
244 edje_object_signal_emit(_EDJ(ad->progress_popup), "progress_popup,vertical", "prog");
247 DEBUG_TRACE("wow, reached un-able reached codes");
250 evas_object_show(ad->progress_popup);
255 // create popup with progress bar burst_progress_popup
256 gboolean cam_popup_for_burst_create(void *data)
258 struct appdata *ad = (struct appdata *)data;
259 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
261 if (ad->progress_popup != NULL)
262 cam_popup_delete(ad);
264 elm_object_part_content_unset(ad->ug_base, "progress_popup_layout");
267 ad->progress_popup = cam_app_load_edj(ad->ug_base, CAM_UTILS_EDJ_NAME, "burst_progress_popup");
269 cam_retvm_if(ad->progress_popup == NULL, FALSE, "progress_popup is NULL");
270 elm_object_part_content_set(ad->ug_base, "progress_popup_layout", ad->progress_popup);
272 switch (ad->target_direction) {
273 case CAM_TARGET_DIRECTION_LANDSCAPE:
274 case CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE:
275 edje_object_signal_emit(_EDJ(ad->progress_popup), "progress_popup,default", "prog");
277 case CAM_TARGET_DIRECTION_PORTRAIT:
278 case CAM_TARGET_DIRECTION_PORTRAIT_INVERSE:
279 edje_object_signal_emit(_EDJ(ad->progress_popup), "progress_popup,vertical", "prog");
282 DEBUG_TRACE("wow, reached un-able reached codes");
285 evas_object_show(ad->progress_popup);
291 gboolean cam_popup_add_progress_bar(void *data)
293 struct appdata *ad = (struct appdata *)data;
294 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
296 if (ad->progress_popup_bar != NULL) {
297 evas_object_del(ad->progress_popup_bar);
298 ad->progress_popup_bar = NULL;
301 ad->progress_popup_bar = elm_progressbar_add(ad->ug_base);
302 cam_retvm_if(ad->progress_popup_bar == NULL, FALSE, "Cannot add progressbar object\n");
304 Evas_Object *pb = ad->progress_popup_bar;
305 edje_object_part_swallow(_EDJ(ad->progress_popup), "progress_popup_bar", pb);
306 elm_object_style_set(pb, "list_progress");
307 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
308 add_progress_bar = TRUE;
313 gboolean cam_popup_set_text(void *data, char *text)
315 struct appdata *ad = (struct appdata *)data;
316 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
318 if (ad->progress_popup == NULL )
323 edje_object_part_text_set(_EDJ(ad->progress_popup), "progress_popup_text", text);
328 gboolean cam_popup_set_bar_value(void *data, double value)
330 struct appdata *ad = (struct appdata *)data;
331 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
333 if (ad->progress_popup_bar) {
335 elm_progressbar_value_set(ad->progress_popup_bar, value);
336 evas_object_raise(ad->progress_popup_bar);
342 gboolean cam_popup_delete(void *data)
344 struct appdata *ad = (struct appdata *)data;
345 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
347 if (ad->progress_popup != NULL) {
348 evas_object_del(ad->progress_popup);
349 ad->progress_popup = NULL;
352 if (ad->progress_popup_bar != NULL) {
353 evas_object_del(ad->progress_popup_bar);
354 ad->progress_popup_bar = NULL;
359 add_progress_bar = FALSE;
365 void cam_popup_rotate(void *data)
367 struct appdata *ad = (struct appdata *)data;
368 cam_retm_if(ad == NULL, "appdata is NULL");
370 unsigned int tmp_percent = bar_percent;
371 char *tmp_text = bar_text;
372 gboolean using_bar = TRUE;
374 cam_popup_delete(ad);
376 if (!cam_popup_create(ad)) {
377 cam_critical(LOG_UI, "cam_popup_create() failed");
381 if (add_progress_bar) {
382 if (!cam_popup_add_progress_bar(ad))
383 cam_debug(LOG_UI, "cam_popup_add_progress_bar() failed");
385 if (!cam_popup_set_bar_value(ad, tmp_percent))
386 cam_debug(LOG_UI, "cam_popup_set_bar_value() failed");
389 if (!cam_popup_set_text(ad, tmp_text))
390 cam_debug(LOG_UI, "cam_popup_set_text() failed");