apply FSL(Flora Software License)
[apps/home/draglock.git] / src / draglock-util.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 <app.h>
19 #include <Ecore_X.h>
20 #include "draglock.h"
21
22 static void _draglock_util_window_deleted_cb(void *data, Evas_Object *obj,
23                 void *event) {
24         app_efl_exit();
25 }
26
27 Evas_Object *draglock_util_add_window(const char *name) {
28         Evas_Object *obj_window = NULL;
29         int width = 0, height = 0;
30
31         obj_window = elm_win_add(NULL, name, ELM_WIN_BASIC);
32         if (obj_window != NULL) {
33                 elm_win_title_set(obj_window, name);
34                 elm_win_borderless_set(obj_window, EINA_TRUE);
35                 evas_object_smart_callback_add(obj_window, "delete,request",
36                                 _draglock_util_window_deleted_cb, NULL);
37                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &width,
38                                 &height);
39                 evas_object_resize(obj_window, width, height);
40                 elm_win_indicator_mode_set(obj_window, ELM_WIN_INDICATOR_SHOW);
41                 elm_win_alpha_set(obj_window, EINA_TRUE);
42         }
43
44         return obj_window;
45 }
46
47 Evas_Object *draglock_util_add_bg(Evas_Object *window) {
48         Evas_Object *obj_background = NULL;
49
50         if (window == NULL) {
51                 return NULL;
52         }
53
54         obj_background = elm_bg_add(window);
55
56         if (obj_background != NULL) {
57                 evas_object_size_hint_weight_set(obj_background, EVAS_HINT_EXPAND,
58                                 EVAS_HINT_EXPAND);
59                 elm_object_style_set(obj_background, "transparent");
60
61                 elm_win_resize_object_add(window, obj_background);
62
63                 evas_object_show(obj_background);
64         }
65
66         return obj_background;
67 }
68
69 Evas_Object *draglock_util_add_layout(Evas_Object *parent, const char *file,
70                 const char *group) {
71         Evas_Object *layout = NULL;
72         Eina_Bool ret = EINA_FALSE;
73
74         if (parent == NULL) {
75                 DRAGLOCK_ERR("parent is NULL");
76                 return NULL;
77         }
78
79         layout = elm_layout_add(parent);
80         if (layout == NULL) {
81                 DRAGLOCK_ERR("layout is NULL");
82                 return NULL;
83         }
84
85         ret = elm_layout_file_set(layout, file, group);
86         DRAGLOCK_DBG("File:%s, Group:%s", file, group);
87         if (ret != EINA_TRUE) {
88                 DRAGLOCK_DBG("File:%s, Group:%s", file, group);
89                 evas_object_del(layout);
90                 return NULL;
91         }
92         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
93                         EVAS_HINT_EXPAND);
94         evas_object_show(layout);
95
96         return layout;
97 }