forked from len0rd/rockbox
Henrik Backes patch for WPS and tag database context menus. Tag database context menus still don't work as expected. Hold Play/Select to pop up the menu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6835 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8b493fa6c4
commit
6e0436f65c
11 changed files with 281 additions and 144 deletions
|
@ -24,5 +24,6 @@
|
||||||
#define CONTEXT_TREE 2
|
#define CONTEXT_TREE 2
|
||||||
#define CONTEXT_RECORD 3
|
#define CONTEXT_RECORD 3
|
||||||
#define CONTEXT_MAINMENU 4
|
#define CONTEXT_MAINMENU 4
|
||||||
|
#define CONTEXT_ID3DB 5
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
|
#define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
|
||||||
|
|
||||||
static bool add_bookmark(const char* bookmark_file_name, const char* bookmark);
|
static bool add_bookmark(const char* bookmark_file_name, const char* bookmark);
|
||||||
static bool bookmark_load_menu(void);
|
|
||||||
static bool check_bookmark(const char* bookmark);
|
static bool check_bookmark(const char* bookmark);
|
||||||
static char* create_bookmark(void);
|
static char* create_bookmark(void);
|
||||||
static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id);
|
static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id);
|
||||||
|
@ -86,38 +85,6 @@ static char global_read_buffer[MAX_BOOKMARK_SIZE];
|
||||||
static char global_bookmark[MAX_BOOKMARK_SIZE];
|
static char global_bookmark[MAX_BOOKMARK_SIZE];
|
||||||
static char global_filename[MAX_PATH];
|
static char global_filename[MAX_PATH];
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
|
||||||
/* Displays the bookmark menu options for the user to decide. This is an */
|
|
||||||
/* interface function. */
|
|
||||||
/* ----------------------------------------------------------------------- */
|
|
||||||
bool bookmark_menu(void)
|
|
||||||
{
|
|
||||||
int m;
|
|
||||||
bool result;
|
|
||||||
|
|
||||||
static const struct menu_item items[] = {
|
|
||||||
{ ID2P(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu},
|
|
||||||
{ ID2P(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu},
|
|
||||||
{ ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load},
|
|
||||||
};
|
|
||||||
|
|
||||||
m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
|
||||||
status_set_param(true);
|
|
||||||
#endif
|
|
||||||
result = menu_run(m);
|
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
|
||||||
status_set_param(false);
|
|
||||||
#endif
|
|
||||||
menu_exit(m);
|
|
||||||
|
|
||||||
settings_save();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* This is the interface function from the main menu. */
|
/* This is the interface function from the main menu. */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -133,7 +100,7 @@ bool bookmark_create_menu(void)
|
||||||
/* for the user. The user can then select a bookmark to load. */
|
/* for the user. The user can then select a bookmark to load. */
|
||||||
/* If no file/directory is currently playing, the menu item does not work. */
|
/* If no file/directory is currently playing, the menu item does not work. */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
static bool bookmark_load_menu(void)
|
bool bookmark_load_menu(void)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
int offset;
|
int offset;
|
||||||
|
@ -628,6 +595,8 @@ static char* select_bookmark(const char* bookmark_file_name)
|
||||||
int bookmark_count = 0;
|
int bookmark_count = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
int x = lcd_getxmargin();
|
||||||
|
int y = lcd_getymargin();
|
||||||
lcd_setmargins(0, 0);
|
lcd_setmargins(0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -711,6 +680,9 @@ static char* select_bookmark(const char* bookmark_file_name)
|
||||||
#endif
|
#endif
|
||||||
#ifdef SETTINGS_OK2
|
#ifdef SETTINGS_OK2
|
||||||
case SETTINGS_OK2:
|
case SETTINGS_OK2:
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
lcd_setmargins(x, y);
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1141,6 +1113,31 @@ static bool generate_bookmark_file_name(const char *in)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* Returns the bookmark name for the current playlist */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
bool bookmark_exist(void)
|
||||||
|
{
|
||||||
|
bool exist=false;
|
||||||
|
|
||||||
|
if(system_check())
|
||||||
|
{
|
||||||
|
char* name = playlist_get_name(NULL, global_temp_buffer,
|
||||||
|
sizeof(global_temp_buffer));
|
||||||
|
if (generate_bookmark_file_name(name))
|
||||||
|
{
|
||||||
|
int fd=open(global_bookmark_file_name, O_RDONLY);
|
||||||
|
if (fd >=0)
|
||||||
|
{
|
||||||
|
close(fd);
|
||||||
|
exist=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return exist;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Checks the current state of the system and returns if it is in a */
|
/* Checks the current state of the system and returns if it is in a */
|
||||||
/* bookmarkable state. */
|
/* bookmarkable state. */
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
bool bookmark_menu(void);
|
bool bookmark_load_menu(void);
|
||||||
bool bookmark_autobookmark(void);
|
bool bookmark_autobookmark(void);
|
||||||
bool bookmark_create_menu(void);
|
bool bookmark_create_menu(void);
|
||||||
bool bookmark_mrb_load(void);
|
bool bookmark_mrb_load(void);
|
||||||
|
@ -29,6 +29,7 @@ bool bookmark_autoload(const char* file);
|
||||||
bool bookmark_load(const char* file, bool autoload);
|
bool bookmark_load(const char* file, bool autoload);
|
||||||
void bookmark_play(char* resume_file, int index, int offset, int seed,
|
void bookmark_play(char* resume_file, int index, int offset, int seed,
|
||||||
char *filename);
|
char *filename);
|
||||||
|
bool bookmark_exist(void);
|
||||||
|
|
||||||
#endif /* __BOOKMARK_H__ */
|
#endif /* __BOOKMARK_H__ */
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "debug_menu.h"
|
#include "debug_menu.h"
|
||||||
#include "sprintf.h"
|
#include "sprintf.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "playlist.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "settings_menu.h"
|
#include "settings_menu.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
@ -41,7 +40,6 @@
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
#include "bookmark.h"
|
#include "bookmark.h"
|
||||||
#include "wps.h"
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "playlist_menu.h"
|
#include "playlist_menu.h"
|
||||||
|
@ -342,7 +340,6 @@ bool info_menu(void)
|
||||||
|
|
||||||
/* info menu */
|
/* info menu */
|
||||||
static const struct menu_item items[] = {
|
static const struct menu_item items[] = {
|
||||||
{ ID2P(LANG_MENU_SHOW_ID3_INFO), browse_id3 },
|
|
||||||
{ ID2P(LANG_INFO_MENU), show_info },
|
{ ID2P(LANG_INFO_MENU), show_info },
|
||||||
{ ID2P(LANG_VERSION), show_credits },
|
{ ID2P(LANG_VERSION), show_credits },
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
@ -373,8 +370,8 @@ bool main_menu(void)
|
||||||
/* main menu */
|
/* main menu */
|
||||||
struct menu_item items[9];
|
struct menu_item items[9];
|
||||||
|
|
||||||
items[i].desc = ID2P(LANG_BOOKMARK_MENU);
|
items[i].desc = ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS);
|
||||||
items[i++].function = bookmark_menu;
|
items[i++].function = bookmark_mrb_load;
|
||||||
|
|
||||||
items[i].desc = ID2P(LANG_SOUND_SETTINGS);
|
items[i].desc = ID2P(LANG_SOUND_SETTINGS);
|
||||||
items[i++].function = sound_menu;
|
items[i++].function = sound_menu;
|
||||||
|
|
166
apps/onplay.c
166
apps/onplay.c
|
@ -45,11 +45,68 @@
|
||||||
#include "onplay.h"
|
#include "onplay.h"
|
||||||
#include "filetypes.h"
|
#include "filetypes.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
#include "bookmark.h"
|
||||||
|
#include "wps.h"
|
||||||
|
#include "action.h"
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
#include "icons.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_PLAYLIST_NAME "/dynamic.m3u"
|
||||||
|
|
||||||
|
static int context;
|
||||||
static char* selected_file = NULL;
|
static char* selected_file = NULL;
|
||||||
static int selected_file_attr = 0;
|
static int selected_file_attr = 0;
|
||||||
static int onplay_result = ONPLAY_OK;
|
static int onplay_result = ONPLAY_OK;
|
||||||
|
|
||||||
|
/* For playlist options */
|
||||||
|
struct playlist_args {
|
||||||
|
int position;
|
||||||
|
bool queue;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* Displays the bookmark menu options for the user to decide. This is an */
|
||||||
|
/* interface function. */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
bool bookmark_menu(void)
|
||||||
|
{
|
||||||
|
int i,m;
|
||||||
|
bool result;
|
||||||
|
struct menu_item items[3];
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
|
||||||
|
if ((audio_status() & AUDIO_STATUS_PLAY))
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_BOOKMARK_MENU_CREATE);
|
||||||
|
items[i].function = bookmark_create_menu;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (bookmark_exist())
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_BOOKMARK_MENU_LIST);
|
||||||
|
items[i].function = bookmark_load_menu;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m=menu_init( items, i, NULL, NULL, NULL, NULL );
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
|
status_set_param(true);
|
||||||
|
#endif
|
||||||
|
result = menu_run(m);
|
||||||
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
|
status_set_param(false);
|
||||||
|
#endif
|
||||||
|
menu_exit(m);
|
||||||
|
|
||||||
|
settings_save();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static bool list_viewers(void)
|
static bool list_viewers(void)
|
||||||
{
|
{
|
||||||
struct menu_item menu[16];
|
struct menu_item menu[16];
|
||||||
|
@ -70,17 +127,28 @@ static bool list_viewers(void)
|
||||||
splash(HZ*2, true, "No viewers found");
|
splash(HZ*2, true, "No viewers found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret == PLUGIN_USB_CONNECTED)
|
if (ret == PLUGIN_USB_CONNECTED)
|
||||||
onplay_result = ONPLAY_RELOAD_DIR;
|
onplay_result = ONPLAY_RELOAD_DIR;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For playlist options */
|
static bool save_playlist(void)
|
||||||
struct playlist_args {
|
{
|
||||||
int position;
|
char filename[MAX_PATH+1];
|
||||||
bool queue;
|
|
||||||
};
|
strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename));
|
||||||
|
|
||||||
|
if (!kbd_input(filename, sizeof(filename)))
|
||||||
|
{
|
||||||
|
playlist_save(NULL, filename);
|
||||||
|
|
||||||
|
/* reload in case playlist was saved to cwd */
|
||||||
|
onplay_result = ONPLAY_RELOAD_DIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool add_to_playlist(int position, bool queue)
|
static bool add_to_playlist(int position, bool queue)
|
||||||
{
|
{
|
||||||
|
@ -168,12 +236,13 @@ static bool view_playlist(void)
|
||||||
/* Sub-menu for playlist options */
|
/* Sub-menu for playlist options */
|
||||||
static bool playlist_options(void)
|
static bool playlist_options(void)
|
||||||
{
|
{
|
||||||
struct menu_item items[7];
|
struct menu_item items[10];
|
||||||
struct playlist_args args[7]; /* increase these 2 if you add entries! */
|
struct playlist_args args[10]; /* increase these 2 if you add entries! */
|
||||||
int m, i=0, pstart=0, result;
|
int m, i=0, pstart=0, result;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U &&
|
||||||
|
context == CONTEXT_TREE)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_VIEW);
|
items[i].desc = ID2P(LANG_VIEW);
|
||||||
items[i].function = view_playlist;
|
items[i].function = view_playlist;
|
||||||
|
@ -181,6 +250,26 @@ static bool playlist_options(void)
|
||||||
pstart++;
|
pstart++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_VIEW_DYNAMIC_PLAYLIST);
|
||||||
|
items[i].function = playlist_viewer;
|
||||||
|
i++;
|
||||||
|
pstart++;
|
||||||
|
|
||||||
|
items[i].desc = ID2P(LANG_SAVE_DYNAMIC_PLAYLIST);
|
||||||
|
items[i].function = save_playlist;
|
||||||
|
i++;
|
||||||
|
pstart++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context == CONTEXT_TREE)
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_CREATE_PLAYLIST);
|
||||||
|
items[i].function = create_playlist;
|
||||||
|
i++;
|
||||||
|
pstart++;
|
||||||
|
|
||||||
if (audio_status() & AUDIO_STATUS_PLAY)
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_INSERT);
|
items[i].desc = ID2P(LANG_INSERT);
|
||||||
|
@ -221,6 +310,7 @@ static bool playlist_options(void)
|
||||||
args[i].queue = false;
|
args[i].queue = false;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
||||||
result = menu_show(m);
|
result = menu_show(m);
|
||||||
|
@ -385,11 +475,11 @@ bool create_dir(void)
|
||||||
|
|
||||||
pathlen = strlen(dirname);
|
pathlen = strlen(dirname);
|
||||||
rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
|
rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
|
||||||
if(rc < 0)
|
if (rc < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
rc = mkdir(dirname, 0);
|
rc = mkdir(dirname, 0);
|
||||||
if(rc < 0) {
|
if (rc < 0) {
|
||||||
splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
|
splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
|
||||||
} else {
|
} else {
|
||||||
onplay_result = ONPLAY_RELOAD_DIR;
|
onplay_result = ONPLAY_RELOAD_DIR;
|
||||||
|
@ -398,50 +488,70 @@ bool create_dir(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int onplay(char* file, int attr)
|
int onplay(char* file, int attr, int from)
|
||||||
{
|
{
|
||||||
struct menu_item items[6]; /* increase this if you add entries! */
|
struct menu_item items[8]; /* increase this if you add entries! */
|
||||||
int m, i=0, result;
|
int m, i=0, result;
|
||||||
|
|
||||||
onplay_result = ONPLAY_OK;
|
onplay_result = ONPLAY_OK;
|
||||||
|
context=from;
|
||||||
if(file)
|
|
||||||
{
|
|
||||||
selected_file = file;
|
selected_file = file;
|
||||||
selected_file_attr = attr;
|
selected_file_attr = attr;
|
||||||
|
|
||||||
if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
if (context == CONTEXT_WPS ||
|
||||||
(attr & ATTR_DIRECTORY) ||
|
context == CONTEXT_TREE ||
|
||||||
((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
|
context == CONTEXT_ID3DB)
|
||||||
{
|
{
|
||||||
|
if ((audio_status() & AUDIO_STATUS_PLAY))
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_BOOKMARK_MENU);
|
||||||
|
items[i].function = bookmark_menu;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
items[i].desc = ID2P(LANG_PLAYLIST);
|
items[i].desc = ID2P(LANG_PLAYLIST);
|
||||||
items[i].function = playlist_options;
|
items[i].function = playlist_options;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
if (context == CONTEXT_WPS)
|
||||||
|
{
|
||||||
|
items[i].desc = ID2P(LANG_MENU_SHOW_ID3_INFO);
|
||||||
|
items[i].function = browse_id3;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_MULTIVOLUME
|
#ifdef HAVE_MULTIVOLUME
|
||||||
if (!(attr & ATTR_VOLUME)) /* no rename+delete for volumes */
|
if (!(attr & ATTR_VOLUME)) /* no rename+delete for volumes */
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
if (context == CONTEXT_TREE)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_RENAME);
|
items[i].desc = ID2P(LANG_RENAME);
|
||||||
items[i].function = rename_file;
|
items[i].function = rename_file;
|
||||||
i++;
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(attr & ATTR_DIRECTORY))
|
if (!(attr & ATTR_DIRECTORY) && context == CONTEXT_TREE)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_DELETE);
|
items[i].desc = ID2P(LANG_DELETE);
|
||||||
items[i].function = delete_file;
|
items[i].function = delete_file;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (context == CONTEXT_TREE)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_DELETE_DIR);
|
items[i].desc = ID2P(LANG_DELETE_DIR);
|
||||||
items[i].function = delete_dir;
|
items[i].function = delete_dir;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(attr & ATTR_DIRECTORY))
|
if (!(attr & ATTR_DIRECTORY) && attr)
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH);
|
items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH);
|
||||||
items[i].function = list_viewers;
|
items[i].function = list_viewers;
|
||||||
|
@ -449,16 +559,30 @@ int onplay(char* file, int attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context == CONTEXT_TREE)
|
||||||
|
{
|
||||||
items[i].desc = ID2P(LANG_CREATE_DIR);
|
items[i].desc = ID2P(LANG_CREATE_DIR);
|
||||||
items[i].function = create_dir;
|
items[i].function = create_dir;
|
||||||
i++;
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
/* DIY menu handling, since we want to exit after selection */
|
/* DIY menu handling, since we want to exit after selection */
|
||||||
|
button_clear_queue();
|
||||||
|
if (i)
|
||||||
|
{
|
||||||
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
||||||
result = menu_show(m);
|
result = menu_show(m);
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
items[result].function();
|
items[result].function();
|
||||||
menu_exit(m);
|
menu_exit(m);
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
if (global_settings.statusbar)
|
||||||
|
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
||||||
|
else
|
||||||
|
lcd_setmargins(0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return onplay_result;
|
return onplay_result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#ifndef _ONPLAY_H_
|
#ifndef _ONPLAY_H_
|
||||||
#define _ONPLAY_H_
|
#define _ONPLAY_H_
|
||||||
|
|
||||||
int onplay(char* file, int attr);
|
int onplay(char* file, int attr, int from_screen);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ONPLAY_OK,
|
ONPLAY_OK,
|
||||||
|
|
|
@ -20,34 +20,13 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "file.h"
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "playlist_viewer.h"
|
|
||||||
#include "talk.h"
|
#include "talk.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
#define DEFAULT_PLAYLIST_NAME "/dynamic.m3u"
|
|
||||||
|
|
||||||
static bool save_playlist(void)
|
|
||||||
{
|
|
||||||
char filename[MAX_PATH+1];
|
|
||||||
|
|
||||||
strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename));
|
|
||||||
|
|
||||||
if (!kbd_input(filename, sizeof(filename)))
|
|
||||||
{
|
|
||||||
playlist_save(NULL, filename);
|
|
||||||
|
|
||||||
/* reload in case playlist was saved to cwd */
|
|
||||||
reload_directory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool recurse_directory(void)
|
static bool recurse_directory(void)
|
||||||
{
|
{
|
||||||
static const struct opt_items names[] = {
|
static const struct opt_items names[] = {
|
||||||
|
@ -67,9 +46,6 @@ bool playlist_menu(void)
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
static const struct menu_item items[] = {
|
static const struct menu_item items[] = {
|
||||||
{ ID2P(LANG_CREATE_PLAYLIST), create_playlist },
|
|
||||||
{ ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
|
|
||||||
{ ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
|
|
||||||
{ ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
|
{ ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "onplay.h"
|
#include "onplay.h"
|
||||||
#include "talk.h"
|
#include "talk.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#include "widgets.h"
|
#include "widgets.h"
|
||||||
|
@ -728,7 +729,7 @@ static int onplay_menu(int index)
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
onplay(tracks[index].name, TREE_ATTR_MPA);
|
onplay(tracks[index].name, TREE_ATTR_MPA, CONTEXT_TREE);
|
||||||
|
|
||||||
if (!viewer.playlist)
|
if (!viewer.playlist)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
30
apps/tree.c
30
apps/tree.c
|
@ -110,6 +110,7 @@ static bool reload_dir = false;
|
||||||
|
|
||||||
static bool start_wps = false;
|
static bool start_wps = false;
|
||||||
static bool dirbrowse(void);
|
static bool dirbrowse(void);
|
||||||
|
static int curr_context = false;
|
||||||
|
|
||||||
bool check_rockboxdir(void)
|
bool check_rockboxdir(void)
|
||||||
{
|
{
|
||||||
|
@ -625,11 +626,15 @@ static bool check_changed_id3mode(bool currmode)
|
||||||
if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) {
|
if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) {
|
||||||
currmode = global_settings.dirfilter == SHOW_ID3DB;
|
currmode = global_settings.dirfilter == SHOW_ID3DB;
|
||||||
if (currmode) {
|
if (currmode) {
|
||||||
|
curr_context=CONTEXT_ID3DB;
|
||||||
db_load(&tc);
|
db_load(&tc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
curr_context=CONTEXT_TREE;
|
||||||
ft_load(&tc, NULL);
|
ft_load(&tc, NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return currmode;
|
return currmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,6 +665,11 @@ static bool dirbrowse(void)
|
||||||
char* currdir = tc.currdir; /* just a shortcut */
|
char* currdir = tc.currdir; /* just a shortcut */
|
||||||
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
||||||
|
|
||||||
|
if (id3db)
|
||||||
|
curr_context=CONTEXT_ID3DB;
|
||||||
|
else
|
||||||
|
curr_context=CONTEXT_TREE;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
tree_max_on_screen = recalc_screen_height();
|
tree_max_on_screen = recalc_screen_height();
|
||||||
#else
|
#else
|
||||||
|
@ -1059,7 +1069,7 @@ static bool dirbrowse(void)
|
||||||
/* don't enter f2 from plugin browser */
|
/* don't enter f2 from plugin browser */
|
||||||
if (*tc.dirfilter < NUM_FILTER_MODES)
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
||||||
{
|
{
|
||||||
if (quick_screen(CONTEXT_TREE, BUTTON_F2))
|
if (quick_screen(curr_context, BUTTON_F2))
|
||||||
reload_dir = true;
|
reload_dir = true;
|
||||||
restore = true;
|
restore = true;
|
||||||
|
|
||||||
|
@ -1071,7 +1081,7 @@ static bool dirbrowse(void)
|
||||||
/* don't enter f3 from plugin browser */
|
/* don't enter f3 from plugin browser */
|
||||||
if (*tc.dirfilter < NUM_FILTER_MODES)
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
||||||
{
|
{
|
||||||
if (quick_screen(CONTEXT_TREE, BUTTON_F3))
|
if (quick_screen(curr_context, BUTTON_F3))
|
||||||
reload_dir = true;
|
reload_dir = true;
|
||||||
tree_max_on_screen = recalc_screen_height();
|
tree_max_on_screen = recalc_screen_height();
|
||||||
restore = true;
|
restore = true;
|
||||||
|
@ -1091,7 +1101,7 @@ static bool dirbrowse(void)
|
||||||
int attr = 0;
|
int attr = 0;
|
||||||
|
|
||||||
if(!numentries)
|
if(!numentries)
|
||||||
onplay_result = onplay(NULL, 0);
|
onplay_result = onplay(NULL, 0, curr_context);
|
||||||
else {
|
else {
|
||||||
if (currdir[1])
|
if (currdir[1])
|
||||||
snprintf(buf, sizeof buf, "%s/%s",
|
snprintf(buf, sizeof buf, "%s/%s",
|
||||||
|
@ -1099,9 +1109,19 @@ static bool dirbrowse(void)
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof buf, "/%s",
|
snprintf(buf, sizeof buf, "/%s",
|
||||||
dircache[tc.dircursor+tc.dirstart].name);
|
dircache[tc.dircursor+tc.dirstart].name);
|
||||||
if (!id3db)
|
if (id3db)
|
||||||
|
switch (tc.currtable)
|
||||||
|
{
|
||||||
|
case allsongs:
|
||||||
|
case songs4album:
|
||||||
|
case songs4artist:
|
||||||
|
case searchsongs:
|
||||||
|
attr=TREE_ATTR_MPA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
attr = dircache[tc.dircursor+tc.dirstart].attr;
|
attr = dircache[tc.dircursor+tc.dirstart].attr;
|
||||||
onplay_result = onplay(buf, attr);
|
onplay_result = onplay(buf, attr, curr_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (onplay_result)
|
switch (onplay_result)
|
||||||
|
|
15
apps/wps.c
15
apps/wps.c
|
@ -50,6 +50,7 @@
|
||||||
#include "bookmark.h"
|
#include "bookmark.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "onplay.h"
|
||||||
|
|
||||||
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
|
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
|
||||||
/* 3% of 30min file == 54s step size */
|
/* 3% of 30min file == 54s step size */
|
||||||
|
@ -472,6 +473,12 @@ long wps_show(void)
|
||||||
|
|
||||||
switch(button)
|
switch(button)
|
||||||
{
|
{
|
||||||
|
#ifdef WPS_CONTEXT
|
||||||
|
case WPS_CONTEXT:
|
||||||
|
onplay(id3->path, TREE_ATTR_MPA, CONTEXT_WPS);
|
||||||
|
restore = true;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#ifdef WPS_RC_BROWSE
|
#ifdef WPS_RC_BROWSE
|
||||||
case WPS_RC_BROWSE:
|
case WPS_RC_BROWSE:
|
||||||
#endif
|
#endif
|
||||||
|
@ -502,6 +509,14 @@ long wps_show(void)
|
||||||
case WPS_PAUSE:
|
case WPS_PAUSE:
|
||||||
#ifdef WPS_RC_PAUSE
|
#ifdef WPS_RC_PAUSE
|
||||||
case WPS_RC_PAUSE:
|
case WPS_RC_PAUSE:
|
||||||
|
#endif
|
||||||
|
#ifdef WPS_PAUSE_PRE
|
||||||
|
if ((lastbutton != WPS_PAUSE_PRE)
|
||||||
|
#ifdef WPS_RC_PAUSE_PRE
|
||||||
|
&& (lastbutton != WPS_RC_PAUSE_PRE)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
if ( paused )
|
if ( paused )
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define WPS_BROWSE_PRE BUTTON_SELECT
|
#define WPS_BROWSE_PRE BUTTON_SELECT
|
||||||
#define WPS_EXIT BUTTON_OFF
|
#define WPS_EXIT BUTTON_OFF
|
||||||
#define WPS_ID3 (BUTTON_MODE | BUTTON_ON)
|
#define WPS_ID3 (BUTTON_MODE | BUTTON_ON)
|
||||||
|
#define WPS_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT)
|
||||||
|
|
||||||
#define WPS_RC_NEXT BUTTON_RC_FF
|
#define WPS_RC_NEXT BUTTON_RC_FF
|
||||||
#define WPS_RC_PREV BUTTON_RC_REW
|
#define WPS_RC_PREV BUTTON_RC_REW
|
||||||
|
@ -59,7 +60,8 @@
|
||||||
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
|
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
|
||||||
#define WPS_INCVOL BUTTON_UP
|
#define WPS_INCVOL BUTTON_UP
|
||||||
#define WPS_DECVOL BUTTON_DOWN
|
#define WPS_DECVOL BUTTON_DOWN
|
||||||
#define WPS_PAUSE BUTTON_PLAY
|
#define WPS_PAUSE_PRE BUTTON_PLAY
|
||||||
|
#define WPS_PAUSE (BUTTON_PLAY | BUTTON_REL)
|
||||||
#define WPS_MENU (BUTTON_F1 | BUTTON_REL)
|
#define WPS_MENU (BUTTON_F1 | BUTTON_REL)
|
||||||
#define WPS_MENU_PRE BUTTON_F1
|
#define WPS_MENU_PRE BUTTON_F1
|
||||||
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
|
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
|
||||||
|
@ -67,6 +69,7 @@
|
||||||
#define WPS_EXIT BUTTON_OFF
|
#define WPS_EXIT BUTTON_OFF
|
||||||
#define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN)
|
#define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN)
|
||||||
#define WPS_ID3 (BUTTON_F1 | BUTTON_ON)
|
#define WPS_ID3 (BUTTON_F1 | BUTTON_ON)
|
||||||
|
#define WPS_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT)
|
||||||
|
|
||||||
#define WPS_RC_NEXT BUTTON_RC_RIGHT
|
#define WPS_RC_NEXT BUTTON_RC_RIGHT
|
||||||
#define WPS_RC_PREV BUTTON_RC_LEFT
|
#define WPS_RC_PREV BUTTON_RC_LEFT
|
||||||
|
@ -84,7 +87,8 @@
|
||||||
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
|
#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
|
||||||
#define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT)
|
#define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT)
|
||||||
#define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT)
|
#define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT)
|
||||||
#define WPS_PAUSE BUTTON_PLAY
|
#define WPS_PAUSE_PRE BUTTON_PLAY
|
||||||
|
#define WPS_PAUSE (BUTTON_PLAY | BUTTON_REL)
|
||||||
#define WPS_MENU (BUTTON_MENU | BUTTON_REL)
|
#define WPS_MENU (BUTTON_MENU | BUTTON_REL)
|
||||||
#define WPS_MENU_PRE BUTTON_MENU
|
#define WPS_MENU_PRE BUTTON_MENU
|
||||||
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
|
#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
|
||||||
|
@ -92,6 +96,7 @@
|
||||||
#define WPS_EXIT BUTTON_STOP
|
#define WPS_EXIT BUTTON_STOP
|
||||||
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP)
|
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP)
|
||||||
#define WPS_ID3 (BUTTON_MENU | BUTTON_ON)
|
#define WPS_ID3 (BUTTON_MENU | BUTTON_ON)
|
||||||
|
#define WPS_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT)
|
||||||
|
|
||||||
#define WPS_RC_NEXT BUTTON_RC_RIGHT
|
#define WPS_RC_NEXT BUTTON_RC_RIGHT
|
||||||
#define WPS_RC_PREV BUTTON_RC_LEFT
|
#define WPS_RC_PREV BUTTON_RC_LEFT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue