tizen 2.3.1 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                 elm_win_title_set(eo, name);
50                 elm_win_conformant_set(eo, EINA_TRUE);
51
52                 if (transparent) {
53                         elm_win_alpha_set(eo, EINA_TRUE);
54
55 #if 1
56                         unsigned int opaqueVal = 1;
57                         Ecore_X_Atom opaqueAtom = ecore_x_atom_get("_E_ILLUME_WINDOW_REGION_OPAQUE");
58                         Ecore_X_Window xwin = elm_win_xwindow_get(eo);
59                         ecore_x_window_prop_card32_set(xwin, opaqueAtom, &opaqueVal, 1);
60 #endif
61                 }
62
63                 evas_object_smart_callback_add(eo, "delete,request", vp_del_win, NULL);
64
65                 evas_object_show(eo);
66                 elm_win_activate(eo);
67         }
68
69         return eo;
70 }
71
72
73
74
75 static void _vp_rot_changed_cb(void *data, Evas_Object *obj, void *event_info)
76 {
77         SETTING_TRACE_BEGIN;
78 }
79
80 /**
81 * The function is called to create Setting view widgets
82 */
83 static bool vp_app_create(void *data)
84 {
85         SETTING_TRACE_BEGIN;
86
87         SettingProfileUG *ad = data;
88
89         /* create window */
90         ad->win_get = vp_create_win("org.tizen.setting.volume", TRUE);
91         /*ad->win_get = vp_create_win("org.tizen.setting.volume", FALSE); */
92         if (ad->win_get == NULL) {
93                 SETTING_TRACE("Can't create window");
94                 return FALSE;
95         }
96
97 #if 0 /*Fixed PLM bug P141120-07682, no need to support roation*/
98         if (elm_win_wm_rotation_supported_get(ad->win_get)) {
99                 const int rots[4] = {0, 90, 180, 270};
100                 elm_win_wm_rotation_available_rotations_set(ad->win_get, rots, 4);
101         }
102         evas_object_smart_callback_add(ad->win_get, "wm,rotation,changed", _vp_rot_changed_cb, ad);
103 #endif
104
105         /*ea_theme_changeable_ui_enabled_set(TRUE); */
106
107         UG_INIT_EFL(ad->win_get, UG_OPT_INDICATOR_DISABLE);
108         ad->evas = evas_object_evas_get(ad->win_get);
109         ad->viewtype = strdup(VOLUME_APP_NAME);
110         setting_sound_init(ad);
111
112         SETTING_TRACE_END;
113         return TRUE;
114 }
115
116 /**
117 * The function is called when Setting is terminated
118 */
119 static void vp_app_terminate(void *data)
120 {
121         SETTING_TRACE_BEGIN;
122         ret_if(!data);
123         SettingProfileUG *ad = data;
124
125         SETTING_TRACE("volume_popup_terminate!");
126
127         evas_object_smart_callback_del(ad->win_get, "wm,rotation,changed", _vp_rot_changed_cb);
128         setting_sound_deinit(ad);
129         if (ad->win_get) {
130                 evas_object_del(ad->win_get);
131                 ad->win_get = NULL;
132         }
133         SETTING_TRACE_END;
134 }
135
136
137
138 /**
139 * The function is called when Setting begins run in background from forground
140 */
141 static void vp_app_pause(void *data)
142 {
143         SETTING_TRACE_BEGIN;
144         elm_exit();
145 }
146
147 /**
148 * The function is called when Setting begins run in forground from background
149 */
150 static void vp_app_resume(void *data)
151 {
152         SETTING_TRACE_BEGIN;
153 }
154
155 /**
156 * The function is called by app-fwk after app_create. It always do the process which cost much time.
157 */
158 static void vp_app_reset(app_control_h service, void *data)
159 {
160         SETTING_TRACE_BEGIN;
161         /*ret_if(!data); */
162         /*SettingProfileUG *ad = data; */
163 }
164
165 static void vp_app_lang_changed(void *data)
166 {
167         SETTING_TRACE_BEGIN;
168         /*fingerprint_manager_appdata *ad = data; */
169         char *lang = NULL;
170
171         lang = vconf_get_str(VCONFKEY_LANGSET);
172         if (lang) {
173                 elm_language_set((const char *)lang);
174                 FREE(lang);
175         }
176 }
177
178 EXPORT_PUBLIC
179 int main(int argc, char *argv[])
180 {
181         SETTING_TRACE_BEGIN;
182         int r = 0;
183         SettingProfileUG ad;
184
185         app_event_callback_s ops = {
186                 .create = vp_app_create,
187                 .terminate = vp_app_terminate,
188                 .pause = vp_app_pause,
189                 .resume = vp_app_resume,
190                 .app_control = vp_app_reset,
191                 .low_battery = NULL,
192                 .language_changed = vp_app_lang_changed,
193                 .region_format_changed = NULL,
194                 .device_orientation = NULL,
195         };
196
197         memset(&ad, 0x00, sizeof(SettingProfileUG));
198
199         r = app_efl_main(&argc, &argv, &ops, &ad);
200         SETTING_TRACE("r = %d", r);
201
202         if (r == -1) {
203                 SETTING_TRACE_ERROR("app_efl_main() returns -1");
204                 return -1;
205         }
206
207         return 0;
208 }
209