aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/screen_artist.c45
-rw-r--r--src/screen_browser.c53
-rw-r--r--src/screen_browser.h6
-rw-r--r--src/screen_file.c35
-rw-r--r--src/screen_search.c48
5 files changed, 76 insertions, 111 deletions
diff --git a/src/screen_artist.c b/src/screen_artist.c
index c9c6f9b01..972de8f45 100644
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
@@ -427,7 +427,7 @@ metalist_length(void)
}
static int
-artist_lw_cmd(command_t cmd)
+artist_lw_cmd(struct screen *screen, struct mpdclient *c, command_t cmd)
{
switch (mode) {
case LIST_ARTISTS:
@@ -435,9 +435,7 @@ artist_lw_cmd(command_t cmd)
return list_window_cmd(browser.lw, metalist_length(), cmd);
case LIST_SONGS:
- return list_window_cmd(browser.lw,
- filelist_length(browser.filelist),
- cmd);
+ return browser_cmd(&browser, screen, c, cmd);
}
assert(0);
@@ -448,7 +446,6 @@ static int
artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
char *selected;
- int ret;
switch(cmd) {
case CMD_PLAY:
@@ -460,7 +457,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
list_window_push_state(browser.lw_state, browser.lw);
artist_repaint();
- break;
+ return true;
case LIST_ALBUMS:
if (browser.lw->selected == 0) {
@@ -483,7 +480,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
}
artist_repaint();
- break;
+ return true;
case LIST_SONGS:
if (browser.lw->selected == 0) {
@@ -496,12 +493,11 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
browser.lw);
artist_repaint();
- } else
- browser_handle_enter(&browser, c);
+ return true;
+ }
break;
}
- return 1;
-
+ break;
/* FIXME? CMD_GO_* handling duplicates code from CMD_PLAY */
@@ -567,12 +563,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
break;
case LIST_SONGS:
- 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;
+ /* handled by browser_cmd() */
break;
}
break;
@@ -592,34 +583,28 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
screen_find(screen,
browser.lw, artist_list->len,
cmd, artist_lw_callback, artist_list);
- break;
+ artist_repaint();
+ return 1;
case LIST_ALBUMS:
screen_find(screen,
browser.lw, album_list->len + 2,
cmd, artist_lw_callback, album_list);
- break;
+ artist_repaint();
+ return 1;
case LIST_SONGS:
- screen_find(screen,
- browser.lw,
- filelist_length(browser.filelist),
- cmd, browser_lw_callback,
- browser.filelist);
+ /* handled by browser_cmd() */
break;
}
- artist_repaint();
- return 1;
-
- case CMD_MOUSE_EVENT:
- return browser_handle_mouse_event(&browser, c);
+ break;
default:
break;
}
- if (artist_lw_cmd(cmd)) {
+ if (artist_lw_cmd(screen, c, cmd)) {
artist_repaint();
return 1;
}
diff --git a/src/screen_browser.c b/src/screen_browser.c
index bad13ea02..d7dea635e 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -451,3 +451,56 @@ browser_handle_mouse_event(struct screen_browser *browser, mpdclient_t *c)
}
#endif
+bool
+browser_cmd(struct screen_browser *browser, struct screen *screen,
+ struct mpdclient *c, command_t cmd)
+{
+ switch (cmd) {
+ case CMD_PLAY:
+ browser_handle_enter(browser, c);
+ return true;
+
+ case CMD_SELECT:
+ if (browser_handle_select(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_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);
+ return true;
+
+ case CMD_LIST_FIND:
+ case CMD_LIST_RFIND:
+ case CMD_LIST_FIND_NEXT:
+ case CMD_LIST_RFIND_NEXT:
+ screen_find(screen,
+ browser->lw, filelist_length(browser->filelist),
+ cmd, browser_lw_callback,
+ browser->filelist);
+ return true;
+
+ case CMD_MOUSE_EVENT:
+ browser_handle_mouse_event(browser, c);
+ return true;
+
+ default:
+ break;
+ }
+
+ if (list_window_cmd(browser->lw, filelist_length(browser->filelist),
+ cmd))
+ return true;
+
+ return false;
+}
diff --git a/src/screen_browser.h b/src/screen_browser.h
index 5441f41c7..eb1133610 100644
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
@@ -26,6 +26,8 @@
#include "mpdclient.h"
#include "config.h"
+#include <stdbool.h>
+
struct list_window;
struct list_window_state;
@@ -67,4 +69,8 @@ int browser_handle_mouse_event(struct screen_browser *browser, mpdclient_t *c);
#define browser_handle_mouse_event(browser, c) (0)
#endif
+bool
+browser_cmd(struct screen_browser *browser, struct screen *screen,
+ struct mpdclient *c, command_t cmd);
+
#endif
diff --git a/src/screen_file.c b/src/screen_file.c
index 3870cbdc7..d12f77ef5 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -205,10 +205,6 @@ static int
browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
switch(cmd) {
- case CMD_PLAY:
- browser_handle_enter(&browser, c);
- file_repaint();
- return 1;
case CMD_GO_ROOT_DIRECTORY:
browser_change_directory(&browser, c, NULL, "");
file_repaint();
@@ -217,18 +213,6 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
browser_change_directory(&browser, c, NULL, "..");
file_repaint();
return 1;
- case CMD_SELECT:
- if (browser_handle_select(&browser, c) == 0) {
- /* continue and select next item... */
- 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);
@@ -266,29 +250,12 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
} else
screen_status_printf(_("Database update running..."));
return 1;
- case CMD_LIST_FIND:
- case CMD_LIST_RFIND:
- case CMD_LIST_FIND_NEXT:
- case CMD_LIST_RFIND_NEXT:
- screen_find(screen,
- browser.lw, filelist_length(browser.filelist),
- cmd, browser_lw_callback,
- browser.filelist);
- file_repaint();
- return 1;
-
- case CMD_MOUSE_EVENT:
- if (browser_handle_mouse_event(&browser, c))
- file_repaint();
-
- return 1;
default:
break;
}
- if (list_window_cmd(browser.lw, filelist_length(browser.filelist),
- cmd)) {
+ if (browser_cmd(&browser, screen, c, cmd)) {
file_repaint();
return 1;
}
diff --git a/src/screen_search.c b/src/screen_search.c
index 981c0a58b..b7020c043 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -432,32 +432,6 @@ static int
search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
switch (cmd) {
- case CMD_PLAY:
- browser_handle_enter(&browser, c);
- search_repaint();
- return 1;
-
- case CMD_SELECT:
- if (browser_handle_select(&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_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();
- return 0;
-
case CMD_SEARCH_MODE:
options.search_mode++;
if (mode[options.search_mode].label == NULL)
@@ -488,32 +462,12 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
search_repaint();
return 1;
- case CMD_LIST_FIND:
- case CMD_LIST_RFIND:
- case CMD_LIST_FIND_NEXT:
- case CMD_LIST_RFIND_NEXT:
- if (browser.filelist) {
- screen_find(screen,
- browser.lw, filelist_length(browser.filelist),
- cmd, browser_lw_callback,
- browser.filelist);
- search_repaint();
- }
-
- return 1;
-
- case CMD_MOUSE_EVENT:
- browser_handle_mouse_event(&browser, c);
- search_repaint();
- return 1;
-
default:
break;
}
if (browser.filelist != NULL &&
- list_window_cmd(browser.lw,
- filelist_length(browser.filelist), cmd)) {
+ browser_cmd(&browser, screen, c, cmd)) {
search_repaint();
return 1;
}