summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/pictureflow/pictureflow.c63
-rw-r--r--manual/plugins/pictureflow.tex4
4 files changed, 66 insertions, 6 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 2bcbc93de6..c28954e9eb 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -824,6 +824,7 @@ static const struct plugin_api rockbox_api = {
824 splash_progress, 824 splash_progress,
825 splash_progress_set_delay, 825 splash_progress_set_delay,
826 fix_path_part, 826 fix_path_part,
827 onplay_show_playlist_cat_menu,
827}; 828};
828 829
829static int plugin_buffer_handle; 830static int plugin_buffer_handle;
diff --git a/apps/plugin.h b/apps/plugin.h
index 474ccc5b82..850e7484d9 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -157,7 +157,7 @@ int plugin_open(const char *plugin, const char *parameter);
157#define PLUGIN_MAGIC 0x526F634B /* RocK */ 157#define PLUGIN_MAGIC 0x526F634B /* RocK */
158 158
159/* increase this every time the api struct changes */ 159/* increase this every time the api struct changes */
160#define PLUGIN_API_VERSION 262 160#define PLUGIN_API_VERSION 263
161 161
162/* update this to latest version if a change to the api struct breaks 162/* update this to latest version if a change to the api struct breaks
163 backwards compatibility (and please take the opportunity to sort in any 163 backwards compatibility (and please take the opportunity to sort in any
@@ -948,6 +948,8 @@ struct plugin_api {
948 void (*splash_progress)(int current, int total, const char *fmt, ...) ATTRIBUTE_PRINTF(3, 4); 948 void (*splash_progress)(int current, int total, const char *fmt, ...) ATTRIBUTE_PRINTF(3, 4);
949 void (*splash_progress_set_delay)(long delay_ticks); 949 void (*splash_progress_set_delay)(long delay_ticks);
950 void (*fix_path_part)(char* path, int offset, int count); 950 void (*fix_path_part)(char* path, int offset, int count);
951 void (*onplay_show_playlist_cat_menu)(const char* track_name, int attr,
952 void (*add_to_pl_cb));
951}; 953};
952 954
953/* plugin header */ 955/* plugin header */
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 61d0b64e94..b2cf467a2f 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -4198,7 +4198,7 @@ static int show_id3_info(const char *selected_file)
4198} 4198}
4199 4199
4200 4200
4201static bool playlist_insert(int position, bool queue, bool create_new) 4201static bool pf_current_playlist_insert(int position, bool queue, bool create_new)
4202{ 4202{
4203 if (position == PLAYLIST_REPLACE) 4203 if (position == PLAYLIST_REPLACE)
4204 { 4204 {
@@ -4229,6 +4229,44 @@ static bool playlist_insert(int position, bool queue, bool create_new)
4229 return true; 4229 return true;
4230} 4230}
4231 4231
4232
4233static int pf_add_to_playlist(const char* playlist, bool new_playlist)
4234{
4235 int fd;
4236 int result = 0;
4237
4238 if (new_playlist)
4239 fd = rb->open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC);
4240 else
4241 fd = rb->open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666);
4242
4243 if(fd < 0)
4244 return -1;
4245
4246 rb->reload_directory();
4247
4248 if (!insert_whole_album)
4249 {
4250 if (rb->fdprintf(fd, "%s\n", get_track_filename(pf_tracks.sel)) <= 0)
4251 result = -1;
4252 }
4253 else
4254 {
4255 int i = 0;
4256 do {
4257 if (rb->fdprintf(fd, "%s\n", get_track_filename(i)) <= 0)
4258 {
4259 result = -1;
4260 break;
4261 }
4262 rb->yield();
4263 } while(++i < pf_tracks.count);
4264 }
4265 rb->close(fd);
4266 return result;
4267}
4268
4269
4232static bool track_list_ready(void) 4270static bool track_list_ready(void)
4233{ 4271{
4234 if (pf_state != pf_show_tracks) 4272 if (pf_state != pf_show_tracks)
@@ -4291,14 +4329,18 @@ static void context_menu_cleanup(void)
4291 4329
4292static int context_menu(void) 4330static int context_menu(void)
4293{ 4331{
4332 char album_name[MAX_PATH];
4294 char *file_name = get_track_filename(pf_tracks.sel); 4333 char *file_name = get_track_filename(pf_tracks.sel);
4334 int attr;
4295 4335
4296 enum { 4336 enum {
4297 PF_CURRENT_PLAYLIST = 0, 4337 PF_CURRENT_PLAYLIST = 0,
4338 PF_CATALOG,
4298 PF_ID3_INFO 4339 PF_ID3_INFO
4299 }; 4340 };
4300 MENUITEM_STRINGLIST(context_menu, ID2P(LANG_ONPLAY_MENU_TITLE), NULL, 4341 MENUITEM_STRINGLIST(context_menu, ID2P(LANG_ONPLAY_MENU_TITLE), NULL,
4301 ID2P(LANG_PLAYING_NEXT), 4342 ID2P(LANG_PLAYING_NEXT),
4343 ID2P(LANG_ADD_TO_PL),
4302 ID2P(LANG_MENU_SHOW_ID3_INFO)); 4344 ID2P(LANG_MENU_SHOW_ID3_INFO));
4303 4345
4304 while (1) { 4346 while (1) {
@@ -4307,7 +4349,22 @@ static int context_menu(void)
4307 4349
4308 case PF_CURRENT_PLAYLIST: 4350 case PF_CURRENT_PLAYLIST:
4309 rb->onplay_show_playlist_menu(file_name, 4351 rb->onplay_show_playlist_menu(file_name,
4310 &playlist_insert); 4352 &pf_current_playlist_insert);
4353 return 0;
4354 case PF_CATALOG:
4355 if (!insert_whole_album)
4356 attr = FILE_ATTR_AUDIO;
4357 else
4358 {
4359 /* add a leading slash so that catalog_add_to_a_playlist
4360 later prefills the name when creating a new playlist */
4361 rb->snprintf(album_name, MAX_PATH, "/%s", get_album_name(center_index));
4362 rb->fix_path_part(album_name, 1, sizeof(album_name));
4363 file_name = album_name;
4364 attr = ATTR_DIRECTORY;
4365 }
4366
4367 rb->onplay_show_playlist_cat_menu(file_name, attr, &pf_add_to_playlist);
4311 return 0; 4368 return 0;
4312 case PF_ID3_INFO: 4369 case PF_ID3_INFO:
4313 return show_id3_info(file_name); 4370 return show_id3_info(file_name);
@@ -4354,7 +4411,7 @@ static bool start_playback(bool return_to_WPS)
4354 if (shuffle || center_slide.slide_index != old_playlist 4411 if (shuffle || center_slide.slide_index != old_playlist
4355 || (old_shuffle != shuffle)) 4412 || (old_shuffle != shuffle))
4356 { 4413 {
4357 if (!playlist_insert(PLAYLIST_REPLACE, false, true)) 4414 if (!pf_current_playlist_insert(PLAYLIST_REPLACE, false, true))
4358 { 4415 {
4359#ifdef USEGSLIB 4416#ifdef USEGSLIB
4360 grey_show(true); 4417 grey_show(true);
diff --git a/manual/plugins/pictureflow.tex b/manual/plugins/pictureflow.tex
index 5aee31c004..c0b86e34da 100644
--- a/manual/plugins/pictureflow.tex
+++ b/manual/plugins/pictureflow.tex
@@ -2,8 +2,8 @@
2\screenshot{plugins/images/ss-pictureflow}{PictureFlow}{img:pictureflow} 2\screenshot{plugins/images/ss-pictureflow}{PictureFlow}{img:pictureflow}
3PictureFlow is a visual browser for your albums. After you've selected something to play, 3PictureFlow is a visual browser for your albums. After you've selected something to play,
4PictureFlow will continue running by default, or can optionally show the WPS. Using 4PictureFlow will continue running by default, or can optionally show the WPS. Using
5the context menu, songs can be added to the dynamic playlist directly from PictureFlow 5the context menu, songs can be added to the dynamic playlist or other playlists directly
6(see \reference{ref:playingnext_submenu}). 6from PictureFlow (see \reference{ref:playingnext_submenu}).
7Various metadata, such as format, length or year of an album or its songs can also be 7Various metadata, such as format, length or year of an album or its songs can also be
8displayed. 8displayed.
9 9