summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/main_menu.c5
-rw-r--r--apps/onplay.c83
-rw-r--r--apps/tree.c44
-rw-r--r--apps/tree.h1
4 files changed, 71 insertions, 62 deletions
diff --git a/apps/main_menu.c b/apps/main_menu.c
index b6d73ab6f2..23af8d7817 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -304,7 +304,7 @@ bool main_menu(void)
int i = 0;
/* main menu */
- struct menu_items items[9];
+ struct menu_items items[8];
items[i].desc = str(LANG_BOOKMARK_MENU);
items[i++].function = bookmark_menu;
@@ -336,9 +336,6 @@ bool main_menu(void)
items[i].desc = str(LANG_INFO);
items[i++].function = info_menu;
- items[i].desc = str(LANG_CREATE_DIR);
- items[i++].function = create_dir;
-
m=menu_init( items, i );
#ifdef HAVE_LCD_CHARCELLS
status_set_param(true);
diff --git a/apps/onplay.c b/apps/onplay.c
index 2f0ee3b861..52d5d20c6e 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -507,6 +507,34 @@ static bool vbr_fix(void)
return false;
}
+bool create_dir(void)
+{
+ char dirname[MAX_PATH];
+ char *cwd;
+ int rc;
+ int pathlen;
+
+ cwd = getcwd(NULL, 0);
+ memset(dirname, 0, sizeof dirname);
+
+ snprintf(dirname, sizeof dirname, "%s/",
+ cwd[1] ? cwd : "");
+
+ pathlen = strlen(dirname);
+ rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
+ if(rc < 0)
+ return false;
+
+ rc = mkdir(dirname, 0);
+ if(rc < 0) {
+ splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
+ } else {
+ onplay_result = ONPLAY_RELOAD_DIR;
+ }
+
+ return true;
+}
+
int onplay(char* file, int attr)
{
struct menu_items menu[5]; /* increase this if you add entries! */
@@ -514,36 +542,43 @@ int onplay(char* file, int attr)
onplay_result = ONPLAY_OK;
- selected_file = file;
- selected_file_attr = attr;
-
- if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
- (attr & ATTR_DIRECTORY) ||
- ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
+ if(file)
{
- menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST);
- menu[i].function = playlist_options;
+ selected_file = file;
+ selected_file_attr = attr;
+
+ if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
+ (attr & ATTR_DIRECTORY) ||
+ ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
+ {
+ menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST);
+ menu[i].function = playlist_options;
+ i++;
+ }
+
+ menu[i].desc = str(LANG_RENAME);
+ menu[i].function = rename_file;
i++;
+
+ if (!(attr & ATTR_DIRECTORY))
+ {
+ menu[i].desc = str(LANG_DELETE);
+ menu[i].function = delete_file;
+ i++;
+ }
+
+ if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
+ {
+ menu[i].desc = str(LANG_VBRFIX);
+ menu[i].function = vbr_fix;
+ i++;
+ }
}
- menu[i].desc = str(LANG_RENAME);
- menu[i].function = rename_file;
+ menu[i].desc = str(LANG_CREATE_DIR);
+ menu[i].function = create_dir;
i++;
- if (!(attr & ATTR_DIRECTORY))
- {
- menu[i].desc = str(LANG_DELETE);
- menu[i].function = delete_file;
- i++;
- }
-
- if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
- {
- menu[i].desc = str(LANG_VBRFIX);
- menu[i].function = vbr_fix;
- i++;
- }
-
/* DIY menu handling, since we want to exit after selection */
m = menu_init( menu, i );
result = menu_show(m);
diff --git a/apps/tree.c b/apps/tree.c
index aedeeb1dfd..88fb2f3ab0 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -773,16 +773,18 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
int onplay_result;
if(!numentries)
- break;
+ onplay_result = onplay(NULL, 0);
+ else {
+ if (currdir[1])
+ snprintf(buf, sizeof buf, "%s/%s",
+ currdir, dircache[dircursor+dirstart].name);
+ else
+ snprintf(buf, sizeof buf, "/%s",
+ dircache[dircursor+dirstart].name);
+ onplay_result = onplay(buf,
+ dircache[dircursor+dirstart].attr);
+ }
- if (currdir[1])
- snprintf(buf, sizeof buf, "%s/%s",
- currdir, dircache[dircursor+dirstart].name);
- else
- snprintf(buf, sizeof buf, "/%s",
- dircache[dircursor+dirstart].name);
- onplay_result = onplay(buf,
- dircache[dircursor+dirstart].attr);
switch (onplay_result)
{
case ONPLAY_OK:
@@ -1502,30 +1504,6 @@ bool create_playlist(void)
return true;
}
-bool create_dir(void)
-{
- char dirname[MAX_PATH];
- int rc;
- int pathlen;
-
- memset(dirname, 0, sizeof dirname);
-
- snprintf(dirname, sizeof dirname, "%s/",
- currdir[1] ? currdir : "");
-
- pathlen = strlen(dirname);
- rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
- if(rc < 0)
- return false;
-
- rc = mkdir(dirname, 0);
- if(rc < 0) {
- splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
- }
-
- return true;
-}
-
bool rockbox_browse(char *root, int dirfilter)
{
bool rc;
diff --git a/apps/tree.h b/apps/tree.h
index 45297361f5..c7b678eb82 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -47,7 +47,6 @@ void browse_root(void);
void set_current_file(char *path);
bool rockbox_browse(char *root, int dirfilter);
bool create_playlist(void);
-bool create_dir(void);
void resume_directory(char *dir);
char *getcwd(char *buf, int size);
void reload_directory(void);