From: Max Kellermann Date: Thu, 25 Sep 2008 19:35:06 +0000 (+0200) Subject: screen_browser: added hotkey for adding song X-Git-Tag: v0.12_alpha1~140 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1198af221ec2d804d9ff840a9dcd5e770fb3d13a;p=ncmpc.git screen_browser: added hotkey for adding song 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. --- diff --git a/src/screen_artist.c b/src/screen_artist.c index 71b1688..07a3f8f 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -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; diff --git a/src/screen_browser.c b/src/screen_browser.c index 9ce6fed..bad13ea 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -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) { diff --git a/src/screen_browser.h b/src/screen_browser.h index 1b7c706..5441f41 100644 --- a/src/screen_browser.h +++ b/src/screen_browser.h @@ -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); diff --git a/src/screen_file.c b/src/screen_file.c index 24cd8af..a0a7c7c 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -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(); diff --git a/src/screen_help.c b/src/screen_help.c index 3ac4b05..2637af9 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -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 diff --git a/src/screen_search.c b/src/screen_search.c index b93aef0..981c0a5 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -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();