Remove utilX and X lib dependency
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / SortCtxPopup.cpp
1 /*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 <Elementary.h>
18 #include <Eina.h>
19 #include <Ecore.h>
20 #include <aul.h>
21 #include "i18n.h"
22 #include "define.h"
23 #include "common.h"
24
25 #include "Info.h"
26 #include "CtxPopup.h"
27 #include "SortCtxPopup.h"
28
29 const char *sorttext[] = {
30         N_("Title A-Z"),
31         N_("Title Z-A"),
32         N_("Date ↓"),
33         N_("Date ↑"),
34         N_("Size ↓"),
35         N_("Size ↑"),
36 };
37
38 const char *sortbtnids[] = {
39         "Title A-Z",
40         "Title Z-A",
41         "Date Asc",
42         "Date Des",
43         "Size Asc",
44         "Size Des"
45 };
46
47 void CSortCtxPopup::t_OnConfiguration(void)
48 {
49         t_SetList(sorttext, ARRAY_SIZE(sorttext), (int)CInfo::SortType(), CCtxPopup::TOPBTN_SORT, sortbtnids, FBR_PART_SORT_POPUP);
50 }
51
52 void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
53 {
54         if (!obj)
55                 return;
56
57         int index = -1;
58         const char *id = (const char*)evas_object_data_get(obj, FBR_BTN_ID);
59
60         if (!id)
61                 return;
62
63         // Find Index
64         int i;
65         int arrsize = ARRAY_SIZE(sortbtnids);
66         for (i = 0; i < arrsize; i++) {
67                 if (sortbtnids[i] && !strcmp(sortbtnids[i], id)) {
68                         index = i;
69                         break;
70                 }
71         }
72
73         if (index == -1 || index == CInfo::SortType())
74                 return;
75
76         CInfo::SetSortType(index);
77         CCtxPopup::t_OnBtnClicked(obj, ev);
78
79         Destroy(); //_destroy_ctxpopup(bd);
80 }
81
82 const char* CSortCtxPopup::SortText(int index)
83 {
84         return sorttext[index];
85 }