Tizen 2.1 base
[apps/home/ug-myfile-efl.git] / src / widget / mf-ug-tab-bar.c
1 /*\r
2  * Copyright 2012          Samsung Electronics Co., Ltd\r
3  *\r
4  * Licensed under the Flora License, Version 1.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *  http://floralicense.org/license/\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 \r
18 \r
19 \r
20 #include "mf-ug-winset.h"\r
21 #include "mf-ug-util.h"\r
22 #include "mf-ug-fs-util.h"\r
23 #include "mf-ug-fm-svc-wrapper.h"\r
24 #include "mf-ug-cb.h"\r
25 #include "mf-ug-resource.h"\r
26 \r
27 /******************************\r
28 ** Prototype    : mf_ug_tab_bar_create\r
29 ** Description  : Samsung\r
30 ** Input        : Evas_Object *parent\r
31 ** Output       : None\r
32 ** Return Value :\r
33 ** Calls        :\r
34 ** Called By    :\r
35 **\r
36 **  History        :\r
37 **  1.Date         : 2010/12/10\r
38 **    Author       : Samsung\r
39 **    Modification : Created function\r
40 **\r
41 ******************************/\r
42 Evas_Object *mf_ug_tab_bar_create(Evas_Object *parent)\r
43 {\r
44         UG_TRACE_BEGIN;\r
45         ug_mf_retv_if(parent == NULL, NULL);\r
46         Evas_Object *toolbar = elm_toolbar_add(parent);\r
47         elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);\r
48         elm_object_style_set(toolbar, "tabbar/item_horizontal");\r
49         elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);\r
50         elm_toolbar_homogeneous_set(toolbar, EINA_FALSE);\r
51         elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);\r
52 \r
53         UG_TRACE_BEGIN;\r
54         return toolbar;\r
55 }\r
56 \r
57 \r
58 /******************************\r
59 ** Prototype    : mf_ug_tab_bar_append_item\r
60 ** Description  : Samsung\r
61 ** Input        : Evas_Object *pTabBar\r
62 **                char *pTabIconPath\r
63 **                char *pTabBarLabel\r
64 **                Evas_Object *pTabView\r
65 ** Output       : None\r
66 ** Return Value :\r
67 ** Calls        :\r
68 ** Called By    :\r
69 **\r
70 **  History        :\r
71 **  1.Date         : 2010/12/10\r
72 **    Author       : Samsung\r
73 **    Modification : Created function\r
74 **\r
75 ******************************/\r
76 Elm_Object_Item *mf_ug_tab_bar_append_item(Evas_Object *pTabBar, char *pTabIconPath, char *pTabBarLabel, void *user_data)\r
77 {\r
78         UG_TRACE_BEGIN;\r
79         ug_mf_retv_if(pTabBar == NULL, NULL);\r
80 \r
81         Elm_Object_Item *pItem = NULL;\r
82         pItem = elm_toolbar_item_append(pTabBar, pTabIconPath, pTabBarLabel, mf_ug_cb_tab_bar_cb, user_data);\r
83         UG_TRACE_END;\r
84         return pItem;\r
85 }\r
86 \r
87 \r
88 /******************************\r
89 ** Prototype    : mf_ug_tab_bar_set_item_view\r
90 ** Description  : Samsung\r
91 ** Input        : Elm_Object_Item *it\r
92 **                Evas_Object * view\r
93 ** Output       : None\r
94 ** Return Value :\r
95 ** Calls        :\r
96 ** Called By    :\r
97 **\r
98 **  History        :\r
99 **  1.Date         : 2010/12/10\r
100 **    Author       : Samsung\r
101 **    Modification : Created function\r
102 **\r
103 ******************************/\r
104 void mf_ug_tab_bar_set_item_view(Evas_Object *tab_layout, Evas_Object *view)\r
105 {\r
106         UG_TRACE_BEGIN;\r
107         ug_mf_retm_if(tab_layout == NULL, "tab_layout is NULL");\r
108         ug_mf_retm_if(view == NULL, "view is NULL");\r
109         Evas_Object *layout = tab_layout;\r
110         Evas_Object *unset = elm_object_part_content_get(layout, "elm.swallow.content");\r
111         if (unset) {\r
112                 elm_object_part_content_unset(layout, "elm.swallow.content");\r
113                 evas_object_hide(unset);\r
114         }\r
115 \r
116         elm_object_part_content_set(layout, "elm.swallow.content", view);\r
117         UG_TRACE_END;\r
118 }\r
119 \r
120 \r
121 /******************************\r
122 ** Prototype    : mf_ug_tab_bar_remove_item_by_label\r
123 ** Description  : Samsung\r
124 ** Input        : Evas_Object *pTabBar\r
125 **                char *pTabLabel\r
126 ** Output       : None\r
127 ** Return Value :\r
128 ** Calls        :\r
129 ** Called By    :\r
130 **\r
131 **  History        :\r
132 **  1.Date         : 2010/12/10\r
133 **    Author       : Samsung\r
134 **    Modification : Created function\r
135 **\r
136 ******************************/\r
137 void mf_ug_tab_bar_remove_item_by_label(Evas_Object *pTabBar, char *pTabLabel)\r
138 {\r
139         UG_TRACE_BEGIN;\r
140         Elm_Object_Item *pItem = NULL;\r
141         pItem = elm_toolbar_first_item_get(pTabBar);\r
142 \r
143         while(pItem) {\r
144                 if (g_strcmp0(pTabLabel, elm_object_item_text_get(pItem)) == 0) {\r
145                         elm_object_item_del(pItem);\r
146                         return;\r
147                 }\r
148                 pItem = elm_toolbar_item_next_get(pItem);\r
149         }\r
150         UG_TRACE_END;\r
151 }\r
152 \r
153 /******************************\r
154 ** Prototype    : mf_ug_tab_bar_remove_all_items\r
155 ** Description  : Samsung\r
156 ** Input        : Evas_Object *pTabBar\r
157 ** Output       : None\r
158 ** Return Value :\r
159 ** Calls        :\r
160 ** Called By    :\r
161 **\r
162 **  History        :\r
163 **  1.Date         : 2010/12/10\r
164 **    Author       : Samsung\r
165 **    Modification : Created function\r
166 **\r
167 ******************************/\r
168 void mf_ug_tab_bar_remove_all_items(Evas_Object *pTabBar)\r
169 {\r
170 \r
171         UG_TRACE_BEGIN;\r
172         Elm_Object_Item *it = NULL;\r
173         Elm_Object_Item *pNext = NULL;\r
174 \r
175         it = elm_toolbar_first_item_get(pTabBar);\r
176         while(it) {\r
177                 pNext = elm_toolbar_item_next_get(it);\r
178                 elm_object_item_del(it);\r
179                 it = pNext;\r
180         }\r
181         UG_TRACE_END;\r
182 }\r
183 \r
184 \r
185 /******************************\r
186 ** Prototype    : mf_ug_tab_bar_set_selected_item\r
187 ** Description  : Samsung\r
188 ** Input        : Elm_Object_Item* pItem\r
189 ** Output       : None\r
190 ** Return Value :\r
191 ** Calls        :\r
192 ** Called By    :\r
193 **\r
194 **  History        :\r
195 **  1.Date         : 2010/12/10\r
196 **    Author       : Samsung\r
197 **    Modification : Created function\r
198 **\r
199 ******************************/\r
200 void mf_ug_tab_bar_set_selected_item(Elm_Object_Item *pItem)\r
201 {\r
202         UG_TRACE_BEGIN;\r
203         elm_toolbar_item_selected_set(pItem, EINA_TRUE);\r
204         UG_TRACE_END;\r
205 }\r
206 \r
207 \r
208 /******************************\r
209 ** Prototype    : mf_ug_tab_bar_set_item_disable\r
210 ** Description  : Samsung\r
211 ** Input        : Evas_Object *pTabBar\r
212 **                Eina_Bool disable\r
213 ** Output       : None\r
214 ** Return Value :\r
215 ** Calls        :\r
216 ** Called By    :\r
217 **\r
218 **  History        :\r
219 **  1.Date         : 2010/12/10\r
220 **    Author       : Samsung\r
221 **    Modification : Created function\r
222 **\r
223 ******************************/\r
224 void mf_ug_tab_bar_set_item_disable(Evas_Object *pTabBar, Eina_Bool disable)\r
225 {\r
226         Elm_Object_Item *pCurrentItem = NULL;\r
227 \r
228         if (pTabBar != NULL) {\r
229 \r
230                 pCurrentItem = elm_toolbar_first_item_get(pTabBar);\r
231                 while(pCurrentItem) {\r
232                         elm_object_item_disabled_set(pCurrentItem, disable);\r
233                         pCurrentItem = elm_toolbar_item_next_get(pCurrentItem);\r
234                 }\r
235         }\r
236 }\r
237 \r
238 int mf_ug_tab_bar_items_count_get(Evas_Object *pTabBar)\r
239 {\r
240         ug_mf_retvm_if(pTabBar == NULL, 0, "pTabBar is NULL");\r
241 \r
242         Elm_Object_Item *pCurrentItem = NULL;\r
243         int count = 0;\r
244 \r
245         pCurrentItem = elm_toolbar_first_item_get(pTabBar);\r
246         while(pCurrentItem) {\r
247                 count++;\r
248                 pCurrentItem = elm_toolbar_item_next_get(pCurrentItem);\r
249         }\r
250 \r
251         return count;\r
252 }\r
253 \r
254 Elm_Object_Item *mf_ug_tab_bar_get_item_by_label(Evas_Object *pTabBar, char *pTabLabel)\r
255 {\r
256         ug_mf_retvm_if(pTabBar == NULL, NULL, "pTabBar is NULL");\r
257         ug_mf_retvm_if(pTabLabel == NULL, NULL, "pTabLabel is NULL");\r
258         Elm_Object_Item *pItem = NULL;\r
259 \r
260         pItem = elm_toolbar_first_item_get(pTabBar);\r
261         while(pItem) {\r
262                 if (g_strcmp0(pTabLabel, elm_object_item_text_get(pItem)) == 0) {\r
263                         return pItem;\r
264                 }\r
265                 pItem = elm_toolbar_item_next_get(pItem);\r
266         }\r
267         return NULL;\r
268 }\r
269 \r