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 <appcore-efl.h>
20 #include "taskmanager.h"
21 #include "_util_log.h"
22 #include "_util_efl.h"
25 Evas_Object *_add_window(const char *name)
30 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
32 elm_win_title_set(eo, name);
33 elm_win_borderless_set(eo, EINA_TRUE);
34 ecore_x_window_size_get(ecore_x_window_root_first_get(),
36 evas_object_resize(eo, w, h);
42 Evas_Object *_add_bg(Evas_Object *parent, char *style)
46 bg = elm_bg_add(parent);
47 retvm_if(bg == NULL, NULL, "Failed to add bg\n");
48 if (style) elm_object_style_set(bg, style);
49 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
55 Evas_Object *_add_genlist(Evas_Object *parent)
59 eo = elm_genlist_add(parent);
61 printf("[Error] Cannot add genlist\n");
65 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
67 evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
72 Evas_Object *_add_icon(Evas_Object *parent, const char *png)
75 char buf[128] = { 0, };
77 eo = elm_icon_add(parent);
79 printf("[Error] Cannot add button\n");
83 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, png);
84 elm_icon_file_set(eo, buf, NULL);
85 elm_icon_resizable_set(eo, 1, 1);
86 evas_object_size_hint_aspect_set(eo, EVAS_ASPECT_CONTROL_VERTICAL, 1,
92 Evas_Object *_add_layout(Evas_Object *parent, const char *file,
95 Evas_Object *eo = NULL;
98 eo = elm_layout_add(parent);
100 printf("[Error] Cannot add layout\n");
104 r = elm_layout_file_set(eo, file, group);
106 printf("[Error] Cannot set file layout\n");
111 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
117 Evas_Object *_add_ctxpopup(Evas_Object *parent)
119 Evas_Object *eo = NULL;
121 eo = elm_ctxpopup_add(parent);
123 printf("[Error] Cannot add ctxpopup\n");
127 elm_ctxpopup_horizontal_set(eo, EINA_TRUE);
128 elm_ctxpopup_direction_priority_set(eo,
129 ELM_CTXPOPUP_DIRECTION_DOWN,
130 ELM_CTXPOPUP_DIRECTION_UP,
131 ELM_CTXPOPUP_DIRECTION_LEFT,
132 ELM_CTXPOPUP_DIRECTION_RIGHT);
137 Evas_Object *_add_label(Evas_Object *parent, const char *msg)
139 Evas_Object *eo = NULL;
141 eo = elm_label_add(parent);
143 printf("[Error] Cannot add label\n");
147 elm_label_line_wrap_set(eo, ELM_WRAP_WORD);
148 elm_object_text_set(eo, msg);
153 static Eina_Bool _disappear_popup(void *data)
155 Evas_Object *eo = (Evas_Object *)data;
157 printf("[Error] Invalid argument: popup is NULL\n");
158 return ECORE_CALLBACK_CANCEL;
161 return ECORE_CALLBACK_CANCEL;
164 Evas_Object *_add_popup_ask(Evas_Object *parent, char *text, void *data)
166 Evas_Object *pu, *bt1, *bt2;
167 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
169 pu = elm_popup_add(parent);
170 retvm_if(pu == NULL, NULL, "Falied to add popup\n");
171 evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
172 elm_object_part_text_set(pu, "title,text", D_("IDS_COM_POP_WARNING"));
173 elm_object_text_set(pu, text);
174 evas_object_show(pu);
176 bt1 = elm_button_add(pu);
177 elm_object_text_set(bt1, D_("IDS_COM_SK_OK"));
178 elm_object_part_content_set(pu, "button1", bt1);
179 evas_object_smart_callback_add(bt1, "clicked", _ok_response_cb, data);
181 bt2 = elm_button_add(pu);
182 elm_object_text_set(bt2, _("IDS_COM_POP_CANCEL"));
183 elm_object_part_content_set(pu, "button2", bt2);
184 evas_object_smart_callback_add(bt2, "clicked", _cancel_response_cb, data);
190 void util_show_popup_with_message(Evas_Object *parent, double in,
193 Evas_Object *eo = NULL;
195 eo = elm_popup_add(parent);
197 printf("[Error] Cannot add popup\n");
201 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
203 elm_object_text_set(eo, msg);
205 ecore_timer_add(in, _disappear_popup, eo);
208 Evas_Object *_add_naviframe(Evas_Object *parent)
212 retv_if(parent == NULL, NULL);
214 nv = elm_naviframe_add(parent);
215 retvm_if(nv == NULL, NULL, "Failed to add naviframe\n");
216 elm_object_part_content_set(parent, "elm.swallow.content", nv);
218 evas_object_show(nv);
223 Evas_Object *_add_layout_main(Evas_Object *parent,
224 Eina_Bool content, Eina_Bool transparent)
228 retv_if(parent == NULL, NULL);
230 ly = elm_layout_add(parent);
231 retvm_if(ly == NULL, NULL, "Failed elm_layout_add.\n");
233 elm_layout_theme_set(ly, "layout", "application", "default");
234 evas_object_size_hint_weight_set(ly,
235 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 elm_win_resize_object_add(parent, ly);
238 elm_object_signal_emit(ly, "elm,state,show,content", "elm");
240 elm_object_signal_emit(ly, "elm,bg,show,transparent", "elm");
241 evas_object_show(ly);
245 Evas_Object *_add_progressbar(Evas_Object *parent, const char *style,
246 Evas_Coord w, Evas_Coord h)
251 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
253 scale = elm_config_scale_get();
255 pb = elm_progressbar_add(parent);
256 retvm_if(pb == NULL, NULL, "Failed to add progressbar\n");
258 elm_object_style_set(pb, style);
259 evas_object_resize(pb, w, (int)(60 * scale));
260 evas_object_move(pb, 0, h / 2);
261 elm_progressbar_pulse(pb, EINA_TRUE);
262 evas_object_show(pb);