[easytag/wip/musicbrainz-support-merge: 64/75] Apply TAGs add Composer Tags



commit 3932c2371941b8bba0acea6291fc7ba7064b79f2
Author: Abhinav <abhijangda hotmail com>
Date:   Fri Aug 15 01:01:33 2014 +0530

    Apply TAGs add Composer Tags

 src/mb_search.c          |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 src/mb_search.h          |    2 +
 src/musicbrainz_dialog.c |   34 +++++++++++++++++++++-------
 3 files changed, 82 insertions(+), 9 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
index 9971b25..17cfa7b 100755
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -34,6 +34,7 @@
 static gchar *server = NULL;
 static int port = 0;
 
+#define COMPOSER_STR "composer"
 #define USER_AGENT PACKAGE_NAME"/"PACKAGE_VERSION" ( "PACKAGE_URL" ) "
 #define CHECK_CANCELLED(cancellable) if (g_cancellable_is_cancelled (cancellable))\
                                      {\
@@ -117,6 +118,60 @@ et_mb5_recording_get_artists_names (Mb5Recording recording)
 }
 
 /*
+ * et_mb5_recording_get_composers:
+ * @recording: Mb5Recording
+ *
+ * Get composers for a recording.
+ *
+ * Returns: A string containing composers.
+ */
+gchar *
+et_mb5_recording_get_composers (Mb5Recording recording)
+{
+    Mb5RelationListList relation_lists;
+    int i;
+    int j;
+    GString *composers;
+    
+    composers = g_string_new ("");
+    relation_lists = mb5_recording_get_relationlistlist (recording);
+    
+    for (i = 0; i < mb5_relationlist_list_size (relation_lists); i++)
+    {
+        Mb5RelationList relation_list;
+        
+        relation_list = mb5_relationlist_list_item (relation_lists, i);
+        
+        for (j = 0; j < mb5_relation_list_size (relation_list); j++)
+        {
+            Mb5Relation relation;
+            Mb5Artist artist;
+            gchar name[NAME_MAX_SIZE];
+
+            relation = mb5_relation_list_item (relation_list, j);
+            artist = mb5_relation_get_artist (relation);
+            mb5_relation_get_type (relation, name, sizeof (name));
+
+            if (g_strcmp0 (name, COMPOSER_STR))
+            {
+                continue;
+            }
+
+            mb5_artist_get_name (artist, name, sizeof (name));
+            
+            if (!(*composers->str))
+            {
+                g_string_append (composers, ", ");
+            }
+        
+            g_string_append (composers, name);
+        }
+    }
+
+    return g_string_free (composers, FALSE);
+}
+
+/*
  * et_mb5_release_get_artists_names:
  * @release: Mb5Release
  *
diff --git a/src/mb_search.h b/src/mb_search.h
index 1b2318c..6b1dc30 100755
--- a/src/mb_search.h
+++ b/src/mb_search.h
@@ -125,6 +125,8 @@ gchar *
 et_mb5_release_get_artists_names (Mb5Release release);
 gchar *
 et_mb5_recording_get_artists_names (Mb5Recording recording);
+gchar *
+et_mb5_recording_get_composers (Mb5Recording recording);
 int
 et_mb5_recording_get_medium_track_for_release (Mb5Release release,
                                                int **discids, int **trackids,
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 6a6a8b8..6238cc8 100755
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -70,6 +70,7 @@ enum TagChoiceColumns
     TAG_CHOICE_DISC_TOTAL,
     TAG_CHOICE_TRACK_NUMBER,
     TAG_CHOICE_TRACK_TOTAL,
+    TAG_CHOICE_COMPOSERS,
     TAG_CHOICE_COLS_N
 };
 
@@ -308,7 +309,7 @@ static void
 et_set_file_tag (ET_File *et_file, gchar *title, gchar *artist,
                  gchar *album, gchar *album_artist, gchar *date,
                  gchar *country, gchar *disc, gchar *track,
-                 gchar *disc_total, gchar *track_total);
+                 gchar *disc_total, gchar *track_total, gchar *composer);
 static void
 btn_apply_changes_clicked (GtkWidget *widget, gpointer data);
 static void
@@ -1710,7 +1711,7 @@ static void
 et_set_file_tag (ET_File *et_file, gchar *title, gchar *artist,
                  gchar *album, gchar *album_artist, gchar *date,
                  gchar *country, gchar *disc, gchar *track,
-                 gchar *disc_total, gchar *track_total)
+                 gchar *disc_total, gchar *track_total, gchar *composer)
 {
     File_Tag *file_tag;
 
@@ -1725,7 +1726,7 @@ et_set_file_tag (ET_File *et_file, gchar *title, gchar *artist,
     ET_Set_Field_File_Tag_Item (&file_tag->disc_total, disc_total);
     ET_Set_Field_File_Tag_Item (&file_tag->track, track);
     ET_Set_Field_File_Tag_Item (&file_tag->disc_number, disc);
-    printf ("%s %s\n", track_total, disc_total);
+    ET_Set_Field_File_Tag_Item (&file_tag->composer, composer);
     ET_Manage_Changes_Of_File_Data (et_file, NULL, file_tag);
     ET_Display_File_Data_To_UI (ETCore->ETFileDisplayed);
 }
@@ -1891,6 +1892,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
     gchar *track;
     gchar *track_total;
     gchar *disc_total;
+    gchar *composers;
     GtkTreeIter iter;
     GtkTreeSelection *selection;
     GtkWidget *tag_choice_tree_view;
@@ -1917,7 +1919,8 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
     title[size] = '\0';
     size = mb5_release_list_size (release_list);
     release = NULL;
-
+    composers = et_mb5_recording_get_composers (recording);
+    
     if (album_entity)
     {
         gchar id[NAME_MAX_SIZE];
@@ -1964,7 +1967,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
             et_set_file_tag (et_file, title, artist,
                              album, album_artist,
                              date, country, disc, track,
-                             disc_total, track_total);
+                             disc_total, track_total, composers);
             g_free (discids);
             g_free (trackids);
             g_free (disc);
@@ -1977,11 +1980,12 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
         {
             et_set_file_tag (et_file, title, artist,
                              album, album_artist,
-                             date, country, "", "", "", "");
+                             date, country, "", "", "", "", composers);
         }
 
         g_free (album_artist);
         g_free (artist);
+        g_free (composers);
 
         return TRUE;
     }
@@ -2024,6 +2028,8 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
                                                    track,
                                                    TAG_CHOICE_TRACK_TOTAL,
                                                    track_total,
+                                                   TAG_CHOICE_COMPOSERS,
+                                                   composers
                                                    -1);
                 g_free (disc_total);
                 g_free (track_total);
@@ -2035,6 +2041,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
             g_free (trackids);    
             g_free (album_artist);
             g_free (track_count);
+            g_free (composers);
         }
 
         gtk_widget_set_size_request (mb_dialog_priv->tag_choice_dialog,
@@ -2079,7 +2086,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
             et_set_file_tag (et_file, title, artist,
                              ret_album, ret_album_artist,
                              ret_date, ret_country, disc, track, disc_total, 
-                             track_total);
+                             track_total, composers);
             g_free (ret_album);
             g_free (ret_album_artist);
             g_free (ret_date);
@@ -2089,6 +2096,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
             g_free (track_total);
             g_free (disc);
             g_free (track);
+            g_free (composers);
     
             gtk_widget_hide (mb_dialog_priv->tag_choice_dialog);
             gtk_list_store_clear (GTK_LIST_STORE (mb_dialog_priv->tag_choice_store));
@@ -2098,7 +2106,7 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, EtMbEntity *album_entity,
         else
         {
             g_free (artist);
-    
+            g_free (composers);
             gtk_widget_hide (mb_dialog_priv->tag_choice_dialog);
             gtk_list_store_clear (GTK_LIST_STORE (mb_dialog_priv->tag_choice_store));
     
@@ -2160,7 +2168,7 @@ et_initialize_tag_choice_dialog (EtMusicBrainzDialogPrivate *mb_dialog_priv)
                                      G_TYPE_STRING, G_TYPE_STRING,
                                      G_TYPE_STRING, G_TYPE_STRING,
                                      G_TYPE_STRING, G_TYPE_STRING,
-                                     G_TYPE_STRING);
+                                     G_TYPE_STRING, G_TYPE_STRING);
     mb_dialog_priv->tag_choice_store = GTK_TREE_MODEL (list_store);
     gtk_tree_view_set_model (GTK_TREE_VIEW (tag_choice_list),
                              mb_dialog_priv->tag_choice_store);
@@ -2245,6 +2253,14 @@ et_initialize_tag_choice_dialog (EtMusicBrainzDialogPrivate *mb_dialog_priv)
                                                        NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (tag_choice_list),
                                  column);
+    
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes ("Composer",
+                                                       renderer, "text",
+                                                       TAG_CHOICE_COMPOSERS,
+                                                       NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (tag_choice_list),
+                                 column);
 }
 
 gboolean


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