summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a220d74)
raw | patch | inline | side by side (parent: a220d74)
author | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 13:20:19 +0000 (15:20 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 13:20:19 +0000 (15:20 +0200) |
screen_lyrics_switch() opens the lyrics screen and displays the lyrics
of the specified song. This way, the user may view the lyrics of any
song in the database browser.
of the specified song. This way, the user may view the lyrics of any
song in the database browser.
src/screen.h | patch | blob | history | |
src/screen_browser.c | patch | blob | history | |
src/screen_lyrics.c | patch | blob | history | |
src/screen_play.c | patch | blob | history |
diff --git a/src/screen.h b/src/screen.h
index e6f0ee7a1f1f2255fe5f75c9ef03537834490c04..6d264570201c37bab473967fb4af5dbbd465559b 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
+
+#ifdef ENABLE_LYRICS_SCREEN
+void
+screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song);
+#endif
+
#endif
diff --git a/src/screen_browser.c b/src/screen_browser.c
index d7dea635e320a3ad903e96a48c15de1e2d30f2fe..694987fae926d88914245862018aee327a25f654 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
browser_cmd(struct screen_browser *browser, struct screen *screen,
struct mpdclient *c, command_t cmd)
{
+ struct filelist_entry *entry;
+
switch (cmd) {
case CMD_PLAY:
browser_handle_enter(browser, c);
browser_handle_mouse_event(browser, c);
return true;
+#ifdef ENABLE_LYRICS_SCREEN
+ case CMD_SCREEN_LYRICS:
+ entry = browser_get_selected(browser);
+ if (entry == NULL)
+ return false;
+
+ if (entry->entity == NULL ||
+ entry->entity->type != MPD_INFO_ENTITY_TYPE_SONG)
+ return true;
+
+ screen_lyrics_switch(c, entry->entity->info.song);
+ return true;
+#endif
+
default:
break;
}
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index dbfe4ea6feaedbb671758f583024f443a0603e43..83bffdf8d8a2d0f048386a306154e210c10aa724 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static list_window_t *lw = NULL;
+static const struct mpd_song *next_song;
+
static struct {
const struct mpd_song *song;
static void
lyrics_open(mpd_unused screen_t *screen, mpdclient_t *c)
{
- if (c->song != NULL && c->song != current.song)
- screen_lyrics_load(c->song);
+ if (next_song == NULL)
+ next_song = c->song;
+
+ if (next_song != NULL && next_song != current.song)
+ screen_lyrics_load(next_song);
+
+ next_song = NULL;
}
.cmd = lyrics_cmd,
.get_title = lyrics_title,
};
+
+void
+screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song)
+{
+ assert(song != NULL);
+
+ next_song = song;
+ screen_switch(&screen_lyrics, c);
+}
diff --git a/src/screen_play.c b/src/screen_play.c
index 1bc2034b82d7d26557b8fb6a3fe29576f6deb0ae..67de5fa3e62d3d6ce73ec045b6613668a7351e3e 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
case CMD_MOUSE_EVENT:
return handle_mouse_event(screen,c);
+
+#ifdef ENABLE_LYRICS_SCREEN
+ case CMD_SCREEN_LYRICS:
+ if (lw->selected < playlist_length(&c->playlist)) {
+ screen_lyrics_switch(c, playlist_get(&c->playlist, lw->selected));
+ return 1;
+ }
+
+ break;
+#endif
+
default:
break;
}