summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bedf936)
raw | patch | inline | side by side (parent: bedf936)
author | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 13:20:18 +0000 (15:20 +0200) |
Merge a lot of code from the 3 browser screen into browser_cmd().
diff --git a/src/screen_artist.c b/src/screen_artist.c
index c9c6f9b019a1acc4e569f8aebe8cc07d361f2796..972de8f455b0af121a17eabc1bdbf737ab91b458 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
}
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:
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);
artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
char *selected;
- int ret;
switch(cmd) {
case CMD_PLAY:
list_window_push_state(browser.lw_state, browser.lw);
artist_repaint();
- break;
+ return true;
case LIST_ALBUMS:
if (browser.lw->selected == 0) {
}
artist_repaint();
- break;
+ return true;
case LIST_SONGS:
if (browser.lw->selected == 0) {
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 */
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;
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 bad13ea0294bb3a7bb48030f629904a0bd9da335..d7dea635e320a3ad903e96a48c15de1e2d30f2fe 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.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 5441f41c758ae3d1385ed23c3f1d424f2e4c8b89..eb1133610b4a8b794d8f08e948c5d065cf07ef4e 100644 (file)
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
#include "mpdclient.h"
#include "config.h"
+#include <stdbool.h>
+
struct list_window;
struct list_window_state;
#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 3870cbdc7e9165cc89070deb9084a4fd11818bcf..d12f77ef52b1ca5e57b5d66e463105a2048c4d76 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
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();
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);
} 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 981c0a58bc4a1e332f09ff4d4314b2d2740277dc..b7020c04397ecae1dde586ff35bfbff3bfce9b4f 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
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)
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;
}