3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include <appcore-efl.h>
23 #include "taskmanager.h"
24 #include "_util_log.h"
25 #include "_util_efl.h"
28 Evas_Object *_add_window(const char *name)
33 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
35 elm_win_title_set(eo, name);
36 elm_win_borderless_set(eo, EINA_TRUE);
37 ecore_x_window_size_get(ecore_x_window_root_first_get(),
39 evas_object_resize(eo, w, h);
45 Evas_Object *_add_bg(Evas_Object *parent, char *style)
49 bg = elm_bg_add(parent);
50 retvm_if(bg == NULL, NULL, "Failed to add bg\n");
51 if (style) elm_object_style_set(bg, style);
52 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
58 Evas_Object *_add_genlist(Evas_Object *parent)
62 eo = elm_genlist_add(parent);
64 printf("[Error] Cannot add genlist\n");
68 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
70 evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
75 Evas_Object *_add_icon(Evas_Object *parent, const char *png)
78 char buf[128] = { 0, };
80 eo = elm_icon_add(parent);
82 printf("[Error] Cannot add button\n");
86 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, png);
87 elm_image_file_set(eo, buf, NULL);
88 elm_image_resizable_set(eo, 1, 1);
89 evas_object_size_hint_aspect_set(eo, EVAS_ASPECT_CONTROL_VERTICAL, 1,
95 Evas_Object *_add_layout(Evas_Object *parent, const char *file,
98 Evas_Object *eo = NULL;
101 eo = elm_layout_add(parent);
103 printf("[Error] Cannot add layout\n");
107 r = elm_layout_file_set(eo, file, group);
109 printf("[Error] Cannot set file layout\n");
114 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
120 Evas_Object *_add_ctxpopup(Evas_Object *parent)
122 Evas_Object *eo = NULL;
124 eo = elm_ctxpopup_add(parent);
126 printf("[Error] Cannot add ctxpopup\n");
130 elm_ctxpopup_horizontal_set(eo, EINA_TRUE);
131 elm_ctxpopup_direction_priority_set(eo,
132 ELM_CTXPOPUP_DIRECTION_DOWN,
133 ELM_CTXPOPUP_DIRECTION_UP,
134 ELM_CTXPOPUP_DIRECTION_LEFT,
135 ELM_CTXPOPUP_DIRECTION_RIGHT);
140 Evas_Object *_add_label(Evas_Object *parent, const char *msg)
142 Evas_Object *eo = NULL;
144 eo = elm_label_add(parent);
146 printf("[Error] Cannot add label\n");
150 elm_label_line_wrap_set(eo, ELM_WRAP_WORD);
151 elm_object_text_set(eo, msg);
156 static Eina_Bool _disappear_popup(void *data)
158 Evas_Object *eo = (Evas_Object *)data;
160 printf("[Error] Invalid argument: popup is NULL\n");
161 return ECORE_CALLBACK_CANCEL;
164 return ECORE_CALLBACK_CANCEL;
167 void _diable_popup(void *data)
169 Evas_Object *btn = NULL;
170 Evas_Object *eo = (Evas_Object *)data;
172 printf("[Error] Invalid argument: popup is NULL\n");
176 btn = elm_object_part_content_get(eo, "button1");
178 elm_object_disabled_set(btn, EINA_TRUE);
181 btn = elm_object_part_content_get(eo, "button2");
183 elm_object_disabled_set(btn, EINA_TRUE);
187 Evas_Object *_add_popup_ask(Evas_Object *parent, char *text, void *data)
189 Evas_Object *pu, *bt1, *bt2;
190 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
192 pu = elm_popup_add(parent);
193 retvm_if(pu == NULL, NULL, "Falied to add popup\n");
194 evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
195 elm_object_part_text_set(pu, "title,text", S_("IDS_COM_POP_WARNING"));
196 elm_object_text_set(pu, text);
197 evas_object_show(pu);
199 bt1 = elm_button_add(pu);
200 elm_object_text_set(bt1, S_("IDS_COM_SK_OK"));
201 elm_object_part_content_set(pu, "button1", bt1);
202 evas_object_smart_callback_add(bt1, "clicked", _ok_response_cb, data);
204 bt2 = elm_button_add(pu);
205 elm_object_text_set(bt2, S_("IDS_COM_POP_CANCEL"));
206 elm_object_part_content_set(pu, "button2", bt2);
207 evas_object_smart_callback_add(bt2, "clicked", _cancel_response_cb, data);
213 void util_show_popup_with_message(Evas_Object *parent, double in,
216 Evas_Object *eo = NULL;
218 eo = elm_popup_add(parent);
220 printf("[Error] Cannot add popup\n");
224 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
226 elm_object_text_set(eo, msg);
228 ecore_timer_add(in, _disappear_popup, eo);
231 Evas_Object *_add_naviframe(Evas_Object *parent)
235 retv_if(parent == NULL, NULL);
237 nv = elm_naviframe_add(parent);
238 retvm_if(nv == NULL, NULL, "Failed to add naviframe\n");
239 elm_object_part_content_set(parent, "elm.swallow.content", nv);
241 evas_object_show(nv);
246 Evas_Object *_add_layout_main(Evas_Object *parent,
247 Eina_Bool content, Eina_Bool transparent)
251 retv_if(parent == NULL, NULL);
253 ly = elm_layout_add(parent);
254 retvm_if(ly == NULL, NULL, "Failed elm_layout_add.\n");
256 elm_layout_theme_set(ly, "layout", "application", "default");
257 evas_object_size_hint_weight_set(ly,
258 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
259 elm_win_resize_object_add(parent, ly);
261 elm_object_signal_emit(ly, "elm,state,show,content", "elm");
263 elm_object_signal_emit(ly, "elm,bg,show,transparent", "elm");
264 evas_object_show(ly);
268 Evas_Object *_add_progressbar(Evas_Object *parent, const char *style,
269 Evas_Coord w, Evas_Coord h)
274 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
276 scale = elm_config_scale_get();
278 pb = elm_progressbar_add(parent);
279 retvm_if(pb == NULL, NULL, "Failed to add progressbar\n");
281 elm_object_style_set(pb, style);
282 evas_object_resize(pb, w, (int)(60 * scale));
283 evas_object_move(pb, 0, h / 2);
284 elm_progressbar_pulse(pb, EINA_TRUE);
285 evas_object_show(pb);