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.
20 #include <appcore-efl.h>
22 #include "taskmanager.h"
23 #include "_util_log.h"
24 #include "_util_efl.h"
27 Evas_Object *_add_window(const char *name)
32 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
34 elm_win_title_set(eo, name);
35 elm_win_borderless_set(eo, EINA_TRUE);
36 ecore_x_window_size_get(ecore_x_window_root_first_get(),
38 evas_object_resize(eo, w, h);
44 Evas_Object *_add_bg(Evas_Object *parent, char *style)
48 bg = elm_bg_add(parent);
49 retvm_if(bg == NULL, NULL, "Failed to add bg\n");
50 if (style) elm_object_style_set(bg, style);
51 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
57 Evas_Object *_add_genlist(Evas_Object *parent)
61 eo = elm_genlist_add(parent);
63 printf("[Error] Cannot add genlist\n");
67 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
69 evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
74 Evas_Object *_add_icon(Evas_Object *parent, const char *png)
77 char buf[128] = { 0, };
79 eo = elm_icon_add(parent);
81 printf("[Error] Cannot add button\n");
85 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, png);
86 elm_icon_file_set(eo, buf, NULL);
87 elm_icon_resizable_set(eo, 1, 1);
88 evas_object_size_hint_aspect_set(eo, EVAS_ASPECT_CONTROL_VERTICAL, 1,
94 Evas_Object *_add_layout(Evas_Object *parent, const char *file,
97 Evas_Object *eo = NULL;
100 eo = elm_layout_add(parent);
102 printf("[Error] Cannot add layout\n");
106 r = elm_layout_file_set(eo, file, group);
108 printf("[Error] Cannot set file layout\n");
113 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
119 Evas_Object *_add_ctxpopup(Evas_Object *parent)
121 Evas_Object *eo = NULL;
123 eo = elm_ctxpopup_add(parent);
125 printf("[Error] Cannot add ctxpopup\n");
129 elm_ctxpopup_horizontal_set(eo, EINA_TRUE);
130 elm_ctxpopup_direction_priority_set(eo,
131 ELM_CTXPOPUP_DIRECTION_DOWN,
132 ELM_CTXPOPUP_DIRECTION_UP,
133 ELM_CTXPOPUP_DIRECTION_LEFT,
134 ELM_CTXPOPUP_DIRECTION_RIGHT);
139 Evas_Object *_add_label(Evas_Object *parent, const char *msg)
141 Evas_Object *eo = NULL;
143 eo = elm_label_add(parent);
145 printf("[Error] Cannot add label\n");
149 elm_label_line_wrap_set(eo, ELM_WRAP_WORD);
150 elm_object_text_set(eo, msg);
155 static Eina_Bool _disappear_popup(void *data)
157 Evas_Object *eo = (Evas_Object *)data;
159 printf("[Error] Invalid argument: popup is NULL\n");
160 return ECORE_CALLBACK_CANCEL;
163 return ECORE_CALLBACK_CANCEL;
166 Evas_Object *_add_popup_ask(Evas_Object *parent, char *text, void *data)
168 Evas_Object *pu, *bt1, *bt2;
169 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
171 pu = elm_popup_add(parent);
172 retvm_if(pu == NULL, NULL, "Falied to add popup\n");
173 evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
174 elm_object_part_text_set(pu, "title,text", S_("IDS_COM_POP_WARNING"));
175 elm_object_text_set(pu, text);
176 evas_object_show(pu);
178 bt1 = elm_button_add(pu);
179 elm_object_text_set(bt1, S_("IDS_COM_SK_OK"));
180 elm_object_part_content_set(pu, "button1", bt1);
181 evas_object_smart_callback_add(bt1, "clicked", _ok_response_cb, data);
183 bt2 = elm_button_add(pu);
184 elm_object_text_set(bt2, S_("IDS_COM_POP_CANCEL"));
185 elm_object_part_content_set(pu, "button2", bt2);
186 evas_object_smart_callback_add(bt2, "clicked", _cancel_response_cb, data);
192 void util_show_popup_with_message(Evas_Object *parent, double in,
195 Evas_Object *eo = NULL;
197 eo = elm_popup_add(parent);
199 printf("[Error] Cannot add popup\n");
203 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
205 elm_object_text_set(eo, msg);
207 ecore_timer_add(in, _disappear_popup, eo);
210 Evas_Object *_add_naviframe(Evas_Object *parent)
214 retv_if(parent == NULL, NULL);
216 nv = elm_naviframe_add(parent);
217 retvm_if(nv == NULL, NULL, "Failed to add naviframe\n");
218 elm_object_part_content_set(parent, "elm.swallow.content", nv);
220 evas_object_show(nv);
225 Evas_Object *_add_layout_main(Evas_Object *parent,
226 Eina_Bool content, Eina_Bool transparent)
230 retv_if(parent == NULL, NULL);
232 ly = elm_layout_add(parent);
233 retvm_if(ly == NULL, NULL, "Failed elm_layout_add.\n");
235 elm_layout_theme_set(ly, "layout", "application", "default");
236 evas_object_size_hint_weight_set(ly,
237 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
238 elm_win_resize_object_add(parent, ly);
240 elm_object_signal_emit(ly, "elm,state,show,content", "elm");
242 elm_object_signal_emit(ly, "elm,bg,show,transparent", "elm");
243 evas_object_show(ly);
247 Evas_Object *_add_progressbar(Evas_Object *parent, const char *style,
248 Evas_Coord w, Evas_Coord h)
253 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
255 scale = elm_config_scale_get();
257 pb = elm_progressbar_add(parent);
258 retvm_if(pb == NULL, NULL, "Failed to add progressbar\n");
260 elm_object_style_set(pb, style);
261 evas_object_resize(pb, w, (int)(60 * scale));
262 evas_object_move(pb, 0, h / 2);
263 elm_progressbar_pulse(pb, EINA_TRUE);
264 evas_object_show(pb);