Code

included patch from Jonathan Fors
authorKalle Wallin <kaw@linux.se>
Mon, 16 Jan 2006 10:01:35 +0000 (10:01 +0000)
committerKalle Wallin <kaw@linux.se>
Mon, 16 Jan 2006 10:01:35 +0000 (10:01 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3832 09075e82-0dd4-0310-85a5-a0d7c8717e4f

AUTHORS
TODO
configure.ac
doc/ncmpc.1
src/conf.c
src/options.c
src/options.h
src/screen.c
src/screen_file.c

diff --git a/AUTHORS b/AUTHORS
index 06557c0df44e808fc3bf68e6cb239cac0dafa441..f788d322cea60e9f37f25c73eceff856e68c260b 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1,2 @@
 Kalle Wallin <kaw@linux.se>
+Jonathan Fors <etnoy@broach.se>
diff --git a/TODO b/TODO
index 5f705c5e95c12897b0fdb9e797b62f78006963f8..cdcdd2f9bf3f13cb675a3d7fc62289c3042e4a9c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -13,3 +13,5 @@
 
  * LIRC support (without irpty) ?
 
+ * In-program option editor
+
index 72043d467b9b0c904eed3f503ff5646b195c81ba..836fecd4c4521cea593785a68aabfbf1696f88d3 100644 (file)
@@ -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
index 796ca4a2ba9bef3aebc47c6fd1c6f732d9ce19f8..f87caa4a4294712159f89624689f7103727247bd 100644 (file)
@@ -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 
index 4b5e49230e1b8820527d33fd05776c925c528edf..f2c21ea05fb3aaf49dbefffbd5d112046c177e57 100644 (file)
@@ -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) )
                {
index dd31203b63bb1210ee77436a4e3d66545f3a45e4..0f281bc163c934ee176c7894adb8f3adc75b3053 100644 (file)
@@ -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;
 }
 
index 10aba1441b43313c096be706a866066c2e23c463..df6ac6146fad48cee8ef08e1ae8bbb2080242af2 100644 (file)
@@ -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;
index b947190011aac6beaf6c1dd71f0390dca3ef5214..72bdaff36247abf03e1d211db075b38d2fbace58 100644 (file)
@@ -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 );
        }
index b2ca1b6cd9c6c5acd0bf72f9935f116ce9e55a82..f868e2167b36ec74b4cf471406a11f20d7944b1d 100644 (file)
@@ -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;