23b3f03882bf66d3a8fee3dc623a7c63ae6fdbfa
[apps/native/home/homescreen-efl.git] / inc / util.h
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 __HOME_SCREEN_UTIL_H__
18 #define __HOME_SCREEN_UTIL_H__
19
20 #include <dlog.h>
21 #include <Elementary.h>
22 #include <stdbool.h>
23
24 #define BUF_SIZE 64
25
26 #ifdef  LOG_TAG
27 #undef  LOG_TAG
28 #endif
29 #define LOG_TAG "HOMESCREEN_EFL"
30
31 /* Multi-language */
32 #ifndef _
33 #define _(str) gettext(str)
34 #endif
35
36 /* Build */
37 #define HAPI __attribute__((visibility("hidden")))
38 #define DAPI __attribute__((visibility("default")))
39
40 #define COUNT_OF(x) \
41 ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
42
43 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
44
45 #if !defined(LOGD)
46 #define LOGD(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
47 #endif
48
49 #if !defined(LOGW)
50 #define LOGW(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
51 #endif
52
53 #if !defined(LOGE)
54 #define LOGE(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
55 #endif
56
57 #if !defined(LOGI)
58 #define LOGI(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
59 #endif
60
61 /**
62  * @brief Creates elm_layout widget and load edje file to it.
63  *
64  * @param win Homescreen efl window pointer.
65  * @param edje_filename  name of the edje file
66  * @param edje_group group name from the edje file
67  * @return elm_layout Evas_Object pointer.
68  */
69 extern Evas_Object *util_create_edje_layout(
70         Evas_Object *win, const char* edje_filename, const char* edje_group);
71
72 /*DBG callbacks set. Please use it if new objects are not visible .etc*/
73 extern void tst_resize_cb(void *data, Evas *e, Evas_Object *obj, void *ei);
74 extern void tst_show_cb(void *data, Evas *e, Evas_Object *obj, void *ei);
75 extern void tst_hide_cb(void *data, Evas *e, Evas_Object *obj, void *ei);
76 extern void tst_move_cb(void *data, Evas *e, Evas_Object *obj, void *ei);
77 extern void tst_del_cb(void *data, Evas *e, Evas_Object *obj, void *ei);
78
79
80
81 /**
82  * @brief Function returns Eina list of evas objects visible in gengrid
83  *
84  * @param gengrid Evas_Object pointer to elm_gengrid
85  * @return Eina_List pointer which Evas_Objects
86  */
87 extern Eina_List *elm_gengrid_get_evas_objects_from_items(Evas_Object *gengrid);
88
89 /**
90  * @brief Function returns pointer to elm_object_item placed in gengrid
91  * at specified position
92  * @param gengrid Pointer to elm_gengrid_widget;
93  * @param idx
94  * @return Pointer to elm_object_item
95  */
96 Elm_Object_Item *elm_gengrid_get_item_at_index(Evas_Object *gengrid, int idx);
97
98 /*
99  * @brief Application sub-directories type.
100  */
101 enum app_subdir {
102         APP_DIR_DATA,
103         APP_DIR_CACHE,
104         APP_DIR_RESOURCE,
105         APP_DIR_SHARED_DATA,
106         APP_DIR_SHARED_RESOURCE,
107         APP_DIR_SHARED_TRUSTED,
108         APP_DIR_EXTERNAL_DATA,
109         APP_DIR_EXTERNAL_CACHE,
110         APP_DIR_EXTERNAL_SHARED_DATA,
111 };
112
113 /**
114  * @brief Returns absolute path to resource file located in applications directory.
115  *
116  * @param subdir type of subdirectory
117  * @param relative path of resource from starting from "data" dir.
118  *        eg. for DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.homescreen-efl/data/database.db"
119  * @return absolute path string.
120  */
121 const char *util_get_file_path(enum app_subdir dir, const char *relative);
122
123 /**
124  * @brief Convinience macros
125  */
126 #define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x))
127 #define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x))
128 #define util_get_res_file_path(x) util_get_file_path(APP_DIR_RESOURCE, (x))
129 #define util_get_shared_data_file_path(x) util_get_file_path(APP_DIR_SHARED_DATA, (x))
130 #define util_get_shared_res_file_path(x) util_get_file_path(APP_DIR_SHARED_RESOURCE, (x))
131 #define util_get_trusted_file_path(x) util_get_file_path(APP_DIR_SHARED_TRUSTED, (x))
132 #define util_get_external_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_DATA, (x))
133 #define util_get_external_cache_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_CACHE, (x))
134 #define util_get_external_shared_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_SHARED_DATA, (x))
135
136 #endif /* __HOME_SCREEN_UTIL_H__ */