Update changed code
[apps/native/volume-app.git] / src / _util_efl.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  * 
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
7  * 
8  *     http://www.tizenopensource.org/license
9  * 
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.
15  */
16
17
18 #include <Ecore.h>
19 #include <Ecore_X.h>
20
21 #include "volume.h"
22 #include "_util_log.h"
23
24 Evas_Object *_add_window(const char *name)
25 {
26         Evas_Object *eo;
27         int w, h;
28         eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION);
29         if (eo) {
30                 elm_win_title_set(eo, name);
31                 elm_win_borderless_set(eo, EINA_TRUE);
32                 elm_win_alpha_set(eo, EINA_TRUE);
33                 ecore_x_window_size_get(
34                                 ecore_x_window_root_first_get(),
35                                 &w, &h);
36                 evas_object_resize(eo, w, h);
37         }
38         return eo;
39 }
40
41 Evas_Object *_add_slider(Evas_Object *parent, int min, int max, int val)
42 {
43         Evas_Object *sl;
44         sl = elm_slider_add(parent);
45         retvm_if(sl == NULL, NULL, "Failed to add slider\n");
46         elm_slider_horizontal_set(sl, EINA_TRUE);
47         elm_slider_indicator_show_set(sl, EINA_TRUE);
48         elm_slider_indicator_format_set(sl, "%.0f");
49         evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
50         evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
51         elm_slider_min_max_set(sl, min, max);
52         elm_slider_value_set(sl, val);
53         return sl;
54 }
55
56 Evas_Object *_add_layout(Evas_Object *parent, const char *file,
57                              const char *group)
58 {
59         Evas_Object *eo;
60         int r;
61
62         retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
63         retvm_if(file == NULL, NULL, "Invalid argument: file is NULL\n");
64         retvm_if(group == NULL, NULL, "Invalid argument: group is NULL\n");
65
66         eo = elm_layout_add(parent);
67         retvm_if(eo == NULL, NULL, "Failed to add layout\n");
68
69         r = elm_layout_file_set(eo, file, group);
70         if (!r) {
71                 _E("Failed to set file[%s]\n", file);
72                 evas_object_del(eo);
73                 return NULL;
74         }
75
76         evas_object_size_hint_weight_set(eo,
77                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
78         evas_object_show(eo);
79         return eo;
80 }
81
82 Evas_Object *_add_button(Evas_Object *parent, const char *style, const char *text)
83 {
84         Evas_Object *bt;
85         bt = elm_button_add(parent);
86         retvm_if(bt == NULL, NULL, "Failed to add button\n");
87         if (style) elm_object_style_set(bt, style);
88         elm_object_focus_set(bt, EINA_FALSE);
89         elm_object_text_set(bt, text);
90         evas_object_show(bt);
91         return bt;
92 }
93
94 Evas_Object *_add_popup(Evas_Object *parent, const char *style)
95 {
96         Evas_Object *pu;
97         pu = elm_popup_add(parent);
98         retvm_if(pu == NULL, NULL, "[Error] Failed to add popup\n");
99         evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100         if (style) elm_object_style_set(pu, style);
101         evas_object_show(pu);
102         return pu;
103 }
104 Evas_Object *_add_label(Evas_Object *parent, const char *style, const char *text)
105 {
106         Evas_Object *lb;
107         lb = elm_label_add(parent);
108         retvm_if(lb == NULL, NULL, "Failed to add label\n");
109         elm_object_style_set(lb, style);
110         evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
111         evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
112         elm_label_line_wrap_set(lb, ELM_WRAP_MIXED);
113         elm_object_text_set(lb, text);
114         return lb;
115 }
116