aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2005-06-15 13:04:22 +0000
committerKalle Wallin <kaw@linux.se>2005-06-15 13:04:22 +0000
commitc94d06df7370bfe88f6a42f22142f05927c5c44b (patch)
treea1be838de371da566b4acb6b52e68b08fcb0dcef /src/screen.c
parent7c9aa09019ac6ab2cdf847d785c2dc127a46ac94 (diff)
downloadmpd-c94d06df7370bfe88f6a42f22142f05927c5c44b.tar.gz
mpd-c94d06df7370bfe88f6a42f22142f05927c5c44b.tar.xz
mpd-c94d06df7370bfe88f6a42f22142f05927c5c44b.zip
New configuraton option: screen-list
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/screen.c b/src/screen.c
index b5a1d473a..b94719001 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -74,10 +74,10 @@ typedef struct
static screen_mode_info_t screens[] = {
{ SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist },
{ SCREEN_BROWSE_ID, "browse", get_screen_browse },
- { SCREEN_HELP_ID, "help", get_screen_help },
#ifdef ENABLE_ARTIST_SCREEN
{ SCREEN_ARTIST_ID, "artist", get_screen_artist },
#endif
+ { SCREEN_HELP_ID, "help", get_screen_help },
#ifdef ENABLE_SEARCH_SCREEN
{ SCREEN_SEARCH_ID, "search", get_screen_search },
#endif
@@ -96,6 +96,20 @@ static screen_functions_t *mode_fn = NULL;
static int seek_id = -1;
static int seek_target_time = 0;
+gint
+screen_get_id(char *name)
+{
+ gint i=0;
+
+ while( screens[i].name )
+ {
+ if( strcmp(name, screens[i].name) == 0 )
+ return screens[i].id;
+ i++;
+ }
+ return -1;
+}
+
static gint
lookup_mode(gint id)
{
@@ -140,6 +154,32 @@ switch_screen_mode(gint id, mpdclient_t *c)
}
static void
+screen_next_mode(mpdclient_t *c, int offset)
+{
+ int max = g_strv_length(options.screen_list);
+ int current, next;
+ int i;
+
+ /* find current screen */
+ current = -1;
+ i = 0;
+ while( options.screen_list[i] )
+ {
+ if( strcmp(options.screen_list[i], screens[screen->mode].name) == 0 )
+ current = i;
+ i++;
+ }
+ next = current + offset;
+ if( next<0 )
+ next = max-1;
+ else if( next>=max )
+ next = 0;
+
+ D("current mode: %d:%d next:%d\n", current, max, next);
+ switch_screen_mode(screen_get_id(options.screen_list[next]), c);
+}
+
+static void
paint_top_window(char *header, mpdclient_t *c, int clear)
{
char flags[5];
@@ -590,7 +630,14 @@ screen_init(mpdclient_t *c)
i++;
}
+#if 0
+ /* broken */
+ mode_fn = NULL;
+ switch_screen_mode(screen_get_id(options.screen_list[0]), c);
+#else
mode_fn = get_screen_playlist();
+#endif
+
if( mode_fn && mode_fn->open )
mode_fn->open(screen, c);
@@ -877,16 +924,10 @@ screen_cmd(mpdclient_t *c, command_t cmd)
screen->painted = 0;
break;
case CMD_SCREEN_PREVIOUS:
- if( screen->mode > 0 )
- switch_screen_mode(screens[screen->mode-1].id, c);
- else
- switch_screen_mode(lookup_mode(SCREEN_HELP_ID)-1, c);
+ screen_next_mode(c, -1);
break;
case CMD_SCREEN_NEXT:
- if( screens[screen->mode+1].id < SCREEN_HELP_ID )
- switch_screen_mode(screens[screen->mode+1].id, c);
- else
- switch_screen_mode(screens[0].id, c);
+ screen_next_mode(c, 1);
break;
case CMD_SCREEN_PLAY:
switch_screen_mode(SCREEN_PLAYLIST_ID, c);