Base code / protex done / 64bit build check done
[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 <utilX.h>
21 #include <aul.h>
22 #include "i18n.h"
23 #include "define.h"
24 #include "common.h"
25
26 #include "Info.h"
27 #include "CtxPopup.h"
28 #include "SortCtxPopup.h"
29
30 const char *sorttext[] = {
31         N_("Title A-Z"),
32         N_("Title Z-A"),
33         N_("Date ↓"),
34         N_("Date ↑"),
35         N_("Size ↓"),
36         N_("Size ↑"),
37 };
38
39 const char *sortbtnids[] = {
40         "Title A-Z",
41         "Title Z-A",
42         "Date Asc",
43         "Date Des",
44         "Size Asc",
45         "Size Des"
46 };
47
48 void CSortCtxPopup::t_OnConfiguration(void)
49 {
50         t_SetList(sorttext, ARRAY_SIZE(sorttext), (int)CInfo::SortType(), CCtxPopup::TOPBTN_SORT, sortbtnids, FBR_PART_SORT_POPUP);
51 }
52
53 void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
54 {
55         if (!obj)
56                 return;
57
58         int index = -1;
59         const char *id = (const char*)evas_object_data_get(obj, FBR_BTN_ID);
60
61         if (!id)
62                 return;
63
64         // Find Index
65         int i;
66         int arrsize = ARRAY_SIZE(sortbtnids);
67         for (i = 0; i < arrsize; i++) {
68                 if (sortbtnids[i] && !strcmp(sortbtnids[i], id)) {
69                         index = i;
70                         break;
71                 }
72         }
73
74         if (index == -1 || index == CInfo::SortType())
75                 return;
76
77         CInfo::SetSortType(index);
78         CCtxPopup::t_OnBtnClicked(obj, ev);
79
80         Destroy(); //_destroy_ctxpopup(bd);
81 }
82
83 const char* CSortCtxPopup::SortText(int index)
84 {
85         return sorttext[index];
86 }