Code

screen_browser: added hotkey for adding song
authorMax Kellermann <max@duempel.org>
Thu, 25 Sep 2008 19:35:06 +0000 (21:35 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 25 Sep 2008 19:35:06 +0000 (21:35 +0200)
CMD_ADD ('a') appends a song to the playlist, no matter if it is
already there, i.e. unlike CMD_SELECT, it does not toggle the song.

src/screen_artist.c
src/screen_browser.c
src/screen_browser.h
src/screen_file.c
src/screen_help.c
src/screen_search.c

index 71b168841dc73d8c18f82e5f86244ed4e025507b..07a3f8f649f95788131293d2bd03cc48fdbd92bf 100644 (file)
@@ -290,6 +290,7 @@ static int
 artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
 {
        char *selected;
+       int ret;
 
        if (browser.filelist == NULL && metalist != NULL &&
            list_window_cmd(browser.lw, metalist_length, cmd)) {
@@ -396,6 +397,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                break;
 
        case CMD_SELECT:
+       case CMD_ADD:
                switch(mode) {
                case LIST_ARTISTS:
                        selected = g_list_nth_data(metalist,
@@ -423,7 +425,10 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                        break;
 
                case LIST_SONGS:
-                       if (browser_handle_select(&browser, c) == 0)
+                       ret = cmd == CMD_SELECT
+                               ? browser_handle_select(&browser, c)
+                               : browser_handle_add(&browser, c);
+                       if (ret == 0)
                                /* continue and select next item... */
                                cmd = CMD_LIST_NEXT;
                        break;
index 9ce6fedd8f68626858caac90fca6ad63fca49ff0..bad13ea0294bb3a7bb48030f629904a0bd9da335 100644 (file)
@@ -391,6 +391,17 @@ browser_handle_select(struct screen_browser *browser, mpdclient_t *c)
        return browser_select_entry(c, entry, TRUE);
 }
 
+int
+browser_handle_add(struct screen_browser *browser, mpdclient_t *c)
+{
+       struct filelist_entry *entry = browser_get_selected(browser);
+
+       if (entry == NULL || entry->entity == NULL)
+               return -1;
+
+       return browser_select_entry(c, entry, FALSE);
+}
+
 void
 browser_handle_select_all(struct screen_browser *browser, mpdclient_t *c)
 {
index 1b7c70608618030f2f76359fdfb26b7582e59ff5..5441f41c758ae3d1385ed23c3f1d424f2e4c8b89 100644 (file)
@@ -48,6 +48,9 @@ const char *browser_lw_callback(unsigned index, int *highlight, void *filelist);
 int
 browser_handle_select(struct screen_browser *browser, mpdclient_t *c);
 
+int
+browser_handle_add(struct screen_browser *browser, mpdclient_t *c);
+
 void
 browser_handle_select_all(struct screen_browser *browser, mpdclient_t *c);
 
index 24cd8afc747f40f3b78755ccb1eec91afb3306f0..a0a7c7ccea575fd8bb91f4cdaa0af501e63ebf35 100644 (file)
@@ -223,6 +223,13 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                        cmd = CMD_LIST_NEXT;
                }
                break;
+
+       case CMD_ADD:
+               if (browser_handle_add(&browser, c) == 0)
+                       /* continue and select next item... */
+                       cmd = CMD_LIST_NEXT;
+               break;
+
        case CMD_DELETE:
                handle_delete(screen, c);
                file_repaint();
index 3ac4b0543ecdbe79536d9acf3785272fb9de552b..2637af9631f4f88bf7b91ed0057c38dc18d98049 100644 (file)
@@ -107,6 +107,7 @@ static help_text_row_t help_text[] =
   { 2, CMD_NONE,           NULL },
   { 0, CMD_PLAY,           N_("Enter directory/Select and play song") },
   { 0, CMD_SELECT,         NULL },
+  { 0, CMD_ADD, N_("Append song to playlist") },
   { 0, CMD_SAVE_PLAYLIST,  NULL },
   { 0, CMD_DELETE,         N_("Delete playlist") },
   { 0, CMD_GO_PARENT_DIRECTORY, NULL },
@@ -121,6 +122,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_ADD, N_("Append song to playlist") },
   { 0, CMD_SELECT_ALL,    NULL },
   { 0, CMD_SEARCH_MODE,    NULL },
 #endif
index b93aef01a12f067e0f8502fc21301855632aeb0e..981c0a58bc4a1e332f09ff4d4314b2d2740277dc 100644 (file)
@@ -445,6 +445,14 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
                /* call list_window_cmd to go to the next item */
                break;
 
+       case CMD_ADD:
+               if (browser_handle_add(&browser, c) == 0)
+                       /* continue and select next item... */
+                       cmd = CMD_LIST_NEXT;
+
+               /* call list_window_cmd to go to the next item */
+               break;
+
        case CMD_SELECT_ALL:
                browser_handle_select_all(&browser, c);
                search_repaint();