Code

screen swap works with song/lyrics screens
authorJeffrey Middleton <jefromi@gmail.com>
Mon, 23 Mar 2009 15:48:05 +0000 (10:48 -0500)
committerJeffrey Middleton <jefromi@gmail.com>
Mon, 23 Mar 2009 15:48:51 +0000 (10:48 -0500)
The screen swap command now gets handled outside of screen.c when
appropriate, to allow passing the currently selected song to the
song/lyrics screens.

src/screen.c
src/screen.h
src/screen_browser.c
src/screen_lyrics.c
src/screen_play.c
src/screen_song.c

index 57b22cf8a784b4c1a0253690c7c6e6a67647a971..622582582a60edb1872fb8b33b1b252048ace8fb 100644 (file)
@@ -91,6 +91,22 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c)
        screen_paint(c);
 }
 
+void 
+screen_swap(struct mpdclient *c, const struct mpd_song *song)
+{
+       if (song != NULL)
+       {
+               if (mode_fn_prev == &screen_song)
+                       screen_song_switch(c, song);
+               else if (mode_fn_prev == &screen_lyrics)
+                       screen_lyrics_switch(c, song);
+               else
+                       screen_switch(mode_fn_prev, c);
+       }
+       else
+               screen_switch(mode_fn_prev, c);
+}
+
 static int
 find_configured_screen(const char *name)
 {
@@ -863,7 +879,7 @@ screen_cmd(mpdclient_t *c, command_t cmd)
                screen_switch(&screen_outputs, c);
                break;
        case CMD_SCREEN_SWAP:
-               screen_switch(mode_fn_prev, c);
+               screen_swap(c, NULL);
                break;
 #endif
 
index d414548d227e313c64c81766540bf912257fb14c..601548c0158ecf7edfd0d278b54aceccbb5a664e 100644 (file)
@@ -115,6 +115,8 @@ gint screen_get_id(const char *name);
 
 void
 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
+void 
+screen_swap(struct mpdclient *c, const struct mpd_song *song);
 
 gboolean
 screen_is_visible(const struct screen_functions *sf);
index b118a7ec3c7e457a2350e60583beaacaff04ea58..b616c58ed3925a40d03bf021fbe0c7bfe6eba6bc 100644 (file)
@@ -511,6 +511,14 @@ browser_cmd(struct screen_browser *browser,
                screen_lyrics_switch(c, entry->entity->info.song);
                return true;
 #endif
+       case CMD_SCREEN_SWAP:
+               entry = browser_get_selected(browser);
+               if (entry->entity != NULL &&
+                       entry->entity->type == MPD_INFO_ENTITY_TYPE_SONG)
+                       screen_swap(c, entry->entity->info.song);
+               else
+                       screen_swap(c, NULL);
+               return true;
 
        default:
                break;
index 1cb392fb86e4419f5e9de31f24a9f4e6b784e4ff..221b7cdb4ce87f69425158f2ffd3ef51d5e7f0cb 100644 (file)
@@ -256,6 +256,9 @@ lyrics_cmd(mpdclient_t *c, command_t cmd)
 
                break;
 #endif
+       case CMD_SCREEN_SWAP:
+               screen_swap(c, current.song);
+               return true;
 
        case CMD_LOCATE:
                if (current.song != NULL) {
index 4201fb81a2e7b26b6ecf53f187b5e14ee4a37ee1..d80c3510e9c4c29168ed95a0536b8cfea3fcf2df 100644 (file)
@@ -728,6 +728,9 @@ play_cmd(mpdclient_t *c, command_t cmd)
 
                break;
 #endif
+       case CMD_SCREEN_SWAP:
+               screen_swap(c, playlist_get(&c->playlist, lw->selected));
+               return true;
 
        default:
                break;
index cc4d53801fce2c202aee86ea27954386815039ee..74d2652728ccfd1d142be267bf48a5358c390adf 100644 (file)
@@ -362,10 +362,18 @@ screen_song_cmd(mpdclient_t *c, command_t cmd)
                        screen_lyrics_switch(c, current.played_song);
                        return true;
                }
-
                return false;
+
 #endif
 
+       case CMD_SCREEN_SWAP:
+               if (current.selected_song != NULL)
+                       screen_swap(c, current.selected_song);
+               else
+               // No need to check if this is null - we'd pass null anyway
+                       screen_swap(c, current.played_song);
+               return true;
+
        default:
                break;
        }