summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-02-04 13:20:37 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2015-02-04 13:20:37 +0100
commit3e06c99a0a5baabc669fecb134c2c8f94d2754c2 (patch)
tree591d882dea2415f3c157d82c516e9fee6d001539 /menu.c
parentf2807bc7828acd80bbeacbdcd8c96c76e7bc8678 (diff)
downloadvdr-3e06c99a0a5baabc669fecb134c2c8f94d2754c2.tar.gz
vdr-3e06c99a0a5baabc669fecb134c2c8f94d2754c2.tar.bz2
The "Select folder" menu now adds the folder names of all existing recordings to any names that have been predefined in "folders.conf"
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index dd95ae61..b0a511a3 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 3.40 2015/02/04 09:21:55 kls Exp $
+ * $Id: menu.c 3.41 2015/02/04 12:18:27 kls Exp $
*/
#include "menu.h"
@@ -766,8 +766,48 @@ void cMenuFolder::SetHelpKeys(void)
}
}
+#define FOLDERDELIMCHARSUBST 0x01
+static void AddRecordingFolders(cList<cNestedItem> *List, char *Path)
+{
+ if (Path) {
+ char *p = strchr(Path, FOLDERDELIMCHARSUBST);
+ if (p)
+ *p++ = 0;
+ cNestedItem *Folder;
+ for (Folder = List->First(); Folder; Folder = List->Next(Folder)) {
+ if (strcmp(Path, Folder->Text()) == 0)
+ break;
+ }
+ if (!Folder)
+ List->Add(Folder = new cNestedItem(Path));
+ if (p) {
+ Folder->SetSubItems(true);
+ AddRecordingFolders(Folder->SubItems(), p);
+ }
+ }
+ else {
+ cThreadLock RecordingsLock(&Recordings);
+ cStringList Dirs;
+ for (cRecording *Recording = Recordings.First(); Recording; Recording = Recordings.Next(Recording)) {
+ cString Folder = Recording->Folder();
+ strreplace((char *)*Folder, FOLDERDELIMCHAR, FOLDERDELIMCHARSUBST); // makes sure parent folders come before subfolders
+ if (Dirs.Find(Folder) < 0)
+ Dirs.Append(strdup(Folder));
+ }
+ Dirs.Sort();
+ for (int i = 0; i < Dirs.Size(); i++) {
+ char *s = Dirs[i];
+ if (*s)
+ AddRecordingFolders(&Folders, s);
+ }
+ }
+}
+
void cMenuFolder::Set(const char *CurrentFolder)
{
+ static int RecordingsState = -1;
+ if (list == &Folders && Recordings.StateChanged(RecordingsState))
+ AddRecordingFolders(&Folders, NULL);
firstFolder = NULL;
Clear();
if (!isempty(dir)) {