Skip to content
Newer
Older
100644 232 lines (200 sloc) 6.13 KB
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
1 /*
2 * Copyright (C) 2005-2008 Team XBMC
3 * http://www.xbmc.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21
22 #include "system.h"
23 #include "GUIWindowPrograms.h"
24 #include "Util.h"
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
25 #include "addons/GUIDialogAddonInfo.h"
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
26 #include "Autorun.h"
c51b118 Merged cptspiff's code-reshuffle branch.
theuni authored
27 #include "guilib/GUIWindowManager.h"
28 #include "dialogs/GUIDialogKeyboard.h"
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
29 #include "FileItem.h"
c51b118 Merged cptspiff's code-reshuffle branch.
theuni authored
30 #include "settings/Settings.h"
31 #include "guilib/LocalizeStrings.h"
88b2c26 Merge remote branch 'origin/gpl-compat'
ceros7 authored
32 #include "utils/log.h"
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
33
34 #define CONTROL_BTNVIEWASICONS 2
35 #define CONTROL_BTNSORTBY 3
36 #define CONTROL_BTNSORTASC 4
37 #define CONTROL_LABELFILES 12
38
39 CGUIWindowPrograms::CGUIWindowPrograms(void)
40 : CGUIMediaWindow(WINDOW_PROGRAMS, "MyPrograms.xml")
41 {
42 m_thumbLoader.SetObserver(this);
43 m_dlgProgress = NULL;
44 m_rootDir.AllowNonLocalSources(false); // no nonlocal shares for this window please
45 }
46
47
48 CGUIWindowPrograms::~CGUIWindowPrograms(void)
49 {
50 }
51
52 bool CGUIWindowPrograms::OnMessage(CGUIMessage& message)
53 {
54 switch ( message.GetMessage() )
55 {
56 case GUI_MSG_WINDOW_DEINIT:
57 {
58 if (m_thumbLoader.IsLoading())
59 m_thumbLoader.StopThread();
60 }
61 break;
62
63 case GUI_MSG_WINDOW_INIT:
64 {
2647224 cosmetic: m_gWindowManager -> g_windowManager for consistency.
jmarshallnz authored
65 m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
66
67 // is this the first time accessing this window?
6d27f0f switch CFileItem::m_strPath to private, and add GetPath/SetPath for a…
Jonathan Marshall authored
68 if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty())
bc23e4c fixed: Some default sources may not have been set correctly when open…
jmarshallnz authored
69 message.SetStringParam(g_settings.m_defaultProgramSource);
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
70
71 return CGUIMediaWindow::OnMessage(message);
72 }
73 break;
74
75 case GUI_MSG_CLICKED:
76 {
77 if (m_viewControl.HasControl(message.GetSenderId())) // list/thumb control
78 {
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
79 int iAction = message.GetParam1();
80 int iItem = m_viewControl.GetSelectedItem();
81 if (iAction == ACTION_PLAYER_PLAY)
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
82 {
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
83 OnPlayMedia(iItem);
84 return true;
85 }
86 else if (iAction == ACTION_SHOW_INFO)
87 {
88 OnInfo(iItem);
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
89 return true;
90 }
91 }
92 }
93 break;
94 }
95
96 return CGUIMediaWindow::OnMessage(message);
97 }
98
99 void CGUIWindowPrograms::GetContextButtons(int itemNumber, CContextButtons &buttons)
100 {
101 if (itemNumber < 0 || itemNumber >= m_vecItems->Size())
102 return;
103 CFileItemPtr item = m_vecItems->Get(itemNumber);
1849749 @Montellese replace CGUIListItem::m_propertyMap and CGUIWindow::m_propertyMap val…
Montellese authored
104 if (item && !item->GetProperty("pluginreplacecontextitems").asBoolean())
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
105 {
106 if ( m_vecItems->IsVirtualDirectoryRoot() )
107 {
108 CGUIDialogContextMenu::GetContextButtons("programs", item, buttons);
109 }
110 else
111 {
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
112 if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
113 buttons.Add(CONTEXT_BUTTON_INFO, 24003); // Add-on info
ea10198 add CFileItem/URIUtils::IsScript and refactor current conditions to u…
Jonathan Marshall authored
114 if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin())
8e2d614 changed: Re-add the "Addon Settings" option to the context menu both …
jmarshallnz authored
115 buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045);
116
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
117 buttons.Add(CONTEXT_BUTTON_GOTO_ROOT, 20128); // Go to Root
118 }
119 }
120 CGUIMediaWindow::GetContextButtons(itemNumber, buttons);
121 }
122
123 bool CGUIWindowPrograms::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
124 {
125 CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr();
126
127 if (item && m_vecItems->IsVirtualDirectoryRoot())
128 {
129 if (CGUIDialogContextMenu::OnContextButton("programs", item, button))
130 {
131 Update("");
132 return true;
133 }
134 }
135 switch (button)
136 {
137 case CONTEXT_BUTTON_GOTO_ROOT:
138 Update("");
139 return true;
140
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
141 case CONTEXT_BUTTON_INFO:
142 OnInfo(itemNumber);
143 return true;
144
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
145 default:
146 break;
147 }
148 return CGUIMediaWindow::OnContextButton(itemNumber, button);
149 }
150
151 bool CGUIWindowPrograms::Update(const CStdString &strDirectory)
152 {
153 if (m_thumbLoader.IsLoading())
154 m_thumbLoader.StopThread();
155
156 if (!CGUIMediaWindow::Update(strDirectory))
157 return false;
158
159 m_thumbLoader.Load(*m_vecItems);
160 return true;
161 }
162
163 bool CGUIWindowPrograms::OnPlayMedia(int iItem)
164 {
165 if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return false;
166 CFileItemPtr pItem = m_vecItems->Get(iItem);
167
d5c23e3 cosmetics
spiff_ authored
168 #ifdef HAS_DVD_DRIVE
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
169 if (pItem->IsDVD())
1c64603 @elupus Attempt to get PlayDisc to work properly on linux even if multiple dr…
elupus authored
170 return MEDIA_DETECT::CAutorun::PlayDiscAskResume(m_vecItems->Get(iItem)->GetPath());
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
171 #endif
d5c23e3 cosmetics
spiff_ authored
172
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
173 if (pItem->m_bIsFolder) return false;
174
175 return false;
176 }
177
178 bool CGUIWindowPrograms::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
179 {
d283f34 changed: remove some deprecated xbox-only code
spiff_ authored
180 if (!CGUIMediaWindow::GetDirectory(strDirectory, items))
181 return false;
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
182
9e11a1d changed: set label2 in program window to add-on version where relevant
spiff_ authored
183 // don't allow the view state to change these
184 if (strDirectory.Left(9).Equals("addons://"))
185 {
186 for (int i=0;i<items.Size();++i)
187 {
1849749 @Montellese replace CGUIListItem::m_propertyMap and CGUIWindow::m_propertyMap val…
Montellese authored
188 items[i]->SetLabel2(items[i]->GetProperty("Addon.Version").asString());
9e11a1d changed: set label2 in program window to add-on version where relevant
spiff_ authored
189 items[i]->SetLabelPreformated(true);
190 }
191 }
192
45285e8 step 3/4: Move linuxport to trunk. How'd I get roped into this?
AlTheKiller authored
193 return true;
194 }
9a921c3 added: Support the return parameter for ActivateWindow in all mediawi…
jmarshallnz authored
195
196 CStdString CGUIWindowPrograms::GetStartFolder(const CStdString &dir)
197 {
198 if (dir.Equals("Plugins") || dir.Equals("Addons"))
199 return "addons://sources/executable/";
200
201 SetupShares();
202 VECSOURCES shares;
203 m_rootDir.GetSources(shares);
204 bool bIsSourceName = false;
205 int iIndex = CUtil::GetMatchingSource(dir, shares, bIsSourceName);
206 if (iIndex > -1)
207 {
208 if (iIndex < (int)shares.size() && shares[iIndex].m_iHasLock == 2)
209 {
210 CFileItem item(shares[iIndex]);
211 if (!g_passwordManager.IsItemUnlocked(&item,"programs"))
212 return "";
213 }
214 if (bIsSourceName)
215 return shares[iIndex].strPath;
216 return dir;
217 }
218 return CGUIMediaWindow::GetStartFolder(dir);
219 }
4faa73c @dersphere add-on info on info-action and via context-menu on program add-ons
dersphere authored
220
221 void CGUIWindowPrograms::OnInfo(int iItem)
222 {
223 if (iItem < 0 || iItem >= m_vecItems->Size())
224 return;
225
226 CFileItemPtr item = m_vecItems->Get(iItem);
227 if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
228 {
229 CGUIDialogAddonInfo::ShowForItem(item);
230 }
231 }
Something went wrong with that request. Please try again.