summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ebb9e5b)
raw | patch | inline | side by side (parent: ebb9e5b)
author | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:57 +0000 (21:51 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:57 +0000 (21:51 +0100) |
Pressing 'l' switches to the file browser (screen_file) and locates
the previously selected song in the server's database.
the previously selected song in the server's database.
diff --git a/src/command.c b/src/command.c
index 92ee27ea072f22e797798d87585f8a40207a0c99..0168b057b37ceaa68efda15cdf97034acb9cbd79 100644 (file)
--- a/src/command.c
+++ b/src/command.c
{ { '"', 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 8cfe9d03b62a909c6d363ad61a386e928bfd11b3..6bfcb027ed79ff911926ad739d98bcc54cc3e33c 100644 (file)
--- a/src/command.h
+++ b/src/command.h
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 404d0a8d565ce49fed7142d4a56a35fac0d7f26f..5eb6cba207b98929db3ad8d5f5b92f7349fcbc74 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
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 6a5bbd2331f549b57edb25b3e645e0bbc24a29b2..63e8c1c71a3e872f4cc7f0eca4bd9300fba25eab 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
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 aabac7afa9cc1da019dd3124f27a4eea74e6c574..a934ef2763ffa79c271be662cf05154045d3ef5e 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
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();
.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 1f0043c094b719ba06deeb91ff95d52bf6770a0f..e462ddc907897d86dfdd109e72f121015ba0c41e 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
{ 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 ab9dfdedaefbaf9c0f3b8faa830279eb799b907c..30a89a163973ddaf8f29143bf2bd5c88fdea20f1 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
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 4c21a17697b8b657ab6299fdb7c00d9c641bcec5..1e0dcaa280759c05d74fd02246f1ac1ab592c895 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
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)) {