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.
18 #include "gl-progressbar.h"
19 #include "gl-ui-util.h"
22 #include "gl-albums.h"
23 #include "gl-controlbar.h"
24 #include "gl-thread-util.h"
25 #include "gl-strings.h"
26 #include "gl-button.h"
28 #define GL_PROGRESSBAR_STYLE_PROGRESS "list_progress"
31 _gl_pb_cancel_thread_pbar_cb(void *data, Evas_Object * obj, void *event_info)
34 //set cancel false value
35 gl_thread_set_cancel_state(data, GL_PB_CANCEL_BUTTON);
40 int gl_pb_make_thread_pbar(void *data, Evas_Object * parent, char *title)
42 GL_CHECK_VAL(data, -1);
43 gl_appdata *ad = (gl_appdata *)data;
44 Evas_Object *popup = NULL;
45 Evas_Object *progressbar = NULL;
46 Evas_Object *box = NULL;
47 Evas_Object *label = NULL;
51 popup = elm_popup_add(parent);
52 GL_CHECK_VAL(popup, -1);
54 elm_object_part_text_set(popup, GL_POPUP_TEXT, title);
56 label = elm_label_add(popup);
57 elm_object_text_set(label, GL_STR_EMPTY);
58 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
60 evas_object_show(label);
62 progressbar = elm_progressbar_add(popup);
63 elm_object_style_set(progressbar, GL_PROGRESSBAR_STYLE_PROGRESS);
64 elm_progressbar_unit_format_set(progressbar, NULL);
65 elm_progressbar_value_set(progressbar, 0.0);
66 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL,
68 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND,
70 evas_object_show(progressbar);
72 box = elm_box_add(popup);
73 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
75 elm_box_horizontal_set(box, EINA_FALSE);
76 elm_box_homogeneous_set(box, EINA_TRUE);
77 elm_box_pack_end(box, progressbar);
78 elm_box_pack_end(box, label);
79 evas_object_show(box);
81 elm_object_content_set(popup, box);
82 Evas_Object *btn1 = NULL;
83 btn1 = _gl_but_create_but_popup(popup, GL_STR_CANCEL,
84 _gl_pb_cancel_thread_pbar_cb, data);
85 elm_object_part_content_set(popup, "button1", btn1);
87 evas_object_show(popup);
89 ad->pbarinfo.pbar_popup = popup;
90 ad->pbarinfo.pbar = progressbar;
91 ad->pbarinfo.status_label = label;
92 ad->pbarinfo.finished_cnt = 0;
98 gl_pb_refresh_thread_pbar(void *data, int cur_cnt, int total_cnt)
100 GL_CHECK_VAL(data, -1);
101 char status_info[GL_POPUP_DESC_LEN_MAX] = { 0, };
102 double percent = 0.0;
103 gl_appdata *ad = (gl_appdata *)data;
104 GL_CHECK_VAL(ad->pbarinfo.pbar, -1);
105 GL_CHECK_VAL(ad->pbarinfo.status_label, -1);
107 snprintf(status_info, sizeof(status_info),
108 GL_FONT_STYLE_POP_S"%d/%d"GL_FONT_STYLE_POP_E, cur_cnt,
110 /* Save medias count already operated */
111 ad->pbarinfo.finished_cnt = cur_cnt;
112 elm_object_text_set(ad->pbarinfo.status_label, status_info);
113 evas_object_show(ad->pbarinfo.status_label);
115 percent = (double)cur_cnt / (double)total_cnt;
116 elm_progressbar_value_set(ad->pbarinfo.pbar, percent);
122 gl_pb_del_pbar(void *data)
124 GL_CHECK_VAL(data, -1);
125 gl_appdata *ad = (gl_appdata *)data;
126 gl_dbg("destroy progressbar");
128 if (ad->pbarinfo.pbar_popup)
130 evas_object_del(ad->pbarinfo.pbar_popup);
131 ad->pbarinfo.pbar_popup = NULL;
132 ad->pbarinfo.pbar = NULL;
133 ad->pbarinfo.status_label = NULL;
134 ad->pbarinfo.finished_cnt = 0;
140 /* Add list_progress style progressbar */
141 Evas_Object *_gl_pb_add_list_pbar(Evas_Object *parent, const double ratio)
143 GL_CHECK_NULL(parent);
145 Evas_Object *pbar = elm_progressbar_add(parent);
147 elm_object_style_set(pbar, GL_PROGRESSBAR_STYLE_PROGRESS);
148 elm_progressbar_horizontal_set(pbar, EINA_TRUE);
149 evas_object_size_hint_align_set(pbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
150 evas_object_size_hint_weight_set(pbar, EVAS_HINT_EXPAND,
152 elm_progressbar_value_set(pbar, ratio);
153 evas_object_show(pbar);