dbg.h file is removed.
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / SourceCtxPopup.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
20 #include <AppCommon.h>
21 #include "define.h"
22 #include "common.h"
23 #include "i18n.h"
24 #include "Info.h"
25 #include "SourceCtxPopup.h"
26
27 #define BTN_ID                   "BTN_ID"
28
29 const char *srcbtnids[] = {
30         "ALL",
31         "TV",
32         "USB"
33 };
34
35 const char *sourcetext[] = {
36         N_("All Source"),
37         N_("TV"),
38         N_("USB"),
39 };
40
41 void CSourceCtxPopup::t_OnConfiguration(void)
42 {
43         int size = ARRAY_SIZE(sourcetext);
44
45         CUsbListener usb;
46         if(usb.Create()) {
47                 if (!usb.FlagConnected())
48                         size--;
49                 usb.Destroy();
50         }
51         else
52                 size--;
53
54         t_SetList(sourcetext, size, (int)CInfo::SourceType(),
55                         CContextPopup::TOPBTN_SOURCE, srcbtnids,
56                         POSITION_SOURCE_POPUP_X, POSITION_SOURCE_POPUP_Y,
57                         NULL,
58                         FBR_STYLE_HOVER_ENTRY, FBR_STYLE_HOVER_ENTRY, FBR_STYLE_HOVER_ENTRY);
59 }
60
61
62 void CSourceCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
63 {
64         if (!obj)
65                 return;
66
67         int index = -1;
68         const char *id = (const char*)evas_object_data_get(obj, BTN_ID);
69
70         if (!id)
71                 return;
72
73         // Find Index
74         int i;
75         int arrsize = ARRAY_SIZE(srcbtnids);
76         for (i = 0; i < arrsize; i++) {
77                 if (srcbtnids[i] && !strcmp(srcbtnids[i], id)) {
78                         index = i;
79                         break;
80                 }
81         }
82         if (index == -1 || index == CInfo::SourceType())
83                 return;
84
85         CInfo::SetSourceType(index);
86         CContextPopup::t_OnBtnClicked(obj, ev);
87
88         Destroy();
89 }
90
91 const char* CSourceCtxPopup::SourceText(int index)
92 {
93         return sourcetext[index];
94 }