diff --git a/src/screen.c b/src/screen.c
index 0c56a7420433f5567473624e40909f2ce5efbb98..72bdaff36247abf03e1d211db075b38d2fbace58 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#define SCREEN_PLAYLIST_ID 0
#define SCREEN_BROWSE_ID 1
+#define SCREEN_ARTIST_ID 2
#define SCREEN_HELP_ID 100
#define SCREEN_KEYDEF_ID 101
#define SCREEN_CLOCK_ID 102
#define SCREEN_SEARCH_ID 103
+
/* screens */
extern screen_functions_t *get_screen_playlist(void);
extern screen_functions_t *get_screen_browse(void);
extern screen_functions_t *get_screen_help(void);
extern screen_functions_t *get_screen_search(void);
+extern screen_functions_t *get_screen_artist(void);
extern screen_functions_t *get_screen_keydef(void);
extern screen_functions_t *get_screen_clock(void);
static screen_mode_info_t screens[] = {
{ SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist },
{ SCREEN_BROWSE_ID, "browse", get_screen_browse },
+#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 },
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)
{
}
+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)
{
waddstr(w, get_key_names(CMD_SCREEN_FILE, FALSE));
colors_use(w, COLOR_TITLE);
waddstr(w, _(":Browse "));
+#ifdef ENABLE_ARTIST_SCREEN
+ colors_use(w, COLOR_TITLE_BOLD);
+ waddstr(w, get_key_names(CMD_SCREEN_ARTIST, FALSE));
+ colors_use(w, COLOR_TITLE);
+ waddstr(w, _(":Artist "));
+#endif
#ifdef ENABLE_SEARCH_SCREEN
colors_use(w, COLOR_TITLE_BOLD);
waddstr(w, get_key_names(CMD_SCREEN_SEARCH, FALSE));
WINDOW *w = screen->status_window.w;
mpd_Status *status = c->status;
mpd_Song *song = c->song;
- int elapsedTime = c->status->elapsedTime;
+ int elapsedTime = 0;
char *str = NULL;
+ char *timestr = NULL;
int x = 0;
if( time(NULL) - screen->status_timestamp <= SCREEN_STATUS_MESSAGE_TIME )
if( IS_PLAYING(status->state) || IS_PAUSED(status->state) )
{
if( status->totalTime > 0 )
- {
- if( c->song && seek_id == c->song->id )
+ {
+
+ /*checks the conf to see whether to display elapsed or remaining time */
+ if(!strcmp(options.timedisplay_type,"elapsed"))
+ {
+ timestr= " [%i:%02i/%i:%02i]";
+ elapsedTime = c->status->elapsedTime;
+ }
+ else if(!strcmp(options.timedisplay_type,"remaining"))
+ {
+ timestr= " [-%i:%02i/%i:%02i]";
+ elapsedTime = (c->status->totalTime - c->status->elapsedTime);
+ }
+ if( c->song && seek_id == c->song->id )
elapsedTime = seek_target_time;
+ /*write out the time*/
g_snprintf(screen->buf, screen->buf_size,
- " [%i:%02i/%i:%02i]",
+ timestr,
elapsedTime/60, elapsedTime%60,
status->totalTime/60, status->totalTime%60 );
}
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);
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);
case CMD_SCREEN_SEARCH:
switch_screen_mode(SCREEN_SEARCH_ID, c);
break;
+ case CMD_SCREEN_ARTIST:
+ switch_screen_mode(SCREEN_ARTIST_ID, c);
+ break;
case CMD_SCREEN_KEYDEF:
switch_screen_mode(SCREEN_KEYDEF_ID, c);
break;