From 1603384f1bf298466183a2bfec343293b5b9ead9 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Mon, 16 Jan 2006 10:01:35 +0000 Subject: [PATCH] included patch from Jonathan Fors git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3832 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- AUTHORS | 1 + TODO | 2 ++ configure.ac | 9 +++++++++ doc/ncmpc.1 | 3 +++ src/conf.c | 21 ++++++++++++++++++++- src/options.c | 5 +++-- src/options.h | 1 + src/screen.c | 22 ++++++++++++++++++---- src/screen_file.c | 6 +++++- 9 files changed, 62 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 06557c0..f788d32 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,2 @@ Kalle Wallin +Jonathan Fors diff --git a/TODO b/TODO index 5f705c5..cdcdd2f 100644 --- a/TODO +++ b/TODO @@ -13,3 +13,5 @@ * LIRC support (without irpty) ? + * In-program option editor + diff --git a/configure.ac b/configure.ac index 72043d4..836fecd 100644 --- a/configure.ac +++ b/configure.ac @@ -240,6 +240,15 @@ AC_MSG_RESULT([$DEFAULT_PORT]) AC_DEFINE_UNQUOTED([DEFAULT_PORT], [$DEFAULT_PORT], [Default MPD port]) AC_DEFINE_UNQUOTED([DEFAULT_PORT_STR], ["$DEFAULT_PORT"], [Default MPD port]) +dnl Default host +AC_MSG_CHECKING([for default timedisplay type]) +AC_ARG_WITH([default-timedisplay_type], + AC_HELP_STRING([--with-default-timedisplay_type=ARG], + [default_timedisplay]), + [DEFAULT_TIMEDISPLAY_TYPE="$withval"], + [DEFAULT_TIMEDISPLAY_TYPE="elapsed"]) +AC_MSG_RESULT([$DEFAULT_TIMEDISPLAY_TYPE]) +AC_DEFINE_UNQUOTED([DEFAULT_TIMEDISPLAY_TYPE], ["$DEFAULT_TIMEDISPLAY_TYPE"], [Default way to display time, either 'elapsed' or 'remaining']) AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in]) AC_OUTPUT diff --git a/doc/ncmpc.1 b/doc/ncmpc.1 index 796ca4a..f87caa4 100644 --- a/doc/ncmpc.1 +++ b/doc/ncmpc.1 @@ -111,6 +111,9 @@ Set the background color. If the background color is assigned to the keyword \fB .B color title = TEXTCOLOR Set the text color for the title row. .TP +.B timedisplay-type = elapsed/remaining +Sets whether to display remaining or elapsed time in the status window. Default is elapsed. +.TP .B color title\-bold = TEXTCOLOR Set the text color for the title row (the bold part). .TP diff --git a/src/conf.c b/src/conf.c index 4b5e492..f2c21ea 100644 --- a/src/conf.c +++ b/src/conf.c @@ -64,6 +64,7 @@ #define CONF_HIDE_CURSOR "hide-cursor" #define CONF_SEEK_TIME "seek-time" #define CONF_SCREEN_LIST "screen-list" +#define CONF_TIMEDISPLAY_TYPE "timedisplay-type" typedef enum { KEY_PARSER_UNKNOWN, @@ -217,6 +218,17 @@ parse_key_definition(char *str) return assign_keys(cmd, keys); } +static char * +parse_timedisplay_type(char *str) +{ + if((!strcmp(str,"elapsed")) || (!strcmp(str,"remaining"))){ + return str; + } else { + fprintf(stderr,_("Error: Bad time display type - %s\n"), str); + return DEFAULT_TIMEDISPLAY_TYPE; + } +} + static int parse_color(char *str) { @@ -243,7 +255,6 @@ parse_color(char *str) return colors_assign(name, value); } - static int parse_color_definition(char *str) { @@ -460,6 +471,14 @@ read_rc_file(char *filename, options_t *options) { options->wide_cursor = str2bool(value); } + /* timer display type */ + else if( !strcasecmp(CONF_TIMEDISPLAY_TYPE, name) ) + { + g_free(options->timedisplay_type); + options->timedisplay_type=g_strdup(parse_timedisplay_type(value)); + D("deb"); + D(options->timedisplay_type); + } /* color definition */ else if( !strcasecmp(CONF_COLOR_DEFINITION, name) ) { diff --git a/src/options.c b/src/options.c index dd31203..0f281bc 100644 --- a/src/options.c +++ b/src/options.c @@ -183,7 +183,7 @@ handle_option(int c, char *arg) case 'C': /* --no-colors */ options.enable_colors = FALSE; break; - case 'm': /* --mouse */ + case 'm': /* --mouse */ options.enable_mouse = TRUE; break; case 'M': /* --no-mouse */ @@ -368,7 +368,8 @@ options_init( void ) options.crossfade_time = DEFAULT_CROSSFADE_TIME; options.seek_time = 1; options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0); - + options.timedisplay_type = DEFAULT_TIMEDISPLAY_TYPE; + return &options; } diff --git a/src/options.h b/src/options.h index 10aba14..df6ac61 100644 --- a/src/options.h +++ b/src/options.h @@ -13,6 +13,7 @@ typedef struct char *status_format; char *xterm_title_format; char **screen_list; + char *timedisplay_type; int port; int crossfade_time; int search_mode; diff --git a/src/screen.c b/src/screen.c index b947190..72bdaff 100644 --- a/src/screen.c +++ b/src/screen.c @@ -306,8 +306,9 @@ paint_status_window(mpdclient_t *c) 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 ) @@ -341,11 +342,24 @@ paint_status_window(mpdclient_t *c) 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 ); } diff --git a/src/screen_file.c b/src/screen_file.c index b2ca1b6..f868e21 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -648,8 +648,12 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) { if( mpdclient_cmd_db_update_utf8(c,filelist->path)==0 ) { - screen_status_printf(_("Database update of %s started!"), + if(strcmp(filelist->path,"")) { + screen_status_printf(_("Database update of %s started!"), filelist->path); + } else { + screen_status_printf(_("Database update started!")); + } /* set updatingDb to make shure the browse callback gets called * even if the updated has finished before status is updated */ c->status->updatingDb = 1; -- 2.30.2