aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_file.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-18 21:51:57 +0100
committerMax Kellermann <max@duempel.org>2008-11-18 21:51:57 +0100
commit299a27c8dee0e7eeab3448ed7cdfe1ac7c97ebaf (patch)
tree45768e3972318fb475c65a5866c5bbedd09da8a3 /src/screen_file.c
parentebb9e5b1924e6bc5baaae9ced82b54be586f6b74 (diff)
downloadmpd-299a27c8dee0e7eeab3448ed7cdfe1ac7c97ebaf.tar.gz
mpd-299a27c8dee0e7eeab3448ed7cdfe1ac7c97ebaf.tar.xz
mpd-299a27c8dee0e7eeab3448ed7cdfe1ac7c97ebaf.zip
command: added CMD_LOCATE to locate song in database
Pressing 'l' switches to the file browser (screen_file) and locates the previously selected song in the server's database.
Diffstat (limited to '')
-rw-r--r--src/screen_file.c47
1 files changed, 47 insertions, 0 deletions
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;
+}