replace service to app_control
[apps/core/preloaded/ug-setting-homescreen-efl.git] / homescreen-setting-efl.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.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 #ifndef UG_MODULE_API
18 #define UG_MODULE_API __attribute__ ((visibility("default")))
19 #endif
20
21 #include "homescreen-setting-efl.h"
22 #include "homescreen-setting-main.h"
23
24 static Evas_Object *_create_naviframe(Evas_Object *parent)
25 {
26         Evas_Object *naviframe = NULL;
27
28         if (parent == NULL)
29         {
30                 HOMESET_ERR("Parent is null.");
31                 return NULL;
32         }
33
34         naviframe = elm_naviframe_add(parent);
35         if (naviframe == NULL)
36         {
37                 HOMESET_ERR("Cannot add naviframe.");
38                 return NULL;
39         }
40
41         elm_object_part_content_set(parent, "elm.swallow.content", naviframe);
42
43         evas_object_show(naviframe);
44
45         return naviframe;
46 }
47
48 static Evas_Object *_create_background(Evas_Object *parent)
49 {
50         Evas_Object *bg = elm_bg_add(parent);
51
52         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53         elm_object_style_set(bg, "group_list");
54
55         elm_object_part_content_set(parent, "elm.swallow.bg", bg);
56         evas_object_show(bg);
57
58         return bg;
59 }
60
61 static Evas_Object *_create_layout(Evas_Object *parent)
62 {
63         Evas_Object *layout = NULL;
64
65         if (parent == NULL)
66         {
67                 HOMESET_ERR("Parent is null.");
68                 return NULL;
69         }
70
71         layout = elm_layout_add(parent);
72         if (layout == NULL)
73         {
74                 HOMESET_ERR("Cannot add layout.");
75                 return NULL;
76         }
77
78         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79
80         evas_object_show(layout);
81
82         return layout;
83 }
84
85 static Evas_Object *create_fullview(Evas_Object *parent, struct ug_data *ugd)
86 {
87         HOMESET_DBG("");
88         if (ugd == NULL)
89         {
90                 HOMESET_ERR("Invalid ug data");
91                 return NULL;
92         }
93
94         /* Create Full view */
95         ugd->base = _create_layout(parent);
96
97         elm_layout_theme_set(ugd->base, "layout", "application", "default");
98         elm_win_indicator_mode_set(parent, ELM_WIN_INDICATOR_SHOW);
99
100         /* Create background */
101         _create_background(ugd->base);
102
103         /* Create navigation bar */
104         ugd->naviframe = _create_naviframe(ugd->base);
105
106         /* Create main view */
107         homescreen_setting_main_create_view(ugd);
108
109         return ugd->base;
110 }
111
112 static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h app_control, void *priv)
113 {
114         HOMESET_DBG("");
115         Evas_Object *parent;
116         struct ug_data *ugd;
117
118         if (!ug || !priv)
119                 return NULL;
120
121         bindtextdomain(HOMESET_DOMAIN, "/usr/ug/res/locale");
122
123         ugd = priv;
124         ugd->ug = ug;
125
126         parent = ug_get_parent_layout(ug);
127         if (!parent)
128                 return NULL;
129
130         /* always make full view */
131         ugd->base = create_fullview(parent, ugd);
132
133         return ugd->base;
134 }
135
136 static void on_start(ui_gadget_h ug, app_control_h app_control, void *priv)
137 {
138 }
139
140 static void on_pause(ui_gadget_h ug, app_control_h app_control, void *priv)
141 {
142
143 }
144
145 static void on_resume(ui_gadget_h ug, app_control_h app_control, void *priv)
146 {
147
148 }
149
150 static void on_destroy(ui_gadget_h ug, app_control_h app_control, void *priv)
151 {
152         HOMESET_DBG("");
153         struct ug_data *ugd;
154
155         if (!ug || !priv)
156                 return;
157
158         ugd = priv;
159         evas_object_del(ugd->base);
160         ugd->base = NULL;
161 }
162
163 static void on_message(ui_gadget_h ug, app_control_h msg, app_control_h app_control, void *priv)
164 {
165 }
166
167 static void on_event(ui_gadget_h ug, enum ug_event event, app_control_h app_control, void *priv)
168 {
169         switch (event)
170         {
171         case UG_EVENT_LOW_MEMORY:
172                 break;
173         case UG_EVENT_LOW_BATTERY:
174                 break;
175         case UG_EVENT_LANG_CHANGE:
176                 break;
177         case UG_EVENT_ROTATE_PORTRAIT:
178                 break;
179         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
180                 break;
181         case UG_EVENT_ROTATE_LANDSCAPE:
182                 break;
183         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
184                 break;
185         case UG_EVENT_REGION_CHANGE:
186                 break;
187         default:
188                 break;
189         }
190 }
191
192 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
193 {
194         HOMESET_DBG("ug init");
195         struct ug_data *ugd;
196
197         if (!ops)
198                 return -1;
199
200         ugd = calloc(1, sizeof(struct ug_data));
201         if (!ugd)
202                 return -1;
203
204         ops->create = on_create;
205         ops->start = on_start;
206         ops->pause = on_pause;
207         ops->resume = on_resume;
208         ops->destroy = on_destroy;
209         ops->message = on_message;
210         ops->event = on_event;
211         ops->priv = ugd;
212         ops->opt = UG_OPT_INDICATOR_ENABLE;
213
214         return 0;
215 }
216
217 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
218 {
219         HOMESET_DBG("ug exit");
220         struct ug_data *ugd;
221
222         if (!ops)
223                 return;
224
225         ugd = ops->priv;
226         if (ugd)
227                 free(ugd);
228 }