Merge "modified default wallpaper image for Tizen setting" into 2.0_beta
[apps/core/preloaded/settings.git] / setting-shortcut / src / setting-shortcut.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 #include <setting-shortcut.h>
23
24 #ifndef UG_MODULE_API
25 #define UG_MODULE_API __attribute__ ((visibility("default")))
26 #endif
27
28
29 static void setting_shortcut_ug_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
30 {
31         SettingShortcutUG *ad = (SettingShortcutUG *) data;
32         setting_view_update(&setting_view_shortcut_main, ad);
33 }
34
35 static void *setting_shortcut_ug_on_create(ui_gadget_h ug,
36                                            enum ug_mode mode, service_h service,
37                                            void *priv)
38 {
39         SETTING_TRACE_BEGIN;
40         setting_retvm_if((!priv), NULL, "!priv");
41
42         SettingShortcutUG *shortcutUG = (SettingShortcutUG *)priv;
43         shortcutUG->ug = ug;
44         shortcutUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
45         shortcutUG->win_get = (Evas_Object *) ug_get_window();
46         evas_object_show(shortcutUG->win_main_layout);
47         shortcutUG->evas = evas_object_evas_get(shortcutUG->win_main_layout);
48
49         setting_retvm_if(shortcutUG->win_main_layout == NULL, NULL,
50                          "cannot get main window ");
51
52         /* --------------------------------------------------------- */
53         /* set launguage */
54         appcore_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
55         /* --------------------------------------------------------- */
56         
57         /*  creating a view. */
58         setting_view_create(&setting_view_shortcut_main,(void *)shortcutUG);
59         evas_object_event_callback_add(shortcutUG->win_main_layout,
60                                                EVAS_CALLBACK_RESIZE,
61                                                setting_shortcut_ug_cb_resize,
62                                                shortcutUG);
63         return shortcutUG->ly_main;
64 }
65
66 static void setting_shortcut_ug_on_start(ui_gadget_h ug, service_h service, void *priv)
67 {
68 }
69
70 static void setting_shortcut_ug_on_pause(ui_gadget_h ug, service_h service, void *priv)
71 {
72 }
73
74 static void setting_shortcut_ug_on_resume(ui_gadget_h ug, service_h service, void *priv)
75 {
76 }
77
78 static void setting_shortcut_ug_on_destroy(ui_gadget_h ug, service_h service, void *priv)
79 {
80         SettingShortcutUG *shortcutUG = (SettingShortcutUG *)priv;
81
82         evas_object_event_callback_del(shortcutUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_shortcut_ug_cb_resize);       /* fix flash issue for gallery */
83         shortcutUG->ug = ug;
84
85         /*  delete the allocated objects. */
86         setting_view_destroy(&setting_view_shortcut_main, shortcutUG);
87         if (NULL != ug_get_layout(shortcutUG->ug)) {
88                 evas_object_hide((Evas_Object *) ug_get_layout(shortcutUG->ug));
89                 evas_object_del((Evas_Object *) ug_get_layout(shortcutUG->ug));
90         }
91 }
92
93 static void setting_shortcut_ug_on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
94 {
95
96 }
97
98 static void setting_shortcut_ug_on_event(ui_gadget_h ug,
99                                          enum ug_event event, service_h service,
100                                          void *priv)
101 {
102         switch (event) {
103         case UG_EVENT_LOW_MEMORY:
104                 break;
105         case UG_EVENT_LOW_BATTERY:
106                 break;
107         case UG_EVENT_LANG_CHANGE:
108                 break;
109         case UG_EVENT_ROTATE_PORTRAIT:
110                 break;
111         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
112                 break;
113         case UG_EVENT_ROTATE_LANDSCAPE:
114                 break;
115         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
116                 break;
117         case UG_EVENT_REGION_CHANGE:
118                 break;
119         default:
120                 break;
121         }
122 }
123
124 static void setting_shortcut_ug_on_key_event(ui_gadget_h ug,
125                                              enum ug_key_event event,
126                                              service_h service, void *priv)
127 {
128         if (!ug || !priv)
129                 return;
130
131         switch (event) {
132         case UG_KEY_EVENT_END:
133                 ug_destroy_me(ug);
134                 break;
135         default:
136                 break;
137         }
138 }
139
140 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
141 {
142         SettingShortcutUG *shortcutUG = calloc(1, sizeof(SettingShortcutUG));
143         setting_retvm_if(!shortcutUG, -1, "Create SettingShortcutUG obj failed");
144
145         ops->create = setting_shortcut_ug_on_create;
146         ops->start = setting_shortcut_ug_on_start;
147         ops->pause = setting_shortcut_ug_on_pause;
148         ops->resume = setting_shortcut_ug_on_resume;
149         ops->destroy = setting_shortcut_ug_on_destroy;
150         ops->message = setting_shortcut_ug_on_message;
151         ops->event = setting_shortcut_ug_on_event;
152         ops->key_event = setting_shortcut_ug_on_key_event;
153         ops->priv = shortcutUG;
154         ops->opt = UG_OPT_INDICATOR_ENABLE;
155
156         return 0;
157 }
158
159 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
160 {
161         struct SettingShortcutUG *shortcutUG;
162         setting_retm_if(!ops, "ops == NULL");
163
164         shortcutUG = ops->priv;
165         if (shortcutUG)
166                 FREE(shortcutUG);
167 }