diff options
Diffstat (limited to 'apps/plugins/pictureflow/pictureflow.c')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 63 |
1 files changed, 60 insertions, 3 deletions
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 | ||
4201 | static bool playlist_insert(int position, bool queue, bool create_new) | 4201 | static 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 | |||
4233 | static 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 | |||
4232 | static bool track_list_ready(void) | 4270 | static 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 | ||
4292 | static int context_menu(void) | 4330 | static 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); |