Modification due to the change of CCtxPopup
[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(),
50                         CCtxPopup::TOPBTN_SORT,
51                         POSITION_SORT_POPUP_X, POSITION_SORT_POPUP_Y,
52                         FBR_STYLE_HOVER_ENTRY,
53                         FBR_STYLE_HOVER_CTXPOPUP, FBR_STYLE_HOVER_CTXPOPUP, FBR_STYLE_HOVER_CTXPOPUP);
54 }
55
56 void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
57 {
58         if (!obj)
59                 return;
60
61         int index = -1;
62         const char *id = (const char*)evas_object_data_get(obj, FBR_BTN_ID);
63
64         if (!id)
65                 return;
66
67         // Find Index
68         int i;
69         int arrsize = ARRAY_SIZE(sortbtnids);
70         for (i = 0; i < arrsize; i++) {
71                 if (sortbtnids[i] && !strcmp(sortbtnids[i], id)) {
72                         index = i;
73                         break;
74                 }
75         }
76
77         if (index == -1 || index == CInfo::SortType())
78                 return;
79
80         CInfo::SetSortType(index);
81         CCtxPopup::t_OnBtnClicked(obj, ev);
82
83         Destroy(); //_destroy_ctxpopup(bd);
84 }
85
86 const char* CSortCtxPopup::SortText(int index)
87 {
88         return sorttext[index];
89 }