Code

way too much stuff to describe here
authorAndreas Obergrusberger <tradiaz@yahoo.de>
Fri, 16 Feb 2007 15:42:08 +0000 (15:42 +0000)
committerAndreas Obergrusberger <tradiaz@yahoo.de>
Fri, 16 Feb 2007 15:42:08 +0000 (15:42 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@5346 09075e82-0dd4-0310-85a5-a0d7c8717e4f

15 files changed:
ChangeLog
TODO
doc/config.sample
doc/ncmpc.1
src/conf.c
src/main.c
src/mpdclient.c
src/mpdclient.h
src/ncmpc.h
src/options.c
src/options.h
src/screen.c
src/screen_help.c
src/screen_search.c
src/strfsong.c

index fc0fbb762649ba6baa115b58092996172cb0eb52..715a4ca822aa2fc49f9f835efc0622365d62c36f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2007-02-01 Andreas Obergrusberger <tradiazqyahoo.de>
+2007-02-16 Andreas Obergrusberger <tradiaz@yahoo.de>
+  + nj has posted a lot of patches on the bug tracker
+       * added the option to search for artist and title at the same time
+       * fixed a drawing problem with the help screen
+       * made scrolling of the song title when windows is too small optional
+         
+2007-02-01 Andreas Obergrusberger <tradiaz@yahoo.de>
   * fixed a bad bug in leoslyrics that made every
     second line an empty line
   * uploaded some updates for the lyrics system
@@ -76,7 +82,7 @@
 
 2006-08-4 Anderas Obergrusberger <tradiaz@yahoo.de>
         * tradiaz is temporary maintainer of a special branch of ncmpc now
-          https://svn.musicpd.org/mpd/ncmpc/branches/tradiaz
+          (https://svn.musicpd.org/mpd/ncmpc/branches/tradiaz)
           the development will go on there till kaw shows up again
           contact him: tradiaz@yahoo.de
 
diff --git a/TODO b/TODO
index cdcdd2f9bf3f13cb675a3d7fc62289c3042e4a9c..7a34370d913f97e240af443ce8937cf9f4f951cd 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,4 @@
 
- * Make status line scrolling optional
-
  * Scroll long list entries, move left/right (#242)
 
  * Search screen (with a simple ui)
@@ -13,5 +11,5 @@
 
  * LIRC support (without irpty) ?
 
- * In-program option editor
+ /* In-program option editor */ do not touch, already in develpoment ;)
 
index 3c80c2f530668be2edcc75fc5a375f68f22a1a55..c3c532ca2970ed0d7c3cb38f5ce2128a1de98c2b 100644 (file)
 ## mpd crossfade time 
 ##crossfade-time = 10
 
+## scroll long titles
+#scroll = yes
+
+## separator to use when scrolling
+#scroll-sep = " *** "
+
 ##
 ## Color configuration
 ##
index 11c3a55192f31555dba2d3f2814ac397ed00ff37..afcd78b156f5b322af184976661fe652b46d4006 100644 (file)
@@ -93,6 +93,12 @@ Visible bell on alerts.
 .B crossfade\-time = CROSSFADE TIME
 Default crossfade time in Seconds
 .TP
+.B scroll = yes|no
+Scroll the title if it is too long for the screen.
+.TP
+.B scroll\-sep = STRING
+The separator to show at the end of the scrolling title.
+.TP
 .B seek\-time = NUM
 Seek forward/backward by NUM seconds.
 .TP 
@@ -189,5 +195,5 @@ Report bugs on http://www.musicpd.org/mantis/
 Since MPD uses UTF\-8, ncmpc needs to convert characters to the 
 charset used by the local system. If you get character conversion errors when your running ncmpc you probably need to set up your locale. This is done by setting any of the LC_CTYPE, LANG or LC_ALL enviroment variables (LC_CTYPE only affects character handling).
 
-.SH "SE ALSO"
+.SH "SEE ALSO"
 mpc(1), mpd(1), locale(5), locale(7)
index 3af986b95fe89df1c99a72021c2b2b03b2352ddb..df0ac546564e055f8b5ef5ca231f8111f0717415 100644 (file)
@@ -70,6 +70,8 @@
 #define CONF_PASSWORD                "password"
 #define CONF_LYRICS_TIMEOUT          "lyrics-timeout"
 #define CONF_SHOW_SPLASH             "show-splash"
+#define CONF_SCROLL                  "scroll"
+#define CONF_SCROLL_SEP              "scroll-sep"
 
 typedef enum {
   KEY_PARSER_UNKNOWN,
@@ -584,6 +586,15 @@ read_rc_file(char *filename, options_t *options)
            {
            options->lyrics_timeout = atoi(get_format(value));
            }           
+           else if( !strcasecmp(CONF_SCROLL, name))
+           {
+           options->scroll = str2bool(value);
+           }
+           else if( !strcasecmp(CONF_SCROLL_SEP, name))
+           {
+           g_free(options->scroll_sep);
+           options->scroll_sep = get_format(value);
+           }
              else
                {
                  match_found = 0;
index 7849f8c1305d6ec98832c1defc5e075c2a283d55..5e978409ff9c73cc3ba59afadf9f13ed69596884 100644 (file)
@@ -125,6 +125,7 @@ exit_and_cleanup(void)
   g_free(options.password);
   g_free(options.list_format);
   g_free(options.status_format);
+  g_free(options.scroll_sep);
   if( timer )
     g_timer_destroy(timer);
 }
index b13146f385baaf30191ecd39e0d382d4ee544d50..98743a35d818a76c03cd4ebd9633bb28744ee743 100644 (file)
@@ -30,6 +30,7 @@
 #include "support.h"
 #include "mpdclient.h"
 #include "options.h"
+#include "strfsong.h"
 
 #undef  ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_ADD /* broken with song id's */
 #define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_DELETE
@@ -37,6 +38,8 @@
 #define ENABLE_SONG_ID
 #define ENABLE_PLCHANGES 
 
+#define BUFSIZE 1024
+
 #define MPD_ERROR(c) (c==NULL || c->connection==NULL || c->connection->error)
 
 /* from utils.c */
@@ -66,6 +69,27 @@ compare_filelistentry_dir(gconstpointer filelist_entry1, gconstpointer filelist_
   return n;
 }
 
+/* sort by list-format */
+gint
+compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2)
+{
+  mpd_InfoEntity *e1, *e2;
+  char key1[BUFSIZE], key2[BUFSIZE];
+  int n = 0;
+
+  e1 = ((filelist_entry_t *)filelist_entry1)->entity;
+  e2 = ((filelist_entry_t *)filelist_entry2)->entity;
+  if (e1 && e2 &&
+      e1->type == MPD_INFO_ENTITY_TYPE_SONG &&
+      e2->type == MPD_INFO_ENTITY_TYPE_SONG)
+    {
+      strfsong(key1, BUFSIZE, LIST_FORMAT, e1->info.song);
+      strfsong(key2, BUFSIZE, LIST_FORMAT, e2->info.song);
+      n = strcmp(key1,key2);
+    }
+  return n;
+}
+
 
 /* Error callbacks */
 static gint
index 3837b1e7b7659e15846f43fcfb4248e28b4c377c..44c266afc51472b85628264e4796575de2dff529 100644 (file)
@@ -203,5 +203,7 @@ void mpdclient_remove_browse_callback(mpdclient_t *c, mpdc_list_cb_t cb);
 /* issue a playlist callback */
 void mpdclient_browse_callback(mpdclient_t *c, int event, gpointer data);
 
+/* sort by list-format */
+gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);
 
 #endif
index 7bc99a1d68ca07add65f08bb92506ca408e9f9e9..7d000958d358dd12cd8522a99acd5ac46074438a 100644 (file)
@@ -79,4 +79,7 @@ void D(char *format, ...);
                                                                                           
 #define DEFAULT_LYRICS_TIMEOUT 100
 
+#define DEFAULT_SCROLL TRUE
+#define DEFAULT_SCROLL_SEP " *** "
+
 #endif /* NCMPC_H */
index f9bfcdd696cdf7b4b0f3ec82d7501b059bc092f1..fbf079af7198748ee1db8ff5dd25755ad31068fd 100644 (file)
@@ -375,6 +375,8 @@ options_init( void )
   options.timedisplay_type = DEFAULT_TIMEDISPLAY_TYPE;
   options.lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
   options.show_splash = FALSE;
+  options.scroll = DEFAULT_SCROLL;
+  options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
   
   return &options;
 }
index d858b709e0a4239a1ecccb8ccbd92f6576392108..5547ff8dd184087139b4f64f6fede52ef5286d2a 100644 (file)
@@ -12,6 +12,7 @@ typedef struct
   char *list_format;
   char *status_format;
   char *xterm_title_format;
+  char *scroll_sep;
   char **screen_list;
   char *timedisplay_type;
   int   port;
@@ -33,6 +34,7 @@ typedef struct
   gboolean enable_xterm_title; 
   gboolean enable_mouse;
   gboolean show_splash;
+  gboolean scroll;
 
 } options_t;
 
index 13e1975c1dc25a50431f1e09bb6bfb5b9d0a6ef0..93d305d78b448a473efac4e20daa2976c68920a6 100644 (file)
@@ -356,26 +356,30 @@ paint_status_window(mpdclient_t *c)
   if( IS_PLAYING(status->state) || IS_PAUSED(status->state) )
     {
       if( status->totalTime > 0 )
-        {
-       
-       /*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, 
-                  timestr,
-                  elapsedTime/60, elapsedTime%60,
-                  status->totalTime/60,   status->totalTime%60 );
+       {
+         /*checks the conf to see whether to display elapsed or remaining time */
+         if(!strcmp(options.timedisplay_type,"elapsed"))
+             elapsedTime = c->status->elapsedTime;
+         else if(!strcmp(options.timedisplay_type,"remaining"))
+             elapsedTime = (c->status->totalTime - c->status->elapsedTime);
+
+         if( c->song && seek_id == c->song->id )
+             elapsedTime = seek_target_time;
+         /*write out the time, using hours if time over 60 minutes*/
+         if (c->status->totalTime > 3600)
+           {
+             g_snprintf(screen->buf, screen->buf_size, 
+                     " [%i:%02i:%02i/%i:%02i:%02i]",
+                     elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60,
+                     status->totalTime/3600, (status->totalTime%3600)/60,  status->totalTime%60);
+           }
+         else
+           {
+             g_snprintf(screen->buf, screen->buf_size, 
+                     " [%i:%02i/%i:%02i]",
+                     elapsedTime/60, elapsedTime%60,
+                     status->totalTime/60,   status->totalTime%60 );
+           }
        }
       else
        {
@@ -404,10 +408,10 @@ paint_status_window(mpdclient_t *c)
 
       colors_use(w, COLOR_STATUS);
       /* scroll if the song name is to long */
-      if( my_strlen(songname) > width )
+      if( options.scroll && my_strlen(songname) > width )
        {
          static  scroll_state_t st = { 0, 0 };
-         char *tmp = strscroll(songname, " *** ", width, &st);
+         char *tmp = strscroll(songname, options.scroll_sep, width, &st);
 
          g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH);
          g_free(tmp);    
index 6825e567b3f9ceee85a02eb77e6717f949874cb0..8be8463f3f3bf18f574874bcedcbe5514b548848 100644 (file)
@@ -246,6 +246,7 @@ static int
 help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
 {
   lw->repaint=1;
+  lw->clear=1;
   switch(cmd)
     {
     case CMD_LIST_NEXT:
index 7fb559fabc7eeaac01e33905630f51b7b41924f6..4dfc6d0add1551056975eb23d60d45edabc4bb9d 100644 (file)
@@ -91,16 +91,19 @@ search_get_tag_id(char *name)
 #define SEARCH_ALBUM    2
 #define SEARCH_FILE     3
 
+#define SEARCH_ARTIST_TITLE 999
+
 typedef struct {
   int table;
   char *label;
 } search_type_t;
 
 static search_type_t mode[] = {
-  { MPD_TABLE_TITLE,    N_("Title") },
-  { MPD_TABLE_ARTIST,   N_("Artist") },
-  { MPD_TABLE_ALBUM,    N_("Album") },
-  { MPD_TABLE_FILENAME, N_("Filename") },
+  { MPD_TABLE_TITLE,     N_("Title") },
+  { MPD_TABLE_ARTIST,    N_("Artist") },
+  { MPD_TABLE_ALBUM,     N_("Album") },
+  { MPD_TABLE_FILENAME,  N_("Filename") },
+  { SEARCH_ARTIST_TITLE, N_("Artist + Title") },
   { 0, NULL }
 };
 
@@ -186,6 +189,29 @@ search_clear(screen_t *screen, mpdclient_t *c, gboolean clear_pattern)
 }
 
 #ifdef FUTURE
+mpdclient_filelist_t *
+filelist_search(mpdclient_t *c, int exact_match, int table, gchar *pattern)
+{
+  mpdclient_filelist_t *list, *list2;
+
+  if( table == SEARCH_ARTIST_TITLE )
+    {
+      list = mpdclient_filelist_search(c, FALSE, MPD_TABLE_ARTIST, pattern);
+      list2 = mpdclient_filelist_search(c, FALSE, MPD_TABLE_TITLE, pattern);
+
+      list->length += list2->length;
+      list->list = g_list_concat(list->list, list2->list);
+      list->list = g_list_sort(list->list, compare_filelistentry_format);
+      list->updated = TRUE;
+    }
+  else
+    {
+      list = mpdclient_filelist_search(c, FALSE, table, pattern);
+    }
+
+  return list;
+}
+
 /*-----------------------------------------------------------------------
  * NOTE: This code exists to test a new search ui,
  *       Its ugly and MUST be redesigned before the next release!
@@ -335,10 +361,10 @@ search_new(screen_t *screen, mpdclient_t *c)
   if( !MPD_VERSION_LT(c, 0, 12, 0) )
     filelist = search_advanced_query(pattern, c);
   if( !advanced_search_mode && filelist==NULL )
-    filelist = mpdclient_filelist_search(c, 
-                                        FALSE,
-                                        mode[options.search_mode].table,
-                                        pattern);
+    filelist = filelist_search(c, 
+                              FALSE,
+                              mode[options.search_mode].table,
+                              pattern);
   sync_highlights(c, filelist);
   mpdclient_install_playlist_callback(c, playlist_changed_callback);
   list_window_check_selected(lw, filelist->length);
@@ -462,7 +488,8 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
          /* continue and select next item... */
          cmd = CMD_LIST_NEXT;
        }
-      return 1;
+      /* call list_window_cmd to go to the next item */
+      return list_window_cmd(lw, filelist->length, cmd);
 
     case CMD_SEARCH_MODE:
       options.search_mode++;
@@ -475,10 +502,10 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
       if( pattern )
        {
          search_clear(screen, c, FALSE);
-         filelist = mpdclient_filelist_search(c, 
-                                              FALSE,
-                                              mode[options.search_mode].table,
-                                              pattern);
+         filelist = filelist_search(c, 
+                                    FALSE,
+                                    mode[options.search_mode].table,
+                                    pattern);
          sync_highlights(c, filelist);
        }
       return 1;
index 287fcbdce63b68105a3357450ad5dbee2407f3a6..df622a2bba75bbaf9cefef6df21fdeea7d392eb9 100644 (file)
@@ -204,9 +204,21 @@ _strfsong(gchar *s,
       else if (strncmp("%time%", p, n) == 0)
        {
          if (song->time != MPD_SONG_NO_TIME) 
-           temp = g_strdup_printf("%d:%02d", 
-                                  song->time / 60, 
-                                  song->time % 60 + 1);
+           {
+             if (song->time > 3600)
+               {
+                 temp = g_strdup_printf("%d:%02d:%02d", 
+                         song->time / 3600, 
+                         (song->time % 3600) / 60, 
+                         song->time % 60);
+               }
+             else
+               {
+                 temp = g_strdup_printf("%d:%02d", 
+                         song->time / 60, 
+                         song->time % 60);
+               }
+           }
        }
 
       if( temp == NULL)