summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2021-12-27 03:36:31 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-12-28 11:06:10 -0500
commite8b912320561c1178d45eb12cf753be62e40ee73 (patch)
tree9ee7b3d865864abcbd0d52f4efbc57bf7292c7e3
parent7d59bbd170454cf433a8214808d09fb58f3489d2 (diff)
downloadrockbox-e8b9123205.tar.gz
rockbox-e8b9123205.zip
Database: show song's album in PictureFlow
Adds a 'PictureFlow' command to database context menus for quickly bringing up the album for a song in PictureFlow. Change-Id: I88cd89e93d9418558c698a15fc7fb5d9a90fb262
-rw-r--r--apps/onplay.c11
-rw-r--r--apps/plugins/pictureflow/pictureflow.c41
-rw-r--r--apps/plugins/viewers.config3
3 files changed, 48 insertions, 7 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index c3e1ebec54..aeda39ba14 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -1586,6 +1586,11 @@ MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH),
MENUITEM_FUNCTION(properties_item, MENU_FUNC_USEPARAM, ID2P(LANG_PROPERTIES),
onplay_load_plugin, (void *)"properties",
clipboard_callback, Icon_NOICON);
+#ifdef HAVE_TAGCACHE
+MENUITEM_FUNCTION(pictureflow_item, MENU_FUNC_USEPARAM, ID2P(LANG_ONPLAY_PICTUREFLOW),
+ onplay_load_plugin, (void *)"pictureflow",
+ clipboard_callback, Icon_NOICON);
+#endif
static bool onplay_add_to_shortcuts(void)
{
shortcuts_add(SHORTCUT_BROWSER, selected_file);
@@ -1652,7 +1657,8 @@ static int clipboard_callback(int action,
{
if (((selected_file_attr & FILE_ATTR_MASK) ==
FILE_ATTR_AUDIO) &&
- this_item == &properties_item)
+ (this_item == &properties_item ||
+ this_item == &pictureflow_item))
return action;
return ACTION_EXIT_MENUITEM;
}
@@ -1751,6 +1757,9 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
&set_backdrop_item,
#endif
&list_viewers_item, &create_dir_item, &properties_item,
+#ifdef HAVE_TAGCACHE
+ &pictureflow_item,
+#endif
#ifdef HAVE_RECORDING
&set_recdir_item,
#endif
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 35afdaf7e4..ec6e51c34d 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -1613,11 +1613,10 @@ static int get_album_artist_alpha_next_index(void)
return pf_idx.album_ct - 1;
}
-static int get_wps_current_index(void)
+static int id3_get_index(struct mp3entry *id3)
{
char* current_artist = UNTAGGED;
char* current_album = UNTAGGED;
- struct mp3entry *id3 = rb->audio_current_track();
if(id3)
{
@@ -3752,6 +3751,35 @@ static void rb_splash_added_to_playlist(void)
}
#endif
+
+static void set_initial_slide(const char* selected_file)
+{
+ if (selected_file == NULL)
+ set_current_slide(id3_get_index(rb->audio_current_track()));
+ else
+ {
+ struct mp3entry id3;
+#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
+ if (rb->tagcache_fill_tags(&id3, selected_file))
+ set_current_slide(id3_get_index(&id3));
+ else
+#endif
+ {
+ int fd = rb->open(selected_file, O_RDONLY);
+ if (fd >= 0)
+ {
+ if (rb->get_metadata(&id3, fd, selected_file))
+ set_current_slide(id3_get_index(&id3));
+ else
+ set_current_slide(pf_cfg.last_album);
+ rb->close(fd);
+ }
+ else
+ set_current_slide(pf_cfg.last_album);
+ }
+ }
+}
+
/**
Display an error message and wait for input.
*/
@@ -3767,7 +3795,7 @@ static void error_wait(const char *message)
Main function that also contain the main plasma
algorithm.
*/
-static int pictureflow_main(void)
+static int pictureflow_main(const char* selected_file)
{
int ret = SUCCESS;
@@ -3888,7 +3916,7 @@ static int pictureflow_main(void)
recalc_offsets();
reset_slides();
- set_current_slide(get_wps_current_index());
+ set_initial_slide(selected_file);
char fpstxt[10];
int button;
@@ -4137,11 +4165,12 @@ enum plugin_status plugin_start(const void *parameter)
lcd_fb = vp_main->buffer->fb_ptr;
int ret;
- (void) parameter;
+ const char *file = parameter;
void * buf;
size_t buf_size;
bool prompt = (parameter && (((char *) parameter)[0] == ACTIVITY_MAINMENU));
+ bool file_id3 = (parameter && (((char *) parameter)[0] == '/'));
if (!check_database(prompt))
{
@@ -4188,7 +4217,7 @@ enum plugin_status plugin_start(const void *parameter)
pf_idx.buf = buf;
pf_idx.buf_sz = buf_size;
- ret = pictureflow_main();
+ ret = file_id3 ? pictureflow_main(file) : pictureflow_main(NULL);
if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) {
if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS,
CONFIG_VERSION))
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config
index 2bf052bb20..8aa0ac370a 100644
--- a/apps/plugins/viewers.config
+++ b/apps/plugins/viewers.config
@@ -103,3 +103,6 @@ z7,viewers/frotz,-
z8,viewers/frotz,-
shopper,viewers/shopper,1
lnk,viewers/windows_lnk,-
+#ifdef HAVE_TAGCACHE
+*,demos/pictureflow,-
+#endif \ No newline at end of file