summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2009-09-16 16:54:24 +0000
committerphintuka <phintuka>2009-09-16 16:54:24 +0000
commit8a8f58656118c98e0d51c2118cc0032f61400ca4 (patch)
treed43e34e6a5def93221b0f65448c5fd9cc0a92673
parent461bb335f8e97d66001da85d2cb5e462f5ed7c36 (diff)
downloadxineliboutput-8a8f58656118c98e0d51c2118cc0032f61400ca4.tar.gz
xineliboutput-8a8f58656118c98e0d51c2118cc0032f61400ca4.tar.bz2
Merged revision 1.68:
Rewrite cMenuBrowseFiles::SetHelpButtons() (should be lot easier to read now ...) - Removed redundant buttons - Disabled color buttons for parent directory entry ( "[..]" ) - Execute color button actions only when defined for the file
-rw-r--r--menu.c81
1 files changed, 54 insertions, 27 deletions
diff --git a/menu.c b/menu.c
index f0f8e797..ce03d022 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c,v 1.57.2.6 2009-09-16 11:52:52 phintuka Exp $
+ * $Id: menu.c,v 1.57.2.7 2009-09-16 16:54:24 phintuka Exp $
*
*/
@@ -60,6 +60,7 @@ class cMenuBrowseFiles : public cOsdMenu
bool m_OnlyQueue;
char *m_CurrentDir;
char *m_ConfigLastDir;
+ const char *help[4];
virtual bool ScanDir(const char *DirName);
virtual eOSState Open(bool ForceOpen = false, bool Queue = false, bool Rewind = false);
@@ -194,16 +195,32 @@ void cMenuBrowseFiles::StoreConfig(void)
void cMenuBrowseFiles::SetHelpButtons(void)
{
- bool isDir = !GetCurrent() || GetCurrent()->IsDir();
- bool isDvd = GetCurrent() && GetCurrent()->IsDvd();
- bool hasResume = GetCurrent() && GetCurrent()->HasResume();
-
- SetHelp((isDir && isDvd) ? trVDR("Button$Open") : !m_OnlyQueue ? trVDR("Button$Play"): NULL,
- (m_Mode == ShowMusic) ? tr("Button$Queue") :
- (m_Mode == ShowFiles && hasResume) ? trVDR("Button$Rewind") :
- NULL,
- (isDir && !isDvd) ? NULL : trVDR("Button$Delete"),
- isDir ? NULL : trVDR("Button$Info"));
+ bool isDir = !GetCurrent() || GetCurrent()->IsDir();
+ bool isFile = !isDir;
+
+ if (isDir && !strcmp("..", GetCurrent()->Name())) {
+ help[0] = help[1] = help[2] = help[3] = NULL;
+ } else if (m_Mode == ShowMusic) {
+ help[0] = isDir ? trVDR("Button$Play") : NULL;
+ help[1] = tr ("Button$Queue");
+ help[2] = isFile ? trVDR("Button$Delete") : NULL;
+ help[3] = isFile ? trVDR("Button$Info") : NULL;
+ } else if (m_Mode == ShowImages) {
+ help[0] = isDir ? trVDR("Button$Play") : NULL;
+ help[1] = NULL;
+ help[2] = isFile ? trVDR("Button$Delete") : NULL;
+ help[3] = isFile ? trVDR("Button$Info") : NULL;
+ } else {
+ bool isDvd = GetCurrent() && (GetCurrent()->IsDvd() || GetCurrent()->IsBluRay());
+ bool hasResume = GetCurrent() && GetCurrent()->HasResume();
+
+ help[0] = isDir && isDvd ? trVDR("Button$Open") : NULL;
+ help[1] = hasResume ? trVDR("Button$Rewind") : NULL;
+ help[2] = isFile || isDvd ? trVDR("Button$Delete") : NULL;
+ help[3] = isFile ? trVDR("Button$Info") : NULL;
+ }
+
+ SetHelp(help[0], help[1], help[2], help[3]);
Display();
}
@@ -277,9 +294,11 @@ eOSState cMenuBrowseFiles::Open(bool ForceOpen, bool Queue, bool Rewind)
// TODO: show all images
}
}
+
+ /* go to directory */
const char *d = GetCurrent()->Name();
char *buffer = NULL;
- if (asprintf(&buffer, "%s/%s", m_CurrentDir, d) > 0) {
+ if(asprintf(&buffer, "%s/%s", m_CurrentDir, d) >= 0) {
while(buffer[0] == '/' && buffer[1] == '/')
strcpy(buffer, buffer+1);
free(m_CurrentDir);
@@ -287,7 +306,7 @@ eOSState cMenuBrowseFiles::Open(bool ForceOpen, bool Queue, bool Rewind)
}
Set();
return osContinue;
-
+
/* regular file */
} else {
cString f = cString::sprintf("%s%s/%s",
@@ -325,7 +344,7 @@ eOSState cMenuBrowseFiles::Open(bool ForceOpen, bool Queue, bool Rewind)
if(it==Get(Current()))
index = i;
if(!it->IsDir())
- if (asprintf(&files[i++], "%s/%s", m_CurrentDir, it->Name()) < 0)
+ if(asprintf(&files[i++], "%s/%s", m_CurrentDir, it->Name()) < 0)
i--;
}
cControl::Shutdown();
@@ -426,23 +445,31 @@ eOSState cMenuBrowseFiles::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
- switch (Key) {
- case kPlay:
- case kOk: return Open(false, m_OnlyQueue);
- case kRed: return Open(true);
- case kGreen: return Open(true,
- m_Mode==ShowMusic ? m_OnlyQueue=true : false,
- m_Mode == ShowFiles);
- case kYellow: return Delete();
- case kBlue: return Info();
- default: break;
- }
- }
+ switch (Key) {
+ case kPlay:
+ case kOk: return Open(false, m_OnlyQueue);
+ case kRed: if (help[0])
+ return Open(true);
+ break;
+ case kGreen: if (help[1])
+ return Open(true,
+ m_Mode == ShowMusic ? m_OnlyQueue=true : false,
+ m_Mode != ShowMusic);
+ break;
+ case kYellow: if (help[2])
+ return Delete();
+ break;
+ case kBlue: if (help[3])
+ return Info();
+ break;
+ default: break;
+ }
+ }
if (state == osUnknown)
state = osContinue;
- if(!HasSubMenu())
+ if (!HasSubMenu())
SetHelpButtons();
return state;