[easytag/wip/disc-number: 5/13] Add support for "total number of discs"
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/disc-number: 5/13] Add support for "total number of discs"
- Date: Fri, 19 Jul 2013 23:12:37 +0000 (UTC)
commit 100e13a1ae0eae6287a79b0974d741998bbfdc74
Author: Mathias Reineke <saihtam gmx net>
Date: Mon Jul 8 10:50:00 2013 +0200
Add support for "total number of discs"
src/browser.c | 24 ++++++++++++--
src/easytag.c | 27 +++++++++++++---
src/et_core.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
src/et_core.h | 1 +
src/flac_tag.c | 2 +
src/misc.c | 51 +++++++++++++++++++++++++++----
6 files changed, 174 insertions(+), 21 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index f65f8e5..26181af 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1002,6 +1002,7 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
gchar *basename_utf8 = g_path_get_basename(current_filename_utf8);
File_Tag *FileTag = ((File_Tag *)((ET_File *)l->data)->FileTag->data);
gchar *track;
+ gchar *disc;
// Change background color when changing directory (the first row must not be changed)
if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(fileListModel), NULL) > 0)
@@ -1023,6 +1024,11 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
/* File list displays the current filename (name on disc) and tag
* fields. */
track = g_strconcat(FileTag->track ? FileTag->track : "",FileTag->track_total ? "/" :
NULL,FileTag->track_total,NULL);
+ disc = g_strconcat (FileTag->disc_number ? FileTag->disc_number : "",
+ FileTag->disc_total ? "/"
+ : NULL, FileTag->disc_total,
+ NULL);
+
gtk_list_store_insert_with_values (fileListModel, &rowIter, G_MAXINT,
LIST_FILE_NAME, basename_utf8,
LIST_FILE_POINTER, l->data,
@@ -1035,8 +1041,7 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
FileTag->album_artist,
LIST_FILE_ALBUM, FileTag->album,
LIST_FILE_YEAR, FileTag->year,
- LIST_FILE_DISCNO,
- FileTag->disc_number,
+ LIST_FILE_DISCNO, disc,
LIST_FILE_TRACK, track,
LIST_FILE_GENRE, FileTag->genre,
LIST_FILE_COMMENT, FileTag->comment,
@@ -1051,6 +1056,7 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
FileTag->encoded_by, -1);
g_free(basename_utf8);
g_free(track);
+ g_free (disc);
if (etfile_to_select == l->data)
{
@@ -1080,6 +1086,7 @@ void Browser_List_Refresh_Whole_List (void)
gint row;
gchar *current_basename_utf8;
gchar *track;
+ gchar *disc;
gboolean valid;
GtkWidget *artist_radio;
@@ -1110,6 +1117,9 @@ void Browser_List_Refresh_Whole_List (void)
current_basename_utf8 = g_path_get_basename(FileName->value_utf8);
track = g_strconcat(FileTag->track ? FileTag->track : "",FileTag->track_total ? "/" :
NULL,FileTag->track_total,NULL);
+ disc = g_strconcat (FileTag->disc_number ? FileTag->disc_number : "",
+ FileTag->disc_total ? "/" : NULL,
+ FileTag->disc_total, NULL);
gtk_list_store_set(fileListModel, &iter,
LIST_FILE_NAME, current_basename_utf8,
@@ -1118,7 +1128,7 @@ void Browser_List_Refresh_Whole_List (void)
LIST_FILE_ALBUM_ARTIST, FileTag->album_artist,
LIST_FILE_ALBUM, FileTag->album,
LIST_FILE_YEAR, FileTag->year,
- LIST_FILE_DISCNO, FileTag->disc_number,
+ LIST_FILE_DISCNO, disc,
LIST_FILE_TRACK, track,
LIST_FILE_GENRE, FileTag->genre,
LIST_FILE_COMMENT, FileTag->comment,
@@ -1130,6 +1140,7 @@ void Browser_List_Refresh_Whole_List (void)
-1);
g_free(current_basename_utf8);
g_free(track);
+ g_free (disc);
Browser_List_Set_Row_Appearance(&iter);
@@ -1187,6 +1198,7 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
gboolean row_found = FALSE;
gchar *current_basename_utf8;
gchar *track;
+ gchar *disc;
gboolean valid;
gint row;
gchar *artist, *album;
@@ -1268,6 +1280,9 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
current_basename_utf8 = g_path_get_basename(FileName->value_utf8);
track = g_strconcat(FileTag->track ? FileTag->track : "",FileTag->track_total ? "/" :
NULL,FileTag->track_total,NULL);
+ disc = g_strconcat (FileTag->disc_number ? FileTag->disc_number : "",
+ FileTag->disc_total ? "/" : NULL, FileTag->disc_total,
+ NULL);
gtk_list_store_set(fileListModel, &selectedIter,
LIST_FILE_NAME, current_basename_utf8,
@@ -1276,7 +1291,7 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
LIST_FILE_ALBUM_ARTIST, FileTag->album_artist,
LIST_FILE_ALBUM, FileTag->album,
LIST_FILE_YEAR, FileTag->year,
- LIST_FILE_DISCNO, FileTag->disc_number,
+ LIST_FILE_DISCNO, disc,
LIST_FILE_TRACK, track,
LIST_FILE_GENRE, FileTag->genre,
LIST_FILE_COMMENT, FileTag->comment,
@@ -1288,6 +1303,7 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
-1);
g_free(current_basename_utf8);
g_free(track);
+ g_free (disc);
// Change appearance (line to red) if filename changed
Browser_List_Set_Row_Appearance(&selectedIter);
diff --git a/src/easytag.c b/src/easytag.c
index 7e36181..a252ff0 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -1397,20 +1397,37 @@ Mini_Button_Clicked (GObject *object)
}
else if (object == G_OBJECT (DiscNumberEntry))
{
- string_to_set = gtk_editable_get_chars(GTK_EDITABLE(DiscNumberEntry),0,-1);
+ /* FIXME: Split discs field into disc number and disc total. */
+ string_to_set = g_strdup (gtk_entry_get_text (GTK_ENTRY (DiscNumberEntry)));
+ string_to_set1 = NULL;
for (l = etfilelist; l != NULL; l = g_list_next (l))
{
etfile = (ET_File *)l->data;
FileTag = ET_File_Tag_Item_New();
ET_Copy_File_Tag_Item(etfile,FileTag);
- ET_Set_Field_File_Tag_Item(&FileTag->disc_number,string_to_set);
+ ET_Set_Field_File_Tag_Item (&FileTag->disc_number, string_to_set);
+ ET_Set_Field_File_Tag_Item (&FileTag->disc_total, string_to_set1);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
- msg = g_strdup_printf(_("Selected files tagged with disc number '%s'."),string_to_set);
+
+ if (string_to_set != NULL && g_utf8_strlen (string_to_set, -1) > 0)
+ {
+ if (string_to_set1 != NULL
+ && g_utf8_strlen (string_to_set1, -1) > 0)
+ {
+ msg = g_strdup_printf (_("Selected files tagged with disc number '%s/%s'."),
+ string_to_set, string_to_set1);
+ }
+ else
+ {
+ msg = g_strdup_printf (_("Selected files tagged with disc number like 'xx'."));
+ }
+ }
else
- msg = g_strdup(_("Removed disc number from selected files."));
+ {
+ msg = g_strdup (_("Removed disc number from selected files."));
+ }
}
else if (object == G_OBJECT (YearEntry))
{
diff --git a/src/et_core.c b/src/et_core.c
index 77deb29..bb85ef7 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -368,6 +368,7 @@ ET_Initialize_File_Tag_Item (File_Tag *FileTag)
FileTag->album_artist= NULL;
FileTag->album = NULL;
FileTag->disc_number = NULL;
+ FileTag->disc_total = NULL;
FileTag->track = NULL;
FileTag->track_total = NULL;
FileTag->year = NULL;
@@ -2195,6 +2196,7 @@ gboolean ET_Free_File_Tag_Item (File_Tag *FileTag)
g_free(FileTag->album_artist);
g_free(FileTag->album);
g_free(FileTag->disc_number);
+ g_free (FileTag->disc_total);
g_free(FileTag->year);
g_free(FileTag->track);
g_free(FileTag->track_total);
@@ -2387,6 +2389,16 @@ gboolean ET_Copy_File_Tag_Item (ET_File *ETFile, File_Tag *FileTag)
FileTag->disc_number = NULL;
}
+ if (FileTagCur->disc_total)
+ {
+ FileTag->disc_total = g_strdup (FileTagCur->disc_total);
+ }
+ else
+ {
+ g_free (FileTag->disc_total);
+ FileTag->disc_total = NULL;
+ }
+
if (FileTagCur->year)
{
FileTag->year = g_strdup(FileTagCur->year);
@@ -2932,13 +2944,31 @@ ET_Display_File_Tag_To_UI (ET_File *ETFile)
gtk_entry_set_text(GTK_ENTRY(AlbumEntry),"");
/* Show disc_number */
+ /* FIXME: Combine disc number and disc total into a single string. */
if (FileTag && FileTag->disc_number)
{
gchar *tmp = Try_To_Validate_Utf8_String(FileTag->disc_number);
- gtk_entry_set_text(GTK_ENTRY(DiscNumberEntry), tmp);
- g_free(tmp);
- }else
- gtk_entry_set_text(GTK_ENTRY(DiscNumberEntry),"");
+ gtk_entry_set_text (GTK_ENTRY (DiscNumberEntry), tmp);
+ g_free (tmp);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (DiscNumberEntry), "");
+ }
+
+ /* Show number of discs of the album. */
+#if 0
+ if (FileTag && FileTag->disc_total)
+ {
+ gchar *tmp = Try_To_Validate_Utf8_String (FileTag->disc_total);
+ gtk_entry_set_text (GTK_ENTRY (DiscNumberEntry), tmp);
+ g_free (tmp);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (DiscNumberEntry), "");
+ }
+#endif
/* Show year */
if (FileTag && FileTag->year)
@@ -3432,7 +3462,8 @@ ET_Save_File_Tag_From_UI (File_Tag *FileTag)
}
/* Disc Number */
- buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(DiscNumberEntry)));
+ /* FIXME: Take single disc string and split into disc number and disc total. */
+ buffer = g_strdup (gtk_entry_get_text (GTK_ENTRY (DiscNumberEntry)));
g_strstrip (buffer);
if ( g_utf8_strlen(buffer, -1) > 0 )
@@ -3443,6 +3474,23 @@ ET_Save_File_Tag_From_UI (File_Tag *FileTag)
g_free(buffer);
}
+ /* Discs Total */
+#if 0
+ buffer = g_strdup (gtk_entry_get_text (GTK_ENTRY (DiscNumberEntry)));
+ g_strstrip (buffer);
+
+ if (g_utf8_strlen (buffer, -1) > 0)
+ {
+ FileTag->disc_total = et_disc_number_to_string (atoi (buffer));
+ g_free (buffer);
+ }
+ else
+ {
+ FileTag->disc_total = NULL;
+ g_free (buffer);
+ }
+#endif
+
/* Year */
buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(YearEntry)));
g_strstrip (buffer);
@@ -3669,6 +3717,19 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
}
+ /* Discs Total */
+ if (FileTagCur->disc_total
+ && g_utf8_strlen (FileTagCur->disc_total, -1) > 0)
+ {
+ FileTag->disc_total = et_disc_number_to_string (atoi (FileTagCur->disc_total));
+ g_strstrip (FileTag->disc_total);
+ }
+ else
+ {
+ FileTag->disc_total = NULL;
+ }
+
+
/* Year */
if ( FileTagCur->year && g_utf8_strlen(FileTagCur->year, -1)>0 )
{
@@ -4120,6 +4181,25 @@ gboolean ET_Detect_Changes_Of_File_Tag (File_Tag *FileTag1, File_Tag *FileTag2)
if (!FileTag1->disc_number && FileTag2->disc_number && g_utf8_strlen(FileTag2->disc_number, -1)>0 )
return TRUE;
if ( FileTag1->disc_number && FileTag2->disc_number &&
g_utf8_collate(FileTag1->disc_number,FileTag2->disc_number)!=0 ) return TRUE;
+ /* Discs Total */
+ if (FileTag1->disc_total && !FileTag2->disc_total
+ && g_utf8_strlen (FileTag1->disc_total, -1) > 0)
+ {
+ return TRUE;
+ }
+
+ if (!FileTag1->disc_total && FileTag2->disc_total
+ && g_utf8_strlen (FileTag2->disc_total, -1) > 0)
+ {
+ return TRUE;
+ }
+
+ if (FileTag1->disc_total && FileTag2->disc_total
+ && g_utf8_collate (FileTag1->disc_total, FileTag2->disc_total) != 0)
+ {
+ return TRUE;
+ }
+
/* Year */
if ( FileTag1->year && !FileTag2->year && g_utf8_strlen(FileTag1->year, -1)>0 ) return TRUE;
if (!FileTag1->year && FileTag2->year && g_utf8_strlen(FileTag2->year, -1)>0 ) return TRUE;
diff --git a/src/et_core.h b/src/et_core.h
index 8688bb4..c9dc610 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -173,6 +173,7 @@ struct _File_Tag
gchar *album_artist; /* Album Artist */
gchar *album; /* Album name */
gchar *disc_number; /* Disc number */
+ gchar *disc_total; /* The total number of discs of the album (ex: 1/2). */
gchar *year; /* Year of track */
gchar *track; /* Position of track in the album */
gchar *track_total; /* The number of tracks for the album (ex: 12/20) */
diff --git a/src/flac_tag.c b/src/flac_tag.c
index ff9b150..cb3612c 100644
--- a/src/flac_tag.c
+++ b/src/flac_tag.c
@@ -679,6 +679,7 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
&& FileTag->album_artist == NULL
&& FileTag->album == NULL
&& FileTag->disc_number == NULL
+ && FileTag->disc_total == NULL
&& FileTag->year == NULL
&& FileTag->track == NULL
&& FileTag->track_total == NULL
@@ -700,6 +701,7 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
|| FileTag->album_artist != NULL
|| FileTag->album != NULL
|| FileTag->disc_number != NULL
+ || FileTag->disc_total != NULL
|| FileTag->year != NULL
|| FileTag->track != NULL
|| FileTag->track_total != NULL
diff --git a/src/misc.c b/src/misc.c
index 7839567..8f425b1 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -516,6 +516,7 @@ void Load_Track_List_To_UI (void)
}
+
/*
* Change mouse cursor
*/
@@ -2275,9 +2276,10 @@ Search_File (GtkWidget *search_button)
ET_File *ETFile;
gchar *msg;
gchar *temp = NULL;
- gchar *title2, *artist2, *album_artist2, *album2, *disc_number2, *year2, *track2,
- *track_total2, *genre2, *comment2, *composer2, *orig_artist2,
- *copyright2, *url2, *encoded_by2, *string_to_search2;
+ gchar *title2, *artist2, *album_artist2, *album2, *disc_number2,
+ *disc_total2, *year2, *track2, *track_total2, *genre2, *comment2,
+ *composer2, *orig_artist2, *copyright2, *url2, *encoded_by2,
+ *string_to_search2;
gint resultCount = 0;
@@ -2343,6 +2345,14 @@ Search_File (GtkWidget *search_button)
if (FileTag->album_artist) album_artist2 = g_utf8_casefold(FileTag->album_artist, -1); else
album_artist2= NULL;
if (FileTag->album) album2 = g_utf8_casefold(FileTag->album, -1); else
album2 = NULL;
if (FileTag->disc_number) disc_number2 = g_utf8_casefold(FileTag->disc_number, -1); else
disc_number2 = NULL;
+ if (FileTag->disc_total)
+ {
+ disc_total2 = g_utf8_casefold (FileTag->disc_total, -1);
+ }
+ else
+ {
+ disc_total2 = NULL;
+ }
if (FileTag->year) year2 = g_utf8_casefold(FileTag->year, -1); else
year2 = NULL;
if (FileTag->track) track2 = g_utf8_casefold(FileTag->track, -1); else
track2 = NULL;
if (FileTag->track_total) track_total2 = g_utf8_casefold(FileTag->track_total, -1); else
track_total2 = NULL;
@@ -2360,9 +2370,10 @@ Search_File (GtkWidget *search_button)
// Duplicate and convert the strings into UTF-8
title2 = g_strdup(FileTag->title);
artist2 = g_strdup(FileTag->artist);
- album_artist2= g_strdup(FileTag->album_artist);
+ album_artist2= g_strdup(FileTag->album_artist);
album2 = g_strdup(FileTag->album);
disc_number2 = g_strdup(FileTag->disc_number);
+ disc_total2 = g_strdup (FileTag->disc_total);
year2 = g_strdup(FileTag->year);
track2 = g_strdup(FileTag->track);
track_total2 = g_strdup(FileTag->track_total);
@@ -2382,6 +2393,7 @@ Search_File (GtkWidget *search_button)
|| (album_artist2 && strstr(album_artist2,string_to_search2) )
|| (album2 && strstr(album2, string_to_search2) )
|| (disc_number2 && strstr(disc_number2, string_to_search2) )
+ || (disc_total2 && strstr (disc_total2, string_to_search2))
|| (year2 && strstr(year2, string_to_search2) )
|| (track2 && strstr(track2, string_to_search2) )
|| (track_total2 && strstr(track_total2, string_to_search2) )
@@ -2400,6 +2412,7 @@ Search_File (GtkWidget *search_button)
g_free(album_artist2);
g_free(album2);
g_free(disc_number2);
+ g_free (disc_total2);
g_free(year2);
g_free(track2);
g_free(track_total2);
@@ -2449,6 +2462,7 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL};
gchar *track, *track_total;
+ gchar *disc_number, *disc_total;
gboolean case_sensitive;
gint column;
@@ -2465,10 +2479,8 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
SearchResultList_Text[SEARCH_RESULT_ARTIST] = g_strdup(((File_Tag *)ETFile->FileTag->data)->artist);
// Album Artist
SearchResultList_Text[SEARCH_RESULT_ALBUM_ARTIST]= g_strdup(((File_Tag
*)ETFile->FileTag->data)->album_artist);
- // Album
+ // Album
SearchResultList_Text[SEARCH_RESULT_ALBUM] = g_strdup(((File_Tag *)ETFile->FileTag->data)->album);
- // Disc Number
- SearchResultList_Text[SEARCH_RESULT_DISC_NUMBER] = g_strdup(((File_Tag
*)ETFile->FileTag->data)->disc_number);
// Year
SearchResultList_Text[SEARCH_RESULT_YEAR] = g_strdup(((File_Tag *)ETFile->FileTag->data)->year);
//Genre
@@ -2486,6 +2498,29 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
// Encoded by
SearchResultList_Text[SEARCH_RESULT_ENCODED_BY] = g_strdup(((File_Tag
*)ETFile->FileTag->data)->encoded_by);
+ /* Disc Number. */
+ disc_number = ((File_Tag *)ETFile->FileTag->data)->disc_number;
+ disc_total = ((File_Tag *)ETFile->FileTag->data)->disc_total;
+
+ if (disc_number)
+ {
+ if (disc_total)
+ {
+ SearchResultList_Text[SEARCH_RESULT_DISC_NUMBER] = g_strconcat (disc_number, "/", disc_total,
NULL);
+ }
+ else
+ {
+ SearchResultList_Text[SEARCH_RESULT_DISC_NUMBER] = g_strdup (disc_number);
+ }
+ }
+ else
+ {
+ SearchResultList_Text[SEARCH_RESULT_DISC_NUMBER] = NULL;
+ }
+
+ g_free (disc_number);
+ g_free (disc_total);
+
// Track
track = ((File_Tag *)ETFile->FileTag->data)->track;
track_total = ((File_Tag *)ETFile->FileTag->data)->track_total;
@@ -2500,6 +2535,8 @@ Add_Row_To_Search_Result_List (ET_File *ETFile, const gchar *string_to_search)
SearchResultList_Text[SEARCH_RESULT_TRACK] = NULL;
}
+ g_free (track);
+ g_free (track_total);
// Highlight the keywords in the result list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]