diff options
author | Andreas Obergrusberger <tradiaz@yahoo.de> | 2007-02-16 15:42:08 +0000 |
---|---|---|
committer | Andreas Obergrusberger <tradiaz@yahoo.de> | 2007-02-16 15:42:08 +0000 |
commit | ebdf8ae4bf442b994ba5dedf3efe22ffe8fc9aec (patch) | |
tree | f933858d5f7adbb49ed73e4be6d536eb3963906d /src | |
parent | 35c6c1651c0c5d67a5bbba8bf2b5726ba7721a5d (diff) | |
download | mpd-ebdf8ae4bf442b994ba5dedf3efe22ffe8fc9aec.tar.gz mpd-ebdf8ae4bf442b994ba5dedf3efe22ffe8fc9aec.tar.xz mpd-ebdf8ae4bf442b994ba5dedf3efe22ffe8fc9aec.zip |
way too much stuff to describe here
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@5346 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/conf.c | 11 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/mpdclient.c | 24 | ||||
-rw-r--r-- | src/mpdclient.h | 2 | ||||
-rw-r--r-- | src/ncmpc.h | 3 | ||||
-rw-r--r-- | src/options.c | 2 | ||||
-rw-r--r-- | src/options.h | 2 | ||||
-rw-r--r-- | src/screen.c | 48 | ||||
-rw-r--r-- | src/screen_help.c | 1 | ||||
-rw-r--r-- | src/screen_search.c | 53 | ||||
-rw-r--r-- | src/strfsong.c | 18 |
11 files changed, 127 insertions, 38 deletions
diff --git a/src/conf.c b/src/conf.c index 3af986b95..df0ac5465 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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; diff --git a/src/main.c b/src/main.c index 7849f8c13..5e978409f 100644 --- a/src/main.c +++ b/src/main.c @@ -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); } diff --git a/src/mpdclient.c b/src/mpdclient.c index b13146f38..98743a35d 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -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 diff --git a/src/mpdclient.h b/src/mpdclient.h index 3837b1e7b..44c266afc 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -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 diff --git a/src/ncmpc.h b/src/ncmpc.h index 7bc99a1d6..7d000958d 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -79,4 +79,7 @@ void D(char *format, ...); #define DEFAULT_LYRICS_TIMEOUT 100 +#define DEFAULT_SCROLL TRUE +#define DEFAULT_SCROLL_SEP " *** " + #endif /* NCMPC_H */ diff --git a/src/options.c b/src/options.c index f9bfcdd69..fbf079af7 100644 --- a/src/options.c +++ b/src/options.c @@ -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; } diff --git a/src/options.h b/src/options.h index d858b709e..5547ff8dd 100644 --- a/src/options.h +++ b/src/options.h @@ -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; diff --git a/src/screen.c b/src/screen.c index 13e1975c1..93d305d78 100644 --- a/src/screen.c +++ b/src/screen.c @@ -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); diff --git a/src/screen_help.c b/src/screen_help.c index 6825e567b..8be8463f3 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -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: diff --git a/src/screen_search.c b/src/screen_search.c index 7fb559fab..4dfc6d0ad 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -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; diff --git a/src/strfsong.c b/src/strfsong.c index 287fcbdce..df622a2bb 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -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) |