tizen 2.3 release
[apps/home/settings.git] / setting-profile / src / volume_popup.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23 #include <setting-profile.h>
24 //#include <ui-gadget.h>
25 #include <Ecore_X.h>
26 //#include <setting-common-general-func.h>
27 //#include <setting-common-draw-widget.h>
28 //#include <setting-common-resource.h>
29
30 ///////////////////////////////////////////////////////////////////////////////////////////
31 // Player related codes - End
32 ///////////////////////////////////////////////////////////////////////////////////////////
33
34 static void vp_del_win(void *data, Evas_Object *obj, void *event)
35 {
36         //app_efl_exit();
37         elm_exit();
38 }
39
40 static Evas_Object *vp_create_win(const char *name, bool transparent)
41 {
42         SETTING_TRACE_BEGIN;
43         Evas_Object *eo;
44         int w, h;
45
46         eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
47
48         if (eo)
49         {
50                 elm_win_title_set(eo, name);
51                 elm_win_conformant_set(eo,EINA_TRUE);
52
53                 if(transparent)
54                 {
55                         elm_win_alpha_set(eo, EINA_TRUE);
56
57                         #if 1
58                         unsigned int opaqueVal = 1;
59                         Ecore_X_Atom opaqueAtom = ecore_x_atom_get("_E_ILLUME_WINDOW_REGION_OPAQUE");
60                         Ecore_X_Window xwin = elm_win_xwindow_get(eo);
61                         ecore_x_window_prop_card32_set(xwin, opaqueAtom, &opaqueVal, 1);
62                         #endif
63                 }
64
65                 evas_object_smart_callback_add(eo, "delete,request", vp_del_win, NULL);
66                 //elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
67                 //ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
68                 //evas_object_resize(eo, w, h);
69                 //evas_object_resize(eo, 100, 100);
70
71                 evas_object_show(eo);
72                 elm_win_activate(eo);
73         }
74
75         return eo;
76 }
77
78
79
80
81 static void _vp_rot_changed_cb(void *data, Evas_Object *obj, void *event_info)
82 {
83         SETTING_TRACE_BEGIN;
84 }
85
86 /**
87 * The function is called to create Setting view widgets
88 */
89 static bool vp_app_create(void *data)
90 {
91         SETTING_TRACE_BEGIN;
92
93         SettingProfileUG *ad = data;
94
95         /* create window */
96         ad->win_get = vp_create_win("org.tizen.setting.volume", TRUE);
97         //ad->win_get = vp_create_win("org.tizen.setting.volume", FALSE);
98         if(ad->win_get == NULL)
99         {
100                 SETTING_TRACE("Can't create window");
101                 return FALSE;
102         }
103
104         #if 0 /*Fixed PLM bug P141120-07682, no need to support roation*/
105         if(elm_win_wm_rotation_supported_get(ad->win_get))
106         {
107                 const int rots[4] = {0, 90, 180, 270};
108                 elm_win_wm_rotation_available_rotations_set(ad->win_get, rots, 4);
109         }
110         evas_object_smart_callback_add(ad->win_get, "wm,rotation,changed", _vp_rot_changed_cb, ad);
111         #endif
112
113         //ea_theme_changeable_ui_enabled_set(TRUE);
114
115         UG_INIT_EFL(ad->win_get, UG_OPT_INDICATOR_DISABLE);
116         ad->evas = evas_object_evas_get(ad->win_get);
117         ad->viewtype = strdup(VOLUME_APP_NAME);
118         setting_sound_init(ad);
119
120         SETTING_TRACE_END;
121         return TRUE;
122 }
123
124 /**
125 * The function is called when Setting is terminated
126 */
127 static void vp_app_terminate(void *data)
128 {
129         SETTING_TRACE_BEGIN;
130         ret_if(!data);
131         SettingProfileUG *ad = data;
132
133         SETTING_TRACE("volume_popup_terminate!");
134
135         evas_object_smart_callback_del(ad->win_get, "wm,rotation,changed", _vp_rot_changed_cb);
136         setting_sound_deinit(ad);
137         if (ad->win_get) {
138                 evas_object_del(ad->win_get);
139                 ad->win_get = NULL;
140         }
141         SETTING_TRACE_END;
142 }
143
144
145
146 /**
147 * The function is called when Setting begins run in background from forground
148 */
149 static void vp_app_pause(void *data)
150 {
151         SETTING_TRACE_BEGIN;
152         elm_exit();
153 }
154
155 /**
156 * The function is called when Setting begins run in forground from background
157 */
158 static void vp_app_resume(void *data)
159 {
160         SETTING_TRACE_BEGIN;
161 }
162
163 /**
164 * The function is called by app-fwk after app_create. It always do the process which cost much time.
165 */
166 static void vp_app_reset(app_control_h service, void *data)
167 {
168         SETTING_TRACE_BEGIN;
169         //ret_if(!data);
170         //SettingProfileUG *ad = data;
171 }
172
173 static void vp_app_lang_changed(void *data)
174 {
175         SETTING_TRACE_BEGIN;
176         //fingerprint_manager_appdata *ad = data;
177         char *lang = NULL;
178
179         lang = vconf_get_str(VCONFKEY_LANGSET);
180         if(lang)
181         {
182                 elm_language_set((const char *)lang);
183                 FREE(lang);
184         }
185 }
186
187 EXPORT_PUBLIC
188 int main(int argc, char *argv[])
189 {
190         SETTING_TRACE_BEGIN;
191         int r = 0;
192         SettingProfileUG ad;
193
194         app_event_callback_s ops = {
195                 .create = vp_app_create,
196                 .terminate = vp_app_terminate,
197                 .pause = vp_app_pause,
198                 .resume = vp_app_resume,
199                 .app_control = vp_app_reset,
200                 .low_battery = NULL,
201                 .language_changed = vp_app_lang_changed,
202                 .region_format_changed = NULL,
203                 .device_orientation = NULL,
204         };
205
206         memset(&ad, 0x00, sizeof(SettingProfileUG));
207
208         r = app_efl_main(&argc, &argv, &ops, &ad);
209         SETTING_TRACE("r = %d", r);
210
211         if(r == -1)
212         {
213                 SETTING_TRACE_ERROR("app_efl_main() returns -1");
214                 return -1;
215         }
216
217         return 0;
218 }
219