6275934d9b0d550e96b82d87528dc284bcee6c6e
[apps/home/volume-app.git] / src / _button.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 <ui-gadget.h>
19
20 #include "_util_log.h"
21 #include "volume.h"
22 #include "_sound.h"
23 #include "_logic.h"
24
25 static void button_ug_layout_cb(ui_gadget_h ug,
26                 enum ug_mode mode, void *priv)
27 {
28         Evas_Object *base;
29         Evas_Object *win;
30
31         base = ug_get_layout(ug);
32         win = ug_get_window();
33
34         switch (mode) {
35                 case UG_MODE_FULLVIEW:
36                         evas_object_size_hint_weight_set(base,
37                                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38                         elm_win_resize_object_add(win, base);
39                         evas_object_show(base);
40                         break;
41                 default:
42                         break;
43         }
44 }
45
46 static void button_ug_destroy_cb(ui_gadget_h ug, void *priv)
47 {
48         _D("%s\n", __func__);
49         struct appdata *ad = (struct appdata *)priv;
50
51         retm_if(ug == NULL, "Invalid argument: ug is NULL\n");
52
53         ug_destroy(ug);
54         ad->ug = NULL;
55
56         ecore_x_netwm_window_type_set(elm_win_xwindow_get(ad->win), ECORE_X_WINDOW_TYPE_NOTIFICATION);
57         utilx_set_window_opaque_state(ecore_x_display_get(), elm_win_xwindow_get(ad->win), UTILX_OPAQUE_STATE_OFF);
58         _close_volume(ad);
59 }
60
61 ui_gadget_h create_button_ug(void *data)
62 {
63         ui_gadget_h ug = NULL;
64         struct ug_cbs cbs = {0};
65         struct appdata *ad = (struct appdata *)data;
66         retvm_if(ad == NULL, 0, "Invalid argument:appdata is NULL\n");
67
68         cbs.layout_cb = button_ug_layout_cb;
69         cbs.destroy_cb = button_ug_destroy_cb;
70         cbs.priv = (void *)data;
71
72         ecore_x_netwm_window_type_set(elm_win_xwindow_get(ad->win), ECORE_X_WINDOW_TYPE_NORMAL);
73         utilx_set_window_opaque_state(ecore_x_display_get(), elm_win_xwindow_get(ad->win), UTILX_OPAQUE_STATE_ON);
74         ug = ug_create(NULL, "setting-profile-efl", UG_MODE_FULLVIEW, NULL, &cbs);
75
76         return ug;
77 }
78
79 int _open_ug(void *data)
80 {
81         struct appdata *ad = (struct appdata *)data;
82         ui_gadget_h ug= NULL;
83
84         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
85         retvm_if(ad->win == NULL, -1, "Invalid argument: window is NULL\n");
86
87         UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE);
88         elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
89         ug = create_button_ug(ad);
90
91         retvm_if(ug == NULL, -1, "Failed to Create ug!\n");
92
93         ad->ug = ug;
94
95         return 0;
96 }