aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c3
-rw-r--r--src/command.h1
-rw-r--r--src/screen.h2
-rw-r--r--src/screen_browser.c9
-rw-r--r--src/screen_file.c47
-rw-r--r--src/screen_help.c1
-rw-r--r--src/screen_lyrics.c9
-rw-r--r--src/screen_play.c8
8 files changed, 80 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 92ee27ea0..0168b057b 100644
--- a/src/command.c
+++ b/src/command.c
@@ -142,6 +142,9 @@ static command_definition_t cmds[] = {
{ { '"', 0, 0 }, 0, CMD_GO_PARENT_DIRECTORY, "go-parent-directory",
N_("Go to parent directory") },
+ { { 'l', 0, 0 }, 0, CMD_LOCATE, "locate",
+ N_("Locate song in browser") },
+
/* lists */
{ { 11, 0, 0 }, 0, CMD_LIST_MOVE_UP, "move-up",
N_("Move item up") },
diff --git a/src/command.h b/src/command.h
index 8cfe9d03b..6bfcb027e 100644
--- a/src/command.h
+++ b/src/command.h
@@ -62,6 +62,7 @@ typedef enum {
CMD_INTERRUPT,
CMD_GO_ROOT_DIRECTORY,
CMD_GO_PARENT_DIRECTORY,
+ CMD_LOCATE,
CMD_QUIT
} command_t;
diff --git a/src/screen.h b/src/screen.h
index 404d0a8d5..5eb6cba20 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -95,6 +95,8 @@ screen_is_visible(const struct screen_functions *sf);
int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
+bool
+screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
#ifdef ENABLE_LYRICS_SCREEN
void
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 6a5bbd233..63e8c1c71 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -531,6 +531,15 @@ browser_cmd(struct screen_browser *browser,
return true;
#endif
+ case CMD_LOCATE:
+ entry = browser_get_selected(browser);
+ if (entry == NULL || entry->entity == NULL ||
+ entry->entity->type != MPD_INFO_ENTITY_TYPE_SONG)
+ return false;
+
+ screen_file_goto_song(c, entry->entity->info.song);
+ return true;
+
#ifdef ENABLE_LYRICS_SCREEN
case CMD_SCREEN_LYRICS:
entry = browser_get_selected(browser);
diff --git a/src/screen_file.c b/src/screen_file.c
index aabac7afa..a934ef276 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -219,6 +219,12 @@ browse_cmd(mpdclient_t *c, command_t cmd)
file_repaint();
return 1;
+ case CMD_LOCATE:
+ /* don't let browser_cmd() evaluate the locate command
+ - it's a no-op, and by the way, leads to a
+ segmentation fault in the current implementation */
+ return false;
+
case CMD_DELETE:
handle_delete(c);
file_repaint();
@@ -283,3 +289,44 @@ const struct screen_functions screen_browse = {
.cmd = browse_cmd,
.get_title = browse_title,
};
+
+bool
+screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song)
+{
+ const char *slash, *parent;
+ char *allocated = NULL;
+ bool ret;
+ int i;
+
+ assert(song != NULL);
+ assert(song->file != NULL);
+
+ if (strstr(song->file, "//") != NULL)
+ /* an URL? */
+ return false;
+
+ /* determine the song's parent directory and go there */
+
+ slash = strrchr(song->file, '/');
+ if (slash != NULL)
+ parent = allocated = g_strndup(song->file, slash - song->file);
+ else
+ parent = "";
+
+ ret = browser_change_directory(&browser, c, NULL, parent);
+ g_free(allocated);
+ if (!ret)
+ return false;
+
+ /* select the specified song */
+
+ i = filelist_find_song(browser.filelist, song);
+ if (i < 0)
+ i = 0;
+
+ list_window_set_selected(browser.lw, i);
+
+ /* finally, switch to the file screen */
+ screen_switch(&screen_browse, c);
+ return true;
+}
diff --git a/src/screen_help.c b/src/screen_help.c
index 1f0043c09..e462ddc90 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -81,6 +81,7 @@ static help_text_row_t help_text[] = {
{ 0, CMD_LIST_FIND_NEXT, NULL },
{ 0, CMD_LIST_RFIND_NEXT, NULL },
{ 0, CMD_TOGGLE_FIND_WRAP, NULL },
+ { 0, CMD_LOCATE, NULL },
{ 0, CMD_NONE, NULL },
{ 0, CMD_QUIT, NULL },
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index ab9dfdeda..30a89a163 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -329,6 +329,15 @@ lyrics_cmd(mpdclient_t *c, command_t cmd)
lyrics_repaint();
}
return 1;
+
+ case CMD_LOCATE:
+ if (current.song != NULL) {
+ screen_file_goto_song(c, current.song);
+ return true;
+ }
+
+ return false;
+
default:
break;
}
diff --git a/src/screen_play.c b/src/screen_play.c
index 4c21a1769..1e0dcaa28 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -554,6 +554,14 @@ play_cmd(mpdclient_t *c, command_t cmd)
return handle_mouse_event(c);
#endif
+ case CMD_LOCATE:
+ if (lw->selected < playlist_length(&c->playlist)) {
+ screen_file_goto_song(c, playlist_get(&c->playlist, lw->selected));
+ return true;
+ }
+
+ break;
+
#ifdef ENABLE_LYRICS_SCREEN
case CMD_SCREEN_LYRICS:
if (lw->selected < playlist_length(&c->playlist)) {