2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
17 #include <Elementary.h>
18 #include <app_debug.h>
25 Evas_Object *utils_add_layout(Evas_Object *base, const char *group,
26 bool focus_allow, const char *part)
30 if (!base || !group) {
31 _ERR("Invalid argument");
35 ly = elm_layout_add(base);
37 _ERR("failed to add layout");
40 elm_layout_file_set(ly, EDJEFILE, group);
43 elm_object_focus_allow_set(ly, EINA_TRUE);
45 elm_object_part_content_set(base, part, ly);
52 Evas_Object *utils_add_icon(Evas_Object *base, const char *file,
58 _ERR("Invalid argument");
62 ic = elm_icon_add(base);
64 _ERR("failed to add icon");
68 elm_image_file_set(ic, file, NULL);
71 elm_object_part_content_set(base, part, ic);
78 Evas_Object *utils_add_label(Evas_Object *base, char *text,
79 const char *style, const char *part)
85 _ERR("Invalid argument");
89 lbl = elm_label_add(base);
91 _ERR("failed to add label");
96 elm_object_style_set(lbl, style);
98 s = edje_object_data_get(elm_layout_edje_get(base), TITLE_WIDTH);
100 elm_label_wrap_width_set(lbl, atoi(s));
102 elm_object_text_set(lbl, text);
105 elm_object_part_content_set(base, part, lbl);
107 evas_object_show(lbl);
112 Evas_Object *utils_add_bg(Evas_Object *base, int r, int g, int b, int a,
118 _ERR("Invalid argument");
122 bg = evas_object_rectangle_add(evas_object_evas_get(base));
124 _ERR("failed to add label");
128 evas_object_color_set(bg, r, g, b, a);
131 elm_object_part_content_set(base, part, bg);
133 evas_object_show(bg);
138 Evas_Object *utils_add_scroller(Evas_Object *base)
142 scr = elm_scroller_add(base);
144 _ERR("failed to add scroller");
148 elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,
149 ELM_SCROLLER_POLICY_OFF);
150 evas_object_show(scr);
155 Evas_Object *utils_add_box(Evas_Object *base, bool horizon)
159 box = elm_box_add(base);
161 _ERR("failed to add box");
166 elm_box_horizontal_set(box, EINA_TRUE);
168 evas_object_show(box);
173 bool utils_launch_app(const char *pkg)
175 app_control_h app_control;
179 _ERR("Invalid argument");
183 app_control_create(&app_control);
184 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
185 app_control_set_app_id(app_control, pkg);
187 r = app_control_send_launch_request(app_control, NULL, NULL);
188 if (r != APP_CONTROL_ERROR_NONE) {
189 _ERR("failed to launch pkg");
190 app_control_destroy(app_control);
194 app_control_destroy(app_control);