X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen.c;h=c8ba729893695035471aad305a207d0ba5a50022;hb=38ff9027801abc7759798854cc6be7d0f99c2769;hp=5345f49ef8665bca530a20689d533742797d1a64;hpb=0b2eee9489a8acef3cdee6f6fa0df6d167c53b8d;p=ncmpc.git diff --git a/src/screen.c b/src/screen.c index 5345f49..c8ba729 100644 --- a/src/screen.c +++ b/src/screen.c @@ -25,11 +25,9 @@ #include "charset.h" #include "mpdclient.h" #include "utils.h" -#include "command.h" #include "options.h" #include "colors.h" #include "strfsong.h" -#include "wreadln.h" #include #include @@ -38,11 +36,13 @@ #include #include +#ifndef NCMPC_MINI /** welcome message time [s] */ -static const unsigned SCREEN_WELCOME_TIME = 10; +static const GTime SCREEN_WELCOME_TIME = 10; +#endif /** status message time [s] */ -static const unsigned SCREEN_STATUS_MESSAGE_TIME = 3; +static const GTime SCREEN_STATUS_MESSAGE_TIME = 3; /* minumum window size */ static const int SCREEN_MIN_COLS = 14; @@ -50,8 +50,11 @@ static const int SCREEN_MIN_ROWS = 5; /* screens */ +#ifndef NCMPC_MINI static gboolean welcome = TRUE; -static struct screen screen; +#endif + +struct screen screen; static const struct screen_functions *mode_fn = &screen_playlist; static int seek_id = -1; static int seek_target_time = 0; @@ -79,7 +82,7 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c) /* open the new mode */ if (mode_fn->open != NULL) - mode_fn->open(&screen, c); + mode_fn->open(c); screen_paint(c); } @@ -126,6 +129,7 @@ paint_top_window2(const char *header, mpdclient_t *c) if (header[0]) { colors_use(w, COLOR_TITLE_BOLD); mvwaddstr(w, 0, 0, header); +#ifndef NCMPC_MINI } else { colors_use(w, COLOR_TITLE_BOLD); waddstr(w, get_key_names(CMD_SCREEN_HELP, FALSE)); @@ -156,8 +160,10 @@ paint_top_window2(const char *header, mpdclient_t *c) waddstr(w, get_key_names(CMD_SCREEN_LYRICS, FALSE)); colors_use(w, COLOR_TITLE); waddstr(w, _(":Lyrics ")); +#endif #endif } + if (c->status == NULL || c->status->volume == MPD_STATUS_NO_VOLUME) { g_snprintf(buf, 32, _("Volume n/a ")); } else { @@ -251,7 +257,11 @@ paint_status_window(mpdclient_t *c) mpd_Status *status = c->status; mpd_Song *song = c->song; int elapsedTime = 0; +#ifdef NCMPC_MINI + static char bitrate[1]; +#else char bitrate[16]; +#endif const char *str = NULL; int x = 0; @@ -294,12 +304,14 @@ paint_status_window(mpdclient_t *c) elapsedTime = seek_target_time; /* display bitrate if visible-bitrate is true */ +#ifndef NCMPC_MINI if (options.visible_bitrate) { g_snprintf(bitrate, 16, " [%d kbps]", status->bitRate); } else { bitrate[0] = '\0'; } +#endif /*write out the time, using hours if time over 60 minutes*/ if (c->status->totalTime > 3600) { @@ -313,22 +325,28 @@ paint_status_window(mpdclient_t *c) bitrate, elapsedTime/60, elapsedTime%60, status->totalTime/60, status->totalTime%60 ); } +#ifndef NCMPC_MINI } else { g_snprintf(screen.buf, screen.buf_size, " [%d kbps]", status->bitRate ); +#endif } +#ifndef NCMPC_MINI } else { time_t timep; time(&timep); strftime(screen.buf, screen.buf_size, "%X ",localtime(&timep)); +#endif } /* display song */ if (status != NULL && (IS_PLAYING(status->state) || IS_PAUSED(status->state))) { char songname[MAX_SONGNAME_LENGTH]; +#ifndef NCMPC_MINI int width = COLS - x - utf8_width(screen.buf); +#endif if (song) strfsong(songname, MAX_SONGNAME_LENGTH, @@ -338,6 +356,7 @@ paint_status_window(mpdclient_t *c) colors_use(w, COLOR_STATUS); /* scroll if the song name is to long */ +#ifndef NCMPC_MINI if (options.scroll && utf8_width(songname) > (unsigned)width) { static scroll_state_t st = { 0, 0 }; char *tmp = strscroll(songname, options.scroll_sep, width, &st); @@ -345,6 +364,7 @@ paint_status_window(mpdclient_t *c) g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH); g_free(tmp); } +#endif //mvwaddnstr(w, 0, x, songname, width); mvwaddstr(w, 0, x, songname); } @@ -522,11 +542,7 @@ screen_init(mpdclient_t *c) screen.main_window.cols, screen.main_window.rows); if (mode_fn->open != NULL) - mode_fn->open(&screen, c); - - /* initialize wreadln */ - wrln_wgetch = my_wgetch; - wrln_max_history_length = 16; + mode_fn->open(c); } void @@ -560,6 +576,7 @@ screen_paint(mpdclient_t *c) void screen_update(mpdclient_t *c) { +#ifndef NCMPC_MINI static int repeat = -1; static int random_enabled = -1; static int crossfade = -1; @@ -603,9 +620,13 @@ screen_update(mpdclient_t *c) screen.last_cmd==CMD_NONE && time(NULL)-screen.start_timestamp <= SCREEN_WELCOME_TIME) paint_top_window("", c, 0); - else if (mode_fn->get_title != NULL) { + else +#endif + if (mode_fn->get_title != NULL) { paint_top_window(mode_fn->get_title(screen.buf,screen.buf_size), c, 0); +#ifndef NCMPC_MINI welcome = FALSE; +#endif } else paint_top_window("", c, 0); @@ -737,7 +758,7 @@ screen_client_cmd(mpdclient_t *c, command_t cmd) break; case CMD_DB_UPDATE: if (!c->status->updatingDb) { - if( mpdclient_cmd_db_update_utf8(c,NULL)==0 ) + if( mpdclient_cmd_db_update(c,NULL)==0 ) screen_status_printf(_("Database update started!")); } else screen_status_printf(_("Database update running...")); @@ -762,9 +783,11 @@ void screen_cmd(mpdclient_t *c, command_t cmd) { screen.last_cmd = cmd; +#ifndef NCMPC_MINI welcome = FALSE; +#endif - if (mode_fn->cmd != NULL && mode_fn->cmd(&screen, c, cmd)) + if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd)) return; if (screen_client_cmd(c, cmd)) @@ -798,9 +821,11 @@ screen_cmd(mpdclient_t *c, command_t cmd) case CMD_SCREEN_FILE: screen_switch(&screen_browse, c); break; +#ifdef ENABLE_HELP_SCREEN case CMD_SCREEN_HELP: screen_switch(&screen_help, c); break; +#endif #ifdef ENABLE_SEARCH_SCREEN case CMD_SCREEN_SEARCH: screen_switch(&screen_search, c);