From 236077042b696133b4a634be5048faf65b53e6dc Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Tue, 15 Jun 2004 15:32:18 +0000 Subject: Modified %shortfile% format to not shorten urls git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1502 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/ncmpc.h | 2 +- src/strfsong.c | 41 ++++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/ncmpc.h b/src/ncmpc.h index 6efe55af6..4a2770be9 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -39,7 +39,7 @@ #define MPD_RECONNECT_TIME 1500 /* song format - list window */ -#define DEFAULT_LIST_FORMAT "%name%|[%artist% - ]%title%|%file%" +#define DEFAULT_LIST_FORMAT "%name%|[%artist% - ]%title%|%shortfile%" #define LIST_FORMAT (options.list_format ? options.list_format : DEFAULT_LIST_FORMAT) /* song format - status window */ diff --git a/src/strfsong.c b/src/strfsong.c index 801447276..a06ae95a1 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -1,8 +1,28 @@ /* * $Id$ * + * Based on mpc's songToFormatedString modified for glib and ncmpc + * + * + * (c) 2003-2004 by normalperson and Warren Dukes (shank@mercury.chem.pitt.edu) + * and Daniel Brown (danb@cs.utexas.edu) + * and Kalle Wallin (kaw@linux.se) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include #include @@ -11,14 +31,13 @@ #include "config.h" #include "libmpdclient.h" -#include "ncmpc.h" #include "support.h" #include "strfsong.h" -static char * -skip(char * p) +static gchar * +skip(gchar * p) { - int stack = 0; + gint stack = 0; while (*p != '\0') { if(*p == '[') stack++; @@ -145,8 +164,6 @@ _strfsong(gchar *s, n = end - p + 1; if(*end != '%') n--; - else if (strncmp("%shortfile%", p, n) == 0) - temp = utf8_to_locale(basename(song->file)); else if (strncmp("%file%", p, n) == 0) temp = utf8_to_locale(song->file); else if (strncmp("%artist%", p, n) == 0) @@ -159,6 +176,13 @@ _strfsong(gchar *s, temp = song->track ? utf8_to_locale(song->track) : NULL; else if (strncmp("%name%", p, n) == 0) temp = song->name ? utf8_to_locale(song->name) : NULL; + else if (strncmp("%shortfile%", p, n) == 0) + { + if( strstr(song->file, "://") ) + temp = utf8_to_locale(song->file); + else + temp = utf8_to_locale(basename(song->file)); + } else if (strncmp("%time%", p, n) == 0) { if (song->time != MPD_SONG_NO_TIME) { @@ -201,11 +225,6 @@ _strfsong(gchar *s, return length; } - -/* a modified version of mpc's songToFormatedString (util.c) - * added - %basename% - */ - gsize strfsong(gchar *s, gsize max, const gchar *format, mpd_Song *song) { -- cgit v1.2.3