Commit 9aad89da authored by David King's avatar David King

Refactor File_Tag copying functions

Change functions which accept ET_File for the purposes of copying a
File_Tag struct to instead use the File_Tag directly. Move the
declarations to file_tag.h.
parent 5068f653
/* EasyTAG - Tag editor for audio files
* Copyright (C) 2014,2015 David King <amigadave@amigadave.com>
* Copyright (C) 2000-2003 Jerome Couderc <easytag@gmail.com>
* Copyright (C) 2014 David King <amigadave@amigadave.com>
*
* 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
......@@ -2364,7 +2364,7 @@ Cddb_Set_Track_Infos_To_File_List (EtCDDBDialog *self)
{
/* Allocation of a new FileTag. */
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item (etfile, FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
if (set_fields & ET_CDDB_SET_FIELD_TITLE)
{
......@@ -2493,7 +2493,7 @@ Cddb_Set_Track_Infos_To_File_List (EtCDDBDialog *self)
{
/* Allocation of a new FileTag. */
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item (etfile, FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
if (set_fields & ET_CDDB_SET_FIELD_TITLE)
{
......
/* EasyTAG - tag editor for audio files
* Copyright (C) 2014 David King <amigadave@amigadave.com>
* Copyright (C) 2014,2015 David King <amigadave@amigadave.com>
*
* 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
......@@ -1438,7 +1438,7 @@ void ET_Save_File_Data_From_UI (ET_File *ETFile)
#endif
case APE_TAG:
FileTag = et_application_window_tag_area_create_file_tag (ET_APPLICATION_WINDOW (MainWindow));
ET_Copy_File_Tag_Item_Other_Field (ETFile, FileTag);
et_file_tag_copy_other_into (ETFile->FileTag->data, FileTag);
break;
case UNKNOWN_TAG:
default:
......
/* EasyTAG - tag editor for audio files
* Copyright (C) 2014 David King <amigadave@amigadave.com>
* Copyright (C) 2014,2015 David King <amigadave@amigadave.com>
*
* 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
......@@ -81,10 +81,6 @@ void ET_Free_File_List_Item (ET_File *ETFile);
gboolean ET_Set_Filename_File_Name_Item (File_Name *FileName, const gchar *filename_utf8, const gchar *filename);
/* FIXME: Move to file_tag.h. */
gboolean ET_Copy_File_Tag_Item (const ET_File *ETFile, File_Tag *FileTag);
void ET_Copy_File_Tag_Item_Other_Field (const ET_File *ETFile, File_Tag *FileTag);
void ET_Display_File_Data_To_UI (ET_File *ETFile);
void ET_Save_File_Data_From_UI (ET_File *ETFile);
gboolean ET_Save_File_Name_Internal (const ET_File *ETFile, File_Name *FileName);
......
......@@ -18,7 +18,7 @@
#include "file_tag.h"
#include "et_core.h"
#include "file.h"
/*
* Create a new File_Tag structure.
......@@ -78,21 +78,18 @@ et_file_tag_free (File_Tag *FileTag)
* Duplicate the 'other' list
*/
void
ET_Copy_File_Tag_Item_Other_Field (const ET_File *ETFile,
File_Tag *FileTag)
et_file_tag_copy_other_into (File_Tag *destination,
const File_Tag *source)
{
const File_Tag *FileTagCur;
GList *l;
FileTagCur = (File_Tag *)(ETFile->FileTag)->data;
for (l = FileTagCur->other; l != NULL; l = g_list_next (l))
for (l = source->other; l != NULL; l = g_list_next (l))
{
FileTag->other = g_list_prepend (FileTag->other,
g_strdup ((gchar *)l->data));
destination->other = g_list_prepend (destination->other,
g_strdup ((gchar *)l->data));
}
FileTag->other = g_list_reverse (FileTag->other);
destination->other = g_list_reverse (destination->other);
}
......@@ -100,19 +97,15 @@ ET_Copy_File_Tag_Item_Other_Field (const ET_File *ETFile,
* Copy data of the File_Tag structure (of ETFile) to the FileTag item.
* Reallocate data if not null.
*/
gboolean
ET_Copy_File_Tag_Item (const ET_File *ETFile, File_Tag *destination)
void
et_file_tag_copy_into (File_Tag *destination,
const File_Tag *source)
{
const File_Tag *source;
g_return_if_fail (source != NULL);
g_return_if_fail (destination != NULL);
g_return_val_if_fail (ETFile != NULL && ETFile->FileTag != NULL &&
(File_Tag *)(ETFile->FileTag)->data != NULL, FALSE);
g_return_val_if_fail (destination != NULL, FALSE);
/* The data to duplicate to FileTag */
source = (File_Tag *)(ETFile->FileTag)->data;
/* Key for the item, may be overwritten. */
destination->key = ET_Undo_Key_New();
destination->key = ET_Undo_Key_New ();
et_file_tag_set_title (destination, source->title);
et_file_tag_set_artist (destination, source->artist);
......@@ -134,14 +127,12 @@ ET_Copy_File_Tag_Item (const ET_File *ETFile, File_Tag *destination)
if (source->other)
{
ET_Copy_File_Tag_Item_Other_Field (ETFile, destination);
et_file_tag_copy_other_into (destination, source);
}
else
{
et_file_tag_free_other_field (destination);
}
return TRUE;
}
/*
......
......@@ -96,6 +96,9 @@ void et_file_tag_set_url (File_Tag *file_tag, const gchar *url);
void et_file_tag_set_encoded_by (File_Tag *file_tag, const gchar *encoded_by);
void et_file_tag_set_picture (File_Tag *file_tag, const EtPicture *pic);
void et_file_tag_copy_into (File_Tag *destination, const File_Tag *source);
void et_file_tag_copy_other_into (File_Tag *destination, const File_Tag *source);
gboolean et_file_tag_detect_difference (const File_Tag *FileTag1, const File_Tag *FileTag2);
G_END_DECLS
......
/* EasyTAG - Tag editor for audio files
* Copyright (C) 2014 David King <amigadave@amigadave.com>
* Copyright (C) 2014,2014 David King <amigadave@amigadave.com>
* Copyright (C) 2000-2003 Jerome Couderc <easytag@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -349,7 +349,7 @@ Scan_Tag_With_Mask (EtScanDialog *self, ET_File *ETFile)
// Create a new File_Tag item
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
// Process this mask with file
fill_tag_list = Scan_Generate_New_Tag_From_Mask(ETFile,mask);
......@@ -1357,7 +1357,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->title);
......@@ -1376,7 +1376,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->artist);
......@@ -1395,7 +1395,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->album_artist);
......@@ -1414,7 +1414,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->album);
......@@ -1433,7 +1433,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->genre);
......@@ -1452,7 +1452,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->comment);
......@@ -1471,7 +1471,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->composer);
......@@ -1490,7 +1490,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->orig_artist);
......@@ -1509,7 +1509,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->copyright);
......@@ -1528,7 +1528,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->url);
......@@ -1547,7 +1547,7 @@ Scan_Process_Fields (EtScanDialog *self, ET_File *ETFile)
if (!FileTag)
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(ETFile,FileTag);
et_file_tag_copy_into (FileTag, ETFile->FileTag->data);
}
string = g_strdup(st_filetag->encoded_by);
......
/* EasyTAG - tag editor for audio files
* Copyright (C) 2014 David King <amigadave@amigadave.com>
* Copyright (C) 2014,2015 David King <amigadave@amigadave.com>
*
* 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
......@@ -177,7 +177,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_title (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -199,7 +199,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -220,7 +220,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_album_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -242,7 +242,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_album (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -280,7 +280,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_disc_number (FileTag, string_to_set);
et_file_tag_set_disc_total (FileTag, string_to_set1);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
......@@ -312,7 +312,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_year (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -336,7 +336,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
// We apply the TrackEntry field to all others files only if it is to delete
// the field (string=""). Else we don't overwrite the track number
......@@ -403,7 +403,7 @@ on_apply_to_selection (GObject *object,
if ( (ET_File *)etfilelistfull->data == etfile )
{
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_track_number (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
......@@ -440,7 +440,7 @@ on_apply_to_selection (GObject *object,
string_to_set1 = g_strdup(string_to_set); // Just for the message below...
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_track_total (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -463,7 +463,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_genre (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -492,7 +492,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_comment (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -513,7 +513,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_composer (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -535,7 +535,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_orig_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -557,7 +557,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_copyright (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -579,7 +579,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_url (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -601,7 +601,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_encoded_by (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......@@ -641,7 +641,7 @@ on_apply_to_selection (GObject *object,
{
etfile = (ET_File *)l->data;
FileTag = et_file_tag_new ();
ET_Copy_File_Tag_Item(etfile,FileTag);
et_file_tag_copy_into (FileTag, etfile->FileTag->data);
et_file_tag_set_picture (FileTag, res);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment