[Easytag-mailing] Easytag Album Artist / Custom Field patch
- From: Bart <bs xs4all nl>
- To: easytag-mailing lists sourceforge net
- Subject: [Easytag-mailing] Easytag Album Artist / Custom Field patch
- Date: Fri, 07 May 2010 01:13:22 +0200
Hi,
I created a patch to add your own custom field. By default it's
ALBUMARTIST (flac) or TPE2 (mp3/id3v2) - you need to change the
easytag.h file to change this (and rebuild).
No other file formats tested (I only made changes for Flac and mp3).
Brief build manual included.
Hope it helps - it's my first code publication on the web so let me know
if it works for you or not.
Regards
Only in ../easytag-2.1.6/src: .deps
Only in ../easytag-2.1.6/src: Makefile
diff -C 2 ./bar.c ../easytag-2.1.6/src/bar.c
*** ./bar.c Sat Mar 22 22:25:35 2008
--- ../easytag-2.1.6/src/bar.c Thu May 6 20:31:27 2010
***************
*** 102,105 ****
--- 102,107 ----
QCASE_DATA(AM_SORT_ASCENDING_ENCODED_BY, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_ASCENDING_ENCODED_BY);
QCASE_DATA(AM_SORT_DESCENDING_ENCODED_BY, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_DESCENDING_ENCODED_BY);
+ QCASE_DATA(AM_SORT_ASCENDING_CUSTOM, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_ASCENDING_CUSTOM);
+ QCASE_DATA(AM_SORT_DESCENDING_CUSTOM, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_DESCENDING_CUSTOM);
QCASE_DATA(AM_SORT_ASCENDING_FILE_TYPE, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_ASCENDING_FILE_TYPE);
QCASE_DATA(AM_SORT_DESCENDING_FILE_TYPE, ET_Sort_Displayed_File_List_And_Update_UI, SORTING_BY_DESCENDING_FILE_TYPE);
***************
*** 175,178 ****
--- 177,182 ----
{ AM_SORT_ASCENDING_ENCODED_BY, GTK_STOCK_SORT_ASCENDING, _("Ascending by encoder name"), NULL, _("Ascending by encoder name"), G_CALLBACK(Menu_Sort_Action) },
{ AM_SORT_DESCENDING_ENCODED_BY, GTK_STOCK_SORT_DESCENDING, _("Descending by encoder name"), NULL, _("Descending by encoder name"), G_CALLBACK(Menu_Sort_Action) },
+ { AM_SORT_ASCENDING_CUSTOM, GTK_STOCK_SORT_ASCENDING, _(SORT_ASC), NULL, _(SORT_ASC), G_CALLBACK(Menu_Sort_Action) },
+ { AM_SORT_DESCENDING_CUSTOM, GTK_STOCK_SORT_DESCENDING, _(SORT_DESC), NULL, _(SORT_DESC), G_CALLBACK(Menu_Sort_Action) },
{ AM_SORT_ASCENDING_FILE_TYPE, GTK_STOCK_SORT_ASCENDING, _("Ascending by file type"), NULL, _("Ascending by file type"), G_CALLBACK(Menu_Sort_Action) },
{ AM_SORT_DESCENDING_FILE_TYPE, GTK_STOCK_SORT_DESCENDING, _("Descending by file type"), NULL, _("Descending by file type"), G_CALLBACK(Menu_Sort_Action) },
diff -C 2 ./bar.h ../easytag-2.1.6/src/bar.h
*** ./bar.h Sat Mar 22 22:25:55 2008
--- ../easytag-2.1.6/src/bar.h Thu May 6 21:05:08 2010
***************
*** 136,139 ****
--- 136,141 ----
#define AM_SORT_ASCENDING_ENCODED_BY "SortEncodedByAsc"
#define AM_SORT_DESCENDING_ENCODED_BY "SortEncodedByDesc"
+ #define AM_SORT_ASCENDING_CUSTOM "SortCustomAsc"
+ #define AM_SORT_DESCENDING_CUSTOM "SortCustomDesc"
#define AM_SORT_ASCENDING_FILE_TYPE "SortTypeAsc"
#define AM_SORT_DESCENDING_FILE_TYPE "SortTypeDesc"
diff -C 2 ./browser.c ../easytag-2.1.6/src/browser.c
*** ./browser.c Sat Jul 12 14:36:19 2008
--- ../easytag-2.1.6/src/browser.c Thu May 6 20:35:57 2010
***************
*** 1069,1072 ****
--- 1069,1073 ----
LIST_FILE_URL, FileTag->url,
LIST_FILE_ENCODED_BY, FileTag->encoded_by,
+ LIST_FILE_CUSTOM, FileTag->custom,
-1);
g_free(basename_utf8);
***************
*** 1147,1150 ****
--- 1148,1152 ----
LIST_FILE_URL, FileTag->url,
LIST_FILE_ENCODED_BY, FileTag->encoded_by,
+ LIST_FILE_CUSTOM, FileTag->custom,
-1);
g_free(current_basename_utf8);
***************
*** 1302,1305 ****
--- 1304,1308 ----
LIST_FILE_URL, FileTag->url,
LIST_FILE_ENCODED_BY, FileTag->encoded_by,
+ LIST_FILE_CUSTOM, FileTag->custom,
-1);
g_free(current_basename_utf8);
***************
*** 1446,1449 ****
--- 1449,1453 ----
LIST_FILE_URL, FileTag->url,
LIST_FILE_ENCODED_BY, FileTag->encoded_by,
+ LIST_FILE_CUSTOM, FileTag->custum,
-1);
}*/
***************
*** 1886,1889 ****
--- 1890,1899 ----
result = ET_Comp_Func_Sort_File_By_Descending_Encoded_By(ETFile1, ETFile2);
break;
+ case SORTING_BY_ASCENDING_CUSTOM:
+ result = ET_Comp_Func_Sort_File_By_Ascending_Custom(ETFile1, ETFile2);
+ break;
+ case SORTING_BY_DESCENDING_CUSTOM:
+ result = ET_Comp_Func_Sort_File_By_Descending_Custom(ETFile1, ETFile2);
+ break;
case SORTING_BY_ASCENDING_FILE_TYPE:
result = ET_Comp_Func_Sort_File_By_Ascending_File_Type(ETFile1, ETFile2);
***************
*** 3029,3033 ****
N_("Year"),N_("Track"),N_("Genre"),N_("Comment"),
N_("Composer"),N_("Orig. Artist"),N_("Copyright"),
! N_("URL"),N_("Encoded By")};
gchar *ArtistList_Titles[] = {N_("Artist"),N_("# Albums"),N_("# Files")};
gchar *AlbumList_Titles[] = {N_("Album"),N_("# Files")};
--- 3039,3043 ----
N_("Year"),N_("Track"),N_("Genre"),N_("Comment"),
N_("Composer"),N_("Orig. Artist"),N_("Copyright"),
! N_("URL"),N_("Encoded By"),N_(CUSTOM_TITLE)};
gchar *ArtistList_Titles[] = {N_("Artist"),N_("# Albums"),N_("# Files")};
gchar *AlbumList_Titles[] = {N_("Album"),N_("# Files")};
***************
*** 3384,3387 ****
--- 3394,3398 ----
G_TYPE_STRING,
G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_STRING);
***************
*** 3574,3577 ****
--- 3585,3602 ----
gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserList), column);
+ // Column for Custom field
+ column = gtk_tree_view_column_new();
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(column, renderer, FALSE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_title(column, _(BrowserList_Titles[13]));
+ gtk_tree_view_column_set_attributes(column, renderer,
+ "text", LIST_FILE_CUSTOM,
+ "weight", LIST_FONT_WEIGHT,
+ "background-gdk", LIST_ROW_BACKGROUND,
+ "foreground-gdk", LIST_ROW_FOREGROUND,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserList), column);
+
gtk_tree_view_set_reorderable(GTK_TREE_VIEW(BrowserList), FALSE);
diff -C 2 ./browser.h ../easytag-2.1.6/src/browser.h
*** ./browser.h Sat Mar 22 21:22:19 2008
--- ../easytag-2.1.6/src/browser.h Thu May 6 19:49:56 2010
***************
*** 94,97 ****
--- 94,98 ----
LIST_FILE_URL,
LIST_FILE_ENCODED_BY,
+ LIST_FILE_CUSTOM,
LIST_COLUMN_COUNT
};
diff -C 2 ./easytag.c ../easytag-2.1.6/src/easytag.c
*** ./easytag.c Wed May 21 22:06:00 2008
--- ../easytag-2.1.6/src/easytag.c Thu May 6 21:02:16 2010
***************
*** 940,943 ****
--- 940,962 ----
g_object_set_data(G_OBJECT(EncodedByEntry),"MButtonName",EncodedByMButton);
+ /* Custom field */
+ CustomLabel = gtk_label_new(_(CUSTOM_LABEL));
+ gtk_table_attach(GTK_TABLE(Table),CustomLabel,0,1,11,12,GTK_FILL,GTK_FILL,TablePadding,TablePadding);
+ gtk_misc_set_alignment(GTK_MISC(CustomLabel),1,0.5);
+
+ CustomEntry = gtk_entry_new();
+ gtk_table_attach(GTK_TABLE(Table),CustomEntry,1,10,11,12,
+ GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,TablePadding,TablePadding);
+
+ CustomMButton = gtk_button_new();
+ gtk_widget_set_size_request(CustomMButton,MButtonSize,MButtonSize);
+ gtk_table_attach(GTK_TABLE(Table),CustomMButton,10,11,11,12,0,0,TablePadding,TablePadding);
+ g_signal_connect(G_OBJECT(CustomMButton),"clicked", G_CALLBACK(Mini_Button_Clicked),NULL);
+ gtk_tooltips_set_tip(Tips,CustomMButton,_(CUSTOM_HINT),NULL);
+
+ Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(CustomEntry));
+ g_object_set_data(G_OBJECT(CustomEntry),"MButtonName",CustomMButton);
+
+
// Managing of entries when pressing the Enter key
***************
*** 956,959 ****
--- 975,979 ----
g_signal_connect_swapped(G_OBJECT(URLEntry), "activate",G_CALLBACK(gtk_widget_grab_focus),G_OBJECT(EncodedByEntry));
g_signal_connect_swapped(G_OBJECT(EncodedByEntry), "activate",G_CALLBACK(gtk_widget_grab_focus),G_OBJECT(TitleEntry));
+ g_signal_connect_swapped(G_OBJECT(CustomEntry), "activate",G_CALLBACK(gtk_widget_grab_focus),G_OBJECT(EncodedByEntry));
// Set focus chain
***************
*** 987,990 ****
--- 1007,1012 ----
focusable_widgets_list = g_list_append(focusable_widgets_list,EncodedByEntry);
focusable_widgets_list = g_list_append(focusable_widgets_list,EncodedByMButton);
+ focusable_widgets_list = g_list_append(focusable_widgets_list,CustomEntry);
+ focusable_widgets_list = g_list_append(focusable_widgets_list,CustomMButton);
focusable_widgets_list = g_list_append(focusable_widgets_list,TitleEntry); // To loop to the beginning
gtk_container_set_focus_chain(GTK_CONTAINER(Table),focusable_widgets_list);
***************
*** 1525,1528 ****
--- 1547,1570 ----
msg = g_strdup(_("Removed encoder name from selected files."));
}
+ else if (object==G_OBJECT(CustomMButton))
+ {
+ string_to_set = gtk_editable_get_chars(GTK_EDITABLE(CustomEntry),0,-1);
+ while (etfilelist)
+ {
+ etfile = (ET_File *)etfilelist->data;
+ FileTag = ET_File_Tag_Item_New();
+ ET_Copy_File_Tag_Item(etfile,FileTag);
+ ET_Set_Field_File_Tag_Item(&FileTag->custom,string_to_set);
+ ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
+
+ if (!etfilelist->next) break;
+ etfilelist = g_list_next(etfilelist);
+ }
+ if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+ msg = g_strdup_printf(_(CUSTOM_RESP"'%s'."),string_to_set);
+ else
+ msg = g_strdup(_(CUSTOM_DEL));
+ }
+
else if (object==G_OBJECT(PictureMButton))
{
***************
*** 4128,4131 ****
--- 4170,4176 ----
gtk_widget_hide(GTK_WIDGET(EncodedByEntry));
gtk_widget_hide(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_hide(GTK_WIDGET(CustomLabel));
+ gtk_widget_hide(GTK_WIDGET(CustomEntry));
+ gtk_widget_hide(GTK_WIDGET(CustomMButton));
gtk_widget_hide(GTK_WIDGET(PictureLabel));
gtk_widget_hide(GTK_WIDGET(PictureScrollWindow));
***************
*** 4155,4158 ****
--- 4200,4206 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
gtk_widget_show(GTK_WIDGET(PictureLabel));
gtk_widget_show(GTK_WIDGET(PictureScrollWindow));
***************
*** 4185,4188 ****
--- 4233,4239 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
gtk_widget_show(GTK_WIDGET(PictureLabel));
gtk_widget_show(GTK_WIDGET(PictureScrollWindow));
***************
*** 4215,4218 ****
--- 4266,4272 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
#ifndef LEGACY_FLAC // Picture supported for FLAC >= 1.1.3...
gtk_widget_show(GTK_WIDGET(PictureLabel));
***************
*** 4266,4269 ****
--- 4320,4326 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
gtk_widget_hide(GTK_WIDGET(PictureLabel));
gtk_widget_hide(GTK_WIDGET(PictureScrollWindow));
***************
*** 4295,4298 ****
--- 4352,4358 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
gtk_widget_show(GTK_WIDGET(PictureLabel));
gtk_widget_show(GTK_WIDGET(PictureScrollWindow));
***************
*** 4325,4328 ****
--- 4385,4391 ----
gtk_widget_show(GTK_WIDGET(EncodedByEntry));
gtk_widget_show(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_show(GTK_WIDGET(CustomLabel));
+ gtk_widget_show(GTK_WIDGET(CustomEntry));
+ gtk_widget_show(GTK_WIDGET(CustomMButton));
gtk_widget_hide(GTK_WIDGET(PictureLabel));
gtk_widget_hide(GTK_WIDGET(PictureScrollWindow));
***************
*** 4355,4358 ****
--- 4418,4424 ----
gtk_widget_hide(GTK_WIDGET(EncodedByEntry));
gtk_widget_hide(GTK_WIDGET(EncodedByMButton));
+ gtk_widget_hide(GTK_WIDGET(CustomLabel));
+ gtk_widget_hide(GTK_WIDGET(CustomEntry));
+ gtk_widget_hide(GTK_WIDGET(CustomMButton));
gtk_widget_hide(GTK_WIDGET(PictureLabel));
gtk_widget_hide(GTK_WIDGET(PictureScrollWindow));
***************
*** 4392,4395 ****
--- 4458,4462 ----
gtk_entry_set_text(GTK_ENTRY(URLEntry), "");
gtk_entry_set_text(GTK_ENTRY(EncodedByEntry), "");
+ gtk_entry_set_text(GTK_ENTRY(CustomEntry), "");
PictureEntry_Clear();
}
diff -C 2 ./easytag.h ../easytag-2.1.6/src/easytag.h
*** ./easytag.h Wed Nov 28 08:54:35 2007
--- ../easytag-2.1.6/src/easytag.h Thu May 6 21:08:09 2010
***************
*** 36,39 ****
--- 36,51 ----
/*#define VERSION "0.15.1" //Now version is defined in ../configure.h.in */
+ #define CUSTOM_LABEL "Album Artist:" // Field name
+ #define CUSTOM_TITLE "Alb.Artist" // Browser name
+ #define CUSTOM_FLAC "ALBUMARTIST" // FLAC Comment
+ #define CUSTOM_ID3 "TPE2" // ID3v2 TAG
+ #define SORT_ASC "Ascending by Album Artist" // Ascending description
+ #define SORT_DESC "Descending by Album Artist" // Descending description
+ #define CUSTOM_HINT "Tag selected files with this Album Artist name" // Hint
+ #define CUSTOM_RESP "Selected files tagged with Album Artist " // Response
+ #define CUSTOM_DEL "Removed Album Artist from selected files." // Removed Response
+
+
+
#define MAX_STRING_LEN 1024
***************
*** 104,107 ****
--- 116,120 ----
GtkWidget *URLEntry;
GtkWidget *EncodedByEntry;
+ GtkWidget *CustomEntry;
GtkWidget *PictureEntryView;
GtkListStore *PictureEntryModel;
***************
*** 120,123 ****
--- 133,137 ----
GtkWidget *URLLabel;
GtkWidget *EncodedByLabel;
+ GtkWidget *CustomLabel;
GtkWidget *PictureLabel;
// Mini buttons
***************
*** 137,140 ****
--- 151,155 ----
GtkWidget *URLMButton;
GtkWidget *EncodedByMButton;
+ GtkWidget *CustomMButton;
GtkWidget *PictureMButton;
diff -C 2 ./et_core.c ../easytag-2.1.6/src/et_core.c
*** ./et_core.c Sat May 17 21:29:32 2008
--- ../easytag-2.1.6/src/et_core.c Thu May 6 21:02:40 2010
***************
*** 390,393 ****
--- 390,394 ----
FileTag->url = NULL;
FileTag->encoded_by = NULL;
+ FileTag->custom = NULL;
FileTag->picture = NULL;
FileTag->other = NULL;
***************
*** 1000,1003 ****
--- 1001,1010 ----
etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Encoded_By);
break;
+ case SORTING_BY_ASCENDING_CUSTOM:
+ etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Custom);
+ break;
+ case SORTING_BY_DESCENDING_CUSTOM:
+ etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Custom);
+ break;
case SORTING_BY_ASCENDING_FILE_TYPE:
etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Type);
***************
*** 1608,1611 ****
--- 1615,1660 ----
}
+ /*
+ * Comparison function for sorting by ascending custom field.
+ */
+ gint ET_Comp_Func_Sort_File_By_Ascending_Custom (ET_File *ETFile1, ET_File *ETFile2)
+ {
+ // Compare pointers just in case they are the same (e.g. both are NULL)
+ if ((ETFile1->FileTag->data == ETFile2->FileTag->data)
+ || (((File_Tag *)ETFile1->FileTag->data)->custom == ((File_Tag *)ETFile2->FileTag->data)->custom))
+ return 0;
+
+ if ( !ETFile1->FileTag->data || !((File_Tag *)ETFile1->FileTag->data)->custom )
+ return -1;
+ if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->custom )
+ return 1;
+
+ if (SORTING_FILE_CASE_SENSITIVE)
+ {
+ if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->custom,((File_Tag *)ETFile2->FileTag->data)->custom) == 0 )
+ // Second criterion
+ return ET_Comp_Func_Sort_File_By_Ascending_Filename(ETFile1,ETFile2);
+ else
+ // First criterion
+ return strcmp(((File_Tag *)ETFile1->FileTag->data)->custom,((File_Tag *)ETFile2->FileTag->data)->custom);
+ }else
+ {
+ if ( strcasecmp(((File_Tag *)ETFile1->FileTag->data)->custom,((File_Tag *)ETFile2->FileTag->data)->custom) == 0 )
+ // Second criterion
+ return ET_Comp_Func_Sort_File_By_Ascending_Filename(ETFile1,ETFile2);
+ else
+ // First criterion
+ return strcasecmp(((File_Tag *)ETFile1->FileTag->data)->custom,((File_Tag *)ETFile2->FileTag->data)->custom);
+ }
+ }
+
+ /*
+ * Comparison function for sorting by descending custom field.
+ */
+ gint ET_Comp_Func_Sort_File_By_Descending_Custom (ET_File *ETFile1, ET_File *ETFile2)
+ {
+ return ET_Comp_Func_Sort_File_By_Ascending_Custom(ETFile2,ETFile1);
+ }
+
/*
***************
*** 2120,2123 ****
--- 2169,2173 ----
g_free(FileTag->url);
g_free(FileTag->encoded_by);
+ g_free(FileTag->custom);
Picture_Free(FileTag->picture);
// Free list of other fields
***************
*** 2386,2389 ****
--- 2436,2448 ----
}
+ if (FileTagCur->custom)
+ {
+ FileTag->custom = g_strdup(FileTagCur->custom);
+ }else
+ {
+ g_free(FileTag->custom);
+ FileTag->custom = NULL;
+ }
+
if (FileTagCur->picture)
{
***************
*** 2880,2883 ****
--- 2939,2951 ----
gtk_entry_set_text(GTK_ENTRY(EncodedByEntry),"");
+ /* Show custom field */
+ if (FileTag && FileTag->custom)
+ {
+ gchar *tmp = Try_To_Validate_Utf8_String(FileTag->custom);
+ gtk_entry_set_text(GTK_ENTRY(CustomEntry), tmp);
+ g_free(tmp);
+ }else
+ gtk_entry_set_text(GTK_ENTRY(CustomEntry),"");
+
/* Show picture */
PictureEntry_Clear();
***************
*** 3414,3417 ****
--- 3482,3497 ----
}
+ /* Custom Entry */
+ buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(CustomEntry)));
+ Strip_String(buffer);
+
+ if ( g_utf8_strlen(buffer, -1) > 0 )
+ FileTag->custom = buffer;
+ else
+ {
+ FileTag->custom = NULL;
+ g_free(buffer);
+ }
+
/* Picture */
{
***************
*** 3624,3627 ****
--- 3704,3718 ----
+ /* Custom Entry */
+ if ( FileTagCur->custom && g_utf8_strlen(FileTagCur->custom, -1)>0 )
+ {
+ FileTag->custom = g_strdup(FileTagCur->custom);
+ Strip_String(FileTag->custom);
+ } else
+ {
+ FileTag->custom = NULL;
+ }
+
+
/* Picture */
if(FileTagCur->picture)
***************
*** 3982,3985 ****
--- 4073,4081 ----
if ( FileTag1->encoded_by && FileTag2->encoded_by && g_utf8_collate(FileTag1->encoded_by,FileTag2->encoded_by)!=0 ) return TRUE;
+ /* Custom Entry */
+ if ( FileTag1->custom && !FileTag2->custom && g_utf8_strlen(FileTag1->custom, -1)>0 ) return TRUE;
+ if (!FileTag1->custom && FileTag2->custom && g_utf8_strlen(FileTag2->custom, -1)>0 ) return TRUE;
+ if ( FileTag1->custom && FileTag2->custom && g_utf8_collate(FileTag1->custom,FileTag2->custom)!=0 ) return TRUE;
+
/* Picture */
pic1 = FileTag1->picture;
***************
*** 4763,4766 ****
--- 4859,4863 ----
g_print("| |-> url : '%s'\n",((File_Tag *)filetaglist->data)->url ? ((File_Tag *)filetaglist->data)->url : "");
g_print("| |-> encoded_by : '%s'\n",((File_Tag *)filetaglist->data)->encoded_by ? ((File_Tag *)filetaglist->data)->encoded_by : "");
+ g_print("| |-> custom : '%s'\n",((File_Tag *)filetaglist->data)->custom ? ((File_Tag *)filetaglist->data)->custom : "");
filetaglist = filetaglist->next;
diff -C 2 ./et_core.h ../easytag-2.1.6/src/et_core.h
*** ./et_core.h Sat May 17 21:29:20 2008
--- ../easytag-2.1.6/src/et_core.h Thu May 6 20:26:11 2010
***************
*** 93,96 ****
--- 93,98 ----
SORTING_BY_ASCENDING_ENCODED_BY,
SORTING_BY_DESCENDING_ENCODED_BY,
+ SORTING_BY_ASCENDING_CUSTOM,
+ SORTING_BY_DESCENDING_CUSTOM,
SORTING_BY_ASCENDING_FILE_TYPE,
SORTING_BY_DESCENDING_FILE_TYPE,
***************
*** 194,197 ****
--- 196,200 ----
gchar *url; /* URL */
gchar *encoded_by; /* Encoded by */
+ gchar *custom; /* Custom */
Picture *picture; /* Picture */
GList *other; /* List of unsupported fields (used for ogg only) */
***************
*** 449,452 ****
--- 452,457 ----
gint ET_Comp_Func_Sort_File_By_Ascending_Encoded_By (ET_File *ETFile1, ET_File *ETFile2);
gint ET_Comp_Func_Sort_File_By_Descending_Encoded_By (ET_File *ETFile1, ET_File *ETFile2);
+ gint ET_Comp_Func_Sort_File_By_Ascending_Custom (ET_File *ETFile1, ET_File *ETFile2);
+ gint ET_Comp_Func_Sort_File_By_Descending_Custom (ET_File *ETFile1, ET_File *ETFile2);
gint ET_Comp_Func_Sort_File_By_Ascending_File_Type (ET_File *ETFile1, ET_File *ETFile2);
diff -C 2 ./flac_tag.c ../easytag-2.1.6/src/flac_tag.c
*** ./flac_tag.c Sat May 24 22:18:56 2008
--- ../easytag-2.1.6/src/flac_tag.c Thu May 6 20:56:21 2010
***************
*** 587,590 ****
--- 587,618 ----
}
+ /****************
+ * Custom field *
+ ****************/
+ field_num = 0;
+ while ( (field_num = FLAC__metadata_object_vorbiscomment_find_entry_from(block,field_num,CUSTOM_FLAC)) >= 0 )
+ {
+ /* Extract field value */
+ field = &vc->comments[field_num++];
+ field_value = memchr(field->entry, '=', field->length);
+
+ if (field_value)
+ {
+ field_value++;
+ if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+ {
+ field_len = field->length - (field_value - (gchar*) field->entry);
+ field_value_tmp = g_strndup(field_value, field_len);
+ field_value = Try_To_Validate_Utf8_String(field_value_tmp);
+ g_free(field_value_tmp);
+ if (FileTag->custom==NULL)
+ FileTag->custom = g_strdup(field_value);
+ else
+ FileTag->custom = g_strconcat(FileTag->custom,MULTIFIELD_SEPARATOR,field_value,NULL);
+ g_free(field_value);
+ }
+ }
+ }
+
/***************************
* Save unsupported fields *
***************
*** 607,611 ****
&& strncasecmp((gchar *)field->entry,"COPYRIGHT=", MIN(10, field->length)) != 0
&& strncasecmp((gchar *)field->entry,"LICENSE=", MIN(8, field->length)) != 0
! && strncasecmp((gchar *)field->entry,"ENCODED-BY=", MIN(11, field->length)) != 0 )
{
//g_print("custom %*s\n", field->length, field->entry);
--- 635,640 ----
&& strncasecmp((gchar *)field->entry,"COPYRIGHT=", MIN(10, field->length)) != 0
&& strncasecmp((gchar *)field->entry,"LICENSE=", MIN(8, field->length)) != 0
! && strncasecmp((gchar *)field->entry,"ENCODED-BY=", MIN(11, field->length)) != 0
! && strncasecmp((gchar *)field->entry,CUSTOM_FLAC"=", MIN(12, field->length)) != 0 )
{
//g_print("custom %*s\n", field->length, field->entry);
***************
*** 1031,1034 ****
--- 1060,1075 ----
}
+ /****************
+ * Custom field *
+ ****************/
+ if ( FileTag->custom )
+ {
+ string = g_strconcat(CUSTOM_FLAC"=",FileTag->custom,NULL);
+ field.entry = (FLAC__byte *)string;
+ field.length = strlen(string);
+ FLAC__metadata_object_vorbiscomment_insert_comment(vc_block,vc_block->data.vorbis_comment.num_comments,field,true);
+ g_free(string);
+ }
+
/**************************
Only in ../easytag-2.1.6/src: id3lib
diff -C 2 ./id3v24_tag.c ../easytag-2.1.6/src/id3v24_tag.c
*** ./id3v24_tag.c Sat Jul 12 14:32:12 2008
--- ../easytag-2.1.6/src/id3v24_tag.c Thu May 6 20:22:13 2010
***************
*** 367,370 ****
--- 367,376 ----
update |= libid3tag_Get_Frame_Str(frame, ~0, &FileTag->encoded_by);
+ /*******************************
+ * Custom Field *
+ *******************************/
+ if ( (frame = id3_tag_findframe(tag, CUSTOM_ID3, 0)) )
+ update |= libid3tag_Get_Frame_Str(frame, ~0, &FileTag->custom);
+
/* Encoded by in TXXX frames */
string1 = NULL;
Only in ../easytag-2.1.6/src: libapetag
Only in ../easytag-2.1.6/src: libmpg123
diff -C 2 ./ogg_tag.c ../easytag-2.1.6/src/ogg_tag.c
*** ./ogg_tag.c Sat May 24 21:58:38 2008
--- ../easytag-2.1.6/src/ogg_tag.c Thu May 6 20:33:34 2010
***************
*** 479,482 ****
--- 479,502 ----
+ /****************
+ * Custom *
+ ****************/
+ field_num = 0;
+ while ( (string = vorbis_comment_query(vc,CUSTOM_FLAC,field_num++)) != NULL )
+ {
+ string = Try_To_Validate_Utf8_String(string);
+
+ if ( g_utf8_strlen(string, -1) > 0 )
+ {
+ if (FileTag->encoded_by==NULL)
+ FileTag->encoded_by = g_strdup(string);
+ else
+ FileTag->encoded_by = g_strconcat(FileTag->custom,MULTIFIELD_SEPARATOR,string,NULL);
+ }
+
+ g_free(string);
+ }
+
+
/**************
* Picture *
Only in .: patch
diff -C 2 ./ui_manager.h ../easytag-2.1.6/src/ui_manager.h
*** ./ui_manager.h Sat Mar 22 21:22:17 2008
--- ../easytag-2.1.6/src/ui_manager.h Thu May 6 19:56:26 2010
***************
*** 53,56 ****
--- 53,59 ----
" <menuitem action='SortEncodedByDesc' />"
" <separator />"
+ " <menuitem action='SortCustomAsc' />"
+ " <menuitem action='SortCustomDesc' />"
+ " <separator />"
" </menu>"
Only in ../easytag-2.1.6/src: win32
Intro
This patch allows you to add a custom field in Easytag v2.1.6.
By default, the fields are "TPE2" for id3v2 (mp3) and "ALBUMARTIST" for Flac files.
I have not tested other formats so you're on your own ;-)
First time I publish some code on the web so if it does not work, let me know.
Prereq - GCC and build environment in place. You need to be able to build easytag clean before applying the patch.
In linux, make a directory in your home and extract easytag-2.1.6.tar.bz2 here.
mkdir easytag
# cd easytag
# tar -jxvf <path>/easytag-2.1.6.tar.bz2
now go into the cd easytag-2.1.6/src directory
# cd easytag-2.1.6/src
Patch using the patch file
# patch -p1 < <path>/easytag-216-customfieldpatch
patching file bar.c
patching file bar.h
patching file browser.c
patching file browser.h
patching file easytag.c
patching file easytag.h
patching file et_core.c
patching file et_core.h
patching file flac_tag.c
patching file id3v24_tag.c
patching file ogg_tag.c
patching file ui_manager.h
#
now go to the easytag-2.1.6 dir (one level up)
# cd ..
# pwd
<yourdir>/easytag-2.1.6
Run the configure script. The output should look something like the example. At least it should show "yes" for FLAC and MP3 support.
# ./configure
Configuration for easytag 2.1.6 :
--------------------------------
Source code location ....: .
Host System Type ........: i686-pc-linux-gnu
Preprocessor ............: gcc
Compiler ................: gcc -g -O2 -Wall
Linker ..................: gcc -lwavpack -lm -lmp4v2 -lm -lz -lstdc++ -lid3 -lid3tag -lFLAC -lm -lspeex -lm -lvorbisfile -lvorbis -logg -lm
GTK2 version ............: 2.16.1
MP3 file support ........: yes
ID3v2.3 tags support ....: yes (id3lib-3.8.3)
Ogg Vorbis file support .: yes
Speex file support ......: yes
FLAC file support .......: yes (flac-1.2.1)
MP4 file support ........: yes (mpeg4ip-1.6)
WavPack support .........: yes
NLS/gettext .............: yes
Install path ............: /usr/local
Now make the binaries
# make
If all is correct, make finishes with some warnings without errors. You can see if it works by checking if
the "easytag" executable is in the src directory
# ls -l src/easytag
The file should be there with the current date.
You can try to run it before installing (make sure your X window environment is set):
# src/easytag
If all is OK you can do an install:
# make install
All should work now!
Note that maybe you have to remove or rename the original "easytag" package from your computer to prevent running the non-patched version.
Changing the custom field
If you don't want Album Artist as a custom tag but something else, go into the src directory and edit easytag.h
There are a few #defines that you can change:
#define CUSTOM_LABEL "Album Artist:" // Field name
#define CUSTOM_TITLE "Alb.Artist" // Browser name
#define CUSTOM_FLAC "ALBUMARTIST" // FLAC Comment
#define CUSTOM_ID3 "TPE2" // ID3v2 TAG
#define SORT_ASC "Ascending by Album Artist" // Ascending description
#define SORT_DESC "Descending by Album Artist" // Descending description
#define CUSTOM_HINT "Tag selected files with this Album Artist name" // Hint
#define CUSTOM_RESP "Selected files tagged with Album Artist " // Response
#define CUSTOM_DEL "Removed Album Artist from selected files." // Removed Response
The lines speak for themselves. Make sure you only enter valid entries because otherwise easytag might screw up your metadata.
Test before using it on your music collection (needles to say: backup...)
I only tested it with ALBUMARTIST and TPE2 and I think it only works with tags that contain strings.
Not sure if it works with numbers or other fields - but feel free to try :-)
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]