[sound-juicer] Zero pad disc number when needed



commit 6bd1ea39d61f0b54d9ecdace25077a24f29382cb
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Mon Aug 24 11:44:56 2015 +0100

    Zero pad disc number when needed
    
    Zero pad the disc number appropriately for the number of discs in the
    current album. This means that the tracks will sort properly when listed
    alphabetically by name. Currently there is no way to enter the number of
    discs in the current album in the UI so this only works for albums that
    have that information in MusicBrainz.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753739

 src/sj-extracting.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index a2b5af4..9bf42f6 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -1164,7 +1164,14 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track)
       case 'N':
         /* Disc and track number, zero padded */
         if (track->album->disc_number > 0) {
-          string = g_strdup_printf ("d%dt%02d", track->album->disc_number, track->number);
+          const gchar *format;
+          if (track->album->disc_count < 10)
+            format = "d%dt%02d";
+          else if (track->album->disc_count < 100)
+            format = "d%02dt%02d";
+          else
+            format = "d%03dt%02d";
+          string = g_strdup_printf (format, track->album->disc_number, track->number);
         } else {
           string = g_strdup_printf ("%02d", track->number);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]