From e23ddeed4b98b02a9925035f38dd2ccdadef28b9 Mon Sep 17 00:00:00 2001 From: Andreas Obergrusberger Date: Fri, 30 Nov 2007 16:09:30 +0000 Subject: [PATCH] cmd_select_all added git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@7061 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- ChangeLog | 3 ++ src/command.c | 2 ++ src/command.h | 1 + src/screen_browse.h | 4 +++ src/screen_file.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ src/screen_help.c | 1 + src/screen_search.c | 5 +++ 7 files changed, 99 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4ff8da5..67f3617 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2007-11-30 Andreas Obergrusberger + * added a function to select all listed items on the search screen + 2007-06-17 Andreas Obergrusberger * two critical bugs in leoslyrics source have been fixed 2007-02-16 Andreas Obergrusberger diff --git a/src/command.c b/src/command.c index 3210f39..d0d1419 100644 --- a/src/command.c +++ b/src/command.c @@ -118,6 +118,8 @@ static command_definition_t cmds[] = N_("Decrease volume") }, { { ' ', 0, 0 }, 0, CMD_SELECT, "select", N_("Select/deselect song in playlist") }, + { { 't', 0, 0 }, 0, CMD_SELECT_ALL, "select_all", + N_("Select all listed items") }, { { DEL, 'd', 0 }, 0, CMD_DELETE, "delete", N_("Delete song from playlist") }, { { 'Z', 0, 0 }, 0, CMD_SHUFFLE, "shuffle", diff --git a/src/command.h b/src/command.h index 745b528..1d5b950 100644 --- a/src/command.h +++ b/src/command.h @@ -9,6 +9,7 @@ typedef enum CMD_NONE = 0, CMD_PLAY, CMD_SELECT, + CMD_SELECT_ALL, CMD_PAUSE, CMD_STOP, CMD_TRACK_NEXT, diff --git a/src/screen_browse.h b/src/screen_browse.h index ddb3f21..3487b2d 100644 --- a/src/screen_browse.h +++ b/src/screen_browse.h @@ -12,6 +12,10 @@ int browse_handle_select(screen_t *screen, mpdclient_t *c, list_window_t *lw, mpdclient_filelist_t *filelist); +int browse_handle_select_all (screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist); int browse_handle_enter(screen_t *screen, mpdclient_t *c, list_window_t *lw, diff --git a/src/screen_file.c b/src/screen_file.c index 14a1147..142c91e 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -523,6 +523,89 @@ browse_handle_select(screen_t *screen, return 0; } +int +browse_handle_select_all (screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist) +{ + filelist_entry_t *entry; + GList *temp = filelist->list; + + if ( filelist==NULL ) + return -1; + for (filelist->list = g_list_first(filelist->list); + filelist->list; + filelist->list = g_list_next(filelist->list)) + { + entry=( filelist_entry_t *) filelist->list->data; + if( entry==NULL || entry->entity==NULL) + return -1; + + if( entry->entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE ) + load_playlist(screen, c, entry); + + if( entry->entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY ) + { + mpd_Directory *dir = entry->entity->info.directory; +#ifdef USE_OLD_ADD + add_directory(c, tmp); +#else + if( mpdclient_cmd_add_path_utf8(c, dir->path) == 0 ) + { + char *tmp = utf8_to_locale(dir->path); + + screen_status_printf(_("Adding \'%s\' to playlist\n"), tmp); + g_free(tmp); + } +#endif + } + + if( entry->entity->type!=MPD_INFO_ENTITY_TYPE_SONG ) + continue; + + if( entry->flags & HIGHLIGHT ) + entry->flags &= ~HIGHLIGHT; + else + entry->flags |= HIGHLIGHT; + + if( entry->flags & HIGHLIGHT ) + { + if( entry->entity->type==MPD_INFO_ENTITY_TYPE_SONG ) + { + mpd_Song *song = entry->entity->info.song; + + if( mpdclient_cmd_add(c, song) == 0 ) + { + char buf[BUFSIZE]; + + strfsong(buf, BUFSIZE, LIST_FORMAT, song); + screen_status_printf(_("Adding \'%s\' to playlist\n"), buf); + } + } + } + /*else + { + //remove song from playlist + if( entry->entity->type==MPD_INFO_ENTITY_TYPE_SONG ) + { + mpd_Song *song = entry->entity->info.song; + + if( song ) + { + int index = playlist_get_index_from_file(c, song->file); + + while( (index=playlist_get_index_from_file(c, song->file))>=0 ) + mpdclient_cmd_delete(c, index); + } + } + } + return 0;*/ + } + filelist->list = temp; + return 0; +} + static void browse_init(WINDOW *w, int cols, int rows) { diff --git a/src/screen_help.c b/src/screen_help.c index 8be8463..515e69b 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -125,6 +125,7 @@ static help_text_row_t help_text[] = { 0, CMD_SCREEN_SEARCH, N_("Search") }, { 0, CMD_PLAY, N_("Select and play") }, { 0, CMD_SELECT, NULL }, + { 0, CMD_SELECT_ALL, NULL }, { 0, CMD_SEARCH_MODE, NULL }, #endif #ifdef ENABLE_LYRICS_SCREEN diff --git a/src/screen_search.c b/src/screen_search.c index 4dfc6d0..76398e4 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -491,6 +491,11 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) /* call list_window_cmd to go to the next item */ return list_window_cmd(lw, filelist->length, cmd); + case CMD_SELECT_ALL: + browse_handle_select_all (screen, c, lw, filelist); + paint (screen, c); + return 0; + case CMD_SEARCH_MODE: options.search_mode++; if( mode[options.search_mode].label == NULL ) -- 2.30.2