tizen_2.0_build
[apps/home/draglock.git] / src / draglock.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 #include <stdio.h>
18 #include <app.h>
19 #include <Ecore_X.h>
20 #include "draglock.h"
21 #include "draglock-ui.h"
22 #include "draglock-util.h"
23
24 static void device_orientation(app_device_orientation_e orientation,
25                 void *user_data) {
26         struct appdata *ad = (struct appdata *) user_data;
27
28         if (ad == NULL || ad->win == NULL)
29                 return;
30 }
31
32 static bool app_create(void *user_data) {
33         struct appdata *ad = (struct appdata *) user_data;
34         Evas_Object *win;
35         Evas_Object *bg;
36         char *name;
37
38         DRAGLOCK_DBG("launching draglock");
39
40         if (ad == NULL) {
41                 return FALSE;
42         }
43
44         ecore_x_window_size_get(ecore_x_window_root_first_get(), &ad->win_w,
45                         &ad->win_h);
46         DRAGLOCK_DBG("window size(%d,%d)", ad->win_w, ad->win_h);
47
48         /* create window */
49         app_get_name(&name);
50
51         win = draglock_util_add_window(name);
52         if (win == NULL)
53                 return FALSE;
54         ad->win = win;
55
56         evas_object_show(win);
57
58         ad->scale = elm_scale_get();
59
60         bg = draglock_util_add_bg(win);
61
62         draglock_ui_create(ad);
63
64         free(name);
65
66         return TRUE;
67 }
68
69 static void app_terminate(void *user_data) {
70         struct appdata *ad = (struct appdata *) user_data;
71
72         if (ad == NULL) {
73                 return;
74         }
75
76         draglock_ui_destroy(ad);
77
78         if (ad->win)
79                 evas_object_del(ad->win);
80 }
81
82 static void app_pause(void *user_data) {
83         struct appdata *ad = (struct appdata *) user_data;
84         (void) ad;
85 }
86
87 static void app_resume(void *user_data) {
88         struct appdata *ad = (struct appdata *) user_data;
89         (void) ad;
90 }
91
92 static void app_service(service_h service, void *user_data) {
93         struct appdata *ad = (struct appdata *) user_data;
94
95         if (ad == NULL) {
96                 return;
97         }
98
99         if (ad->win)
100                 elm_win_activate(ad->win);
101 }
102
103 int main(int argc, char *argv[]) {
104         struct appdata ad;
105
106         app_event_callback_s event_callback;
107
108         event_callback.create = app_create;
109         event_callback.terminate = app_terminate;
110         event_callback.pause = app_pause;
111         event_callback.resume = app_resume;
112         event_callback.service = app_service;
113         event_callback.low_memory = NULL;
114         event_callback.low_battery = NULL;
115         event_callback.device_orientation = device_orientation;
116         event_callback.language_changed = NULL;
117         event_callback.region_format_changed = NULL;
118
119         memset(&ad, 0x0, sizeof(struct appdata));
120
121         return app_efl_main(&argc, &argv, &event_callback, &ad);
122 }