7505cfcb6b03ea20af8f41e4ec16c0fdf142db00
[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 <Ecore.h>
18 #include <aul.h>
19 #include "dbg.h"
20 #include <AppCommon.h>
21 #include "define.h"
22 #include "common.h"
23 #include "i18n.h"
24
25 #include "Info.h"
26 #include "SortCtxPopup.h"
27
28 #define BTN_ID                   "BTN_ID"
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(),
51                         CContextPopup::TOPBTN_SORT, sortbtnids,
52                         POSITION_SORT_POPUP_X, POSITION_SORT_POPUP_Y,
53                         NULL,
54                         FBR_STYLE_HOVER_ENTRY, FBR_STYLE_HOVER_ENTRY, FBR_STYLE_HOVER_ENTRY);
55 }
56
57 void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
58 {
59         if (!obj)
60                 return;
61
62         int index = -1;
63         const char *id = (const char*)evas_object_data_get(obj, BTN_ID);
64
65         if (!id)
66                 return;
67
68         // Find Index
69         int i;
70         int arrsize = ARRAY_SIZE(sortbtnids);
71         for (i = 0; i < arrsize; i++) {
72                 if (sortbtnids[i] && !strcmp(sortbtnids[i], id)) {
73                         index = i;
74                         break;
75                 }
76         }
77
78         if (index == -1 || index == CInfo::SortType())
79                 return;
80
81         CInfo::SetSortType(index);
82         CContextPopup::t_OnBtnClicked(obj, ev);
83
84         Destroy(); //_destroy_ctxpopup(bd);
85 }
86
87 const char* CSortCtxPopup::SortText(int index)
88 {
89         return sorttext[index];
90 }