Code

cmd_select_all added
authorAndreas Obergrusberger <tradiaz@yahoo.de>
Fri, 30 Nov 2007 16:09:30 +0000 (16:09 +0000)
committerAndreas Obergrusberger <tradiaz@yahoo.de>
Fri, 30 Nov 2007 16:09:30 +0000 (16:09 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@7061 09075e82-0dd4-0310-85a5-a0d7c8717e4f

ChangeLog
src/command.c
src/command.h
src/screen_browse.h
src/screen_file.c
src/screen_help.c
src/screen_search.c

index 4ff8da5ef3492722d36ceb4267c67c85fea03c13..67f361737540eed54a6fd2bef3c35c428ea88c01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2007-11-30 Andreas Obergrusberger <tradiaz@yahoo.de>
+       * added a function to select all listed items on the search screen
+
 2007-06-17 Andreas Obergrusberger <tradiaz@yahoo.de>
        * two critical bugs in leoslyrics source have been fixed
 2007-02-16 Andreas Obergrusberger <tradiaz@yahoo.de>
index 3210f39d9bb242e2a8a314831caac37ed802cb83..d0d141904b0c59bcc06e42f4f42573ce5bdd9732 100644 (file)
@@ -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",
index 745b5283bb4107e78f15d7f712927c8ee2d422b9..1d5b9500af5aa1e6d88e37c55bc083e1345f2241 100644 (file)
@@ -9,6 +9,7 @@ typedef enum
   CMD_NONE = 0,
   CMD_PLAY,
   CMD_SELECT,
+  CMD_SELECT_ALL,
   CMD_PAUSE,
   CMD_STOP,
   CMD_TRACK_NEXT,
index ddb3f21b06d4d901a7640f5e97090a2fcb34f808..3487b2d38422b0869a3512017e81206822cd4741 100644 (file)
@@ -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,
index 14a11478c210836d3c143cfeab4fdf56f7666d09..142c91e121efa1ba2a58fd896959ee68594535ba 100644 (file)
@@ -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)
 {
index 8be8463f3f3bf18f574874bcedcbe5514b548848..515e69bc11c6addb7d059f9c3806fbb32f921ffe 100644 (file)
@@ -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
index 4dfc6d0add1551056975eb23d60d45edabc4bb9d..76398e478c0bb7635898b458f239f1ab1841ab0e 100644 (file)
@@ -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 )