[easytag/wip/disc-number: 2/8] WIP Added support for "total number of discs"



commit f6b894c37ffe41a99c15c119e22d16886624c45d
Author: Mathias Reineke <saihtam gmx net>
Date:   Mon Jul 8 10:50:00 2013 +0200

    WIP Added support for "total number of discs"
    
    Split into different commit: Additionally, add autonumbering of "disc"
    (using folders to determine to which disc a file belongs; equivalent to
    "track autonumbering").
    
    Cut out UI changes and instead automatically format numbers from the
    entry field.

 src/browser.c  |   24 +++-
 src/easytag.c  |  372 ++++++++++++++++++++++++++++++++++++++++++++------------
 src/easytag.h  |    6 +-
 src/et_core.c  |   75 +++++++++++-
 src/et_core.h  |    1 +
 src/flac_tag.c |    2 +
 src/misc.c     |   83 +++++++++++--
 src/misc.h     |    1 +
 8 files changed, 469 insertions(+), 95 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 34ff580..96576b6 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -221,9 +221,10 @@ common_init (GApplication *application)
     Init_OptionsWindow();
     Init_ScannerWindow();
     Init_CddbWindow();
-    BrowserEntryModel    = NULL;
+    BrowserEntryModel = NULL;
     TrackEntryComboModel = NULL;
-    GenreComboModel      = NULL;
+    DiscNumberEntryComboModel = NULL;
+    GenreComboModel = NULL;
 
     /* The main window */
     MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -710,7 +711,6 @@ Create_File_Area (void)
 static GtkWidget *
 Create_Tag_Area (void)
 {
-    GtkWidget *Separator;
     GtkWidget *Table;
     GtkWidget *Label;
     GtkWidget *Icon;
@@ -732,6 +732,8 @@ Create_Tag_Area (void)
     GtkTreeViewColumn *column;
     GtkTreeSelection *selection;
 
+    // for positioning within the Table
+    int row = 0;
 
     /* Main Frame */
     TagFrame = gtk_frame_new(_("Tag"));
@@ -763,15 +765,16 @@ Create_Tag_Area (void)
     gtk_container_set_border_width(GTK_CONTAINER(Table),2);
 
     /* Title */
+    row = 0;
     TitleLabel = gtk_label_new(_("Title:"));
-    et_grid_attach_full (GTK_GRID (Table), TitleLabel, 0, 0, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), TitleLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(TitleLabel),1,0.5);
 
     TitleEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (TitleEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), TitleEntry, 1, 0, 9, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), TitleEntry, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (TitleEntry));
@@ -782,15 +785,16 @@ Create_Tag_Area (void)
     Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(TitleEntry));
 
     /* Artist */
+    row++;
     ArtistLabel = gtk_label_new(_("Artist:"));
-    et_grid_attach_full (GTK_GRID (Table), ArtistLabel, 0, 1, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), ArtistLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(ArtistLabel),1,0.5);
 
     ArtistEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (ArtistEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), ArtistEntry, 1, 1, 9, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), ArtistEntry, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding,TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (ArtistEntry));
@@ -801,15 +805,16 @@ Create_Tag_Area (void)
     Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(ArtistEntry));
 
     /* Album Artist */
+    row++;
     AlbumArtistLabel = gtk_label_new(_("Album artist:"));
-    et_grid_attach_full (GTK_GRID (Table), AlbumArtistLabel, 0, 2, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), AlbumArtistLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(AlbumArtistLabel),1,0.5);
 
     AlbumArtistEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (AlbumArtistEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), AlbumArtistEntry, 1, 2, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), AlbumArtistEntry, 1, row, 9, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (AlbumArtistEntry));
@@ -820,15 +825,16 @@ Create_Tag_Area (void)
     Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(AlbumArtistEntry));
 
     /* Album */
+    row++;
     AlbumLabel = gtk_label_new(_("Album:"));
-    et_grid_attach_full (GTK_GRID (Table), AlbumLabel, 0, 3, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), AlbumLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(AlbumLabel),1,0.5);
 
     AlbumEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (AlbumEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), AlbumEntry, 1, 3, 6, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), AlbumEntry, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding,TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (AlbumEntry));
@@ -838,31 +844,10 @@ Create_Tag_Area (void)
 
     Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(AlbumEntry));
 
-    /* Disc Number */
-    DiscNumberLabel = gtk_label_new(_("CD:"));
-    et_grid_attach_full (GTK_GRID (Table), DiscNumberLabel, 8, 3, 1, 1, FALSE,
-                         FALSE, TablePadding, TablePadding);
-    gtk_misc_set_alignment(GTK_MISC(DiscNumberLabel),1,0.5);
-
-    DiscNumberEntry = gtk_entry_new();
-    gtk_entry_set_icon_from_icon_name (GTK_ENTRY (DiscNumberEntry),
-                                       GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), DiscNumberEntry, 9, 3, 1, 1, TRUE,
-                         TRUE, TablePadding, TablePadding);
-    gtk_entry_set_width_chars (GTK_ENTRY (DiscNumberEntry), 3);
-    /* FIXME should allow to type only something like : 1/3. */
-    
/*g_signal_connect(G_OBJECT(GTK_ENTRY(DiscNumberEntry)),"insert_text",G_CALLBACK(Insert_Only_Digit),NULL); */
-
-    et_tag_field_connect_signals (GTK_ENTRY (DiscNumberEntry));
-    gtk_entry_set_icon_tooltip_text (GTK_ENTRY (DiscNumberEntry),
-                                     GTK_ENTRY_ICON_SECONDARY,
-                                     _("Tag selected files with this disc number"));
-
-    Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(DiscNumberEntry));
-
     /* Year */
+    row++;
     YearLabel = gtk_label_new(_("Year:"));
-    et_grid_attach_full (GTK_GRID (Table), YearLabel, 0, 4, 1, 1, FALSE, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), YearLabel, 0, row, 1, 1, FALSE, FALSE,
                          TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(YearLabel),1,0.5);
 
@@ -870,7 +855,7 @@ Create_Tag_Area (void)
     gtk_entry_set_max_length(GTK_ENTRY(YearEntry), 4);
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (YearEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), YearEntry, 1, 4, 1, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), YearEntry, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding, TablePadding);
     gtk_entry_set_width_chars (GTK_ENTRY (YearEntry), 5);
     g_signal_connect (G_OBJECT (YearEntry), "insert-text",
@@ -883,16 +868,86 @@ Create_Tag_Area (void)
                                      GTK_ENTRY_ICON_SECONDARY,
                                      _("Tag selected files with this year"));
 
-    /* Small vertical separator */
-    Separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
-    et_grid_attach_full (GTK_GRID (Table), Separator, 3, 4, 1, 1, FALSE, FALSE,
-                         TablePadding,TablePadding);
+    /* Disc Number */
+    row++;
+    DiscNumberLabel = gtk_label_new(_("CD:"));
+    et_grid_attach_full(GTK_GRID (Table), DiscNumberLabel, 0, row, 1, 1, FALSE,
+            FALSE, TablePadding, TablePadding);
+    gtk_misc_set_alignment(GTK_MISC(DiscNumberLabel),1,0.5);
+
+
+    DiscNumberMButtonSequence = gtk_button_new();
+    gtk_widget_set_size_request(DiscNumberMButtonSequence,MButtonSize,MButtonSize);
+    et_grid_attach_full (GTK_GRID (Table), DiscNumberMButtonSequence, 1, row, 1, 1,
+                         FALSE, FALSE, TablePadding, TablePadding);
+    g_signal_connect(G_OBJECT(DiscNumberMButtonSequence),"clicked",G_CALLBACK(Mini_Button_Clicked),NULL);
+    gtk_widget_set_tooltip_text(DiscNumberMButtonSequence,_("Number the disc of selected tracks 
sequentially. The number will be incremented for each folder found in the selected directory."));
+    // Pixmap into DiscNumberMButtonSequence button
+    Icon = Create_Xpm_Image((const char **)sequence_track_xpm);
+    gtk_container_add(GTK_CONTAINER(DiscNumberMButtonSequence),Icon);
+    gtk_widget_set_can_default(DiscNumberMButtonSequence,TRUE); // To have enough space to display the icon
+    gtk_widget_set_can_focus(DiscNumberMButtonSequence,FALSE);   // To have enough space to display the icon
+
+    if (DiscNumberEntryComboModel != NULL) {
+               gtk_list_store_clear(DiscNumberEntryComboModel);
+    }
+    else
+       DiscNumberEntryComboModel = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
+
+    DiscNumberEntryCombo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(DiscNumberEntryComboModel));
+    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(DiscNumberEntryCombo),MISC_COMBO_TEXT);
+    et_grid_attach_full (GTK_GRID (Table), DiscNumberEntryCombo, 2, row, 1, 1, TRUE,
+                         TRUE, TablePadding, TablePadding);
+    gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(DiscNumberEntryCombo),3); // Three columns to display track 
numbers list
+
+    gtk_entry_set_width_chars (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (DiscNumberEntryCombo))),
+                               2);
+    g_signal_connect(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo)))),"insert_text",
+        G_CALLBACK(Insert_Only_Digit),NULL);
+
+
+    Label = gtk_label_new("/");
+    et_grid_attach_full (GTK_GRID (Table), Label, 3, row, 1, 1, FALSE, FALSE,
+                         TablePadding, TablePadding);
+    gtk_misc_set_alignment(GTK_MISC(Label),0.5,0.5);
+
+
+    DiscNumberMButtonNbrFolders = gtk_button_new();
+    gtk_widget_set_size_request(DiscNumberMButtonNbrFolders,MButtonSize,MButtonSize);
+    et_grid_attach_full (GTK_GRID (Table), DiscNumberMButtonNbrFolders, 4, row, 1, 1,
+                         FALSE, FALSE, TablePadding, TablePadding);
+    g_signal_connect(G_OBJECT(DiscNumberMButtonNbrFolders),"clicked",G_CALLBACK(Mini_Button_Clicked),NULL);
+    gtk_widget_set_tooltip_text(DiscNumberMButtonNbrFolders,_("Set the number of folders, in the selected 
directory, to the selected tracks."));
+    // Pixmap into DiscNumberMButtonNbrFolders button
+    Icon = Create_Xpm_Image((const char **)sequence_track_xpm);
+    gtk_container_add(GTK_CONTAINER(DiscNumberMButtonNbrFolders),Icon);
+    gtk_widget_set_can_default(DiscNumberMButtonNbrFolders,TRUE); // To have enough space to display the icon
+    gtk_widget_set_can_focus(DiscNumberMButtonNbrFolders,FALSE); // To have enough space to display the icon
+
+    DiscNumberTotalEntry = gtk_entry_new();
+    gtk_entry_set_icon_from_icon_name (GTK_ENTRY (DiscNumberTotalEntry),
+                                       GTK_ENTRY_ICON_SECONDARY, "insert-text");
+    et_grid_attach_full (GTK_GRID (Table), DiscNumberTotalEntry, 5, row, 1, 1, TRUE,
+                         TRUE, TablePadding, TablePadding);
+    gtk_entry_set_width_chars (GTK_ENTRY (DiscNumberTotalEntry), 3);
+    g_signal_connect (G_OBJECT (GTK_ENTRY (DiscNumberTotalEntry)), "insert-text",
+                      G_CALLBACK (Insert_Only_Digit), NULL);
 
+    et_tag_field_connect_signals (GTK_ENTRY (DiscNumberTotalEntry));
+    gtk_entry_set_icon_tooltip_text (GTK_ENTRY (DiscNumberTotalEntry),
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     _("Tag selected files with this disc number"));
 
     /* Track and Track total */
+    row++;
+    TrackLabel = gtk_label_new(_("Track #:"));
+    et_grid_attach_full (GTK_GRID (Table), TrackLabel, 0, row, 1, 1, FALSE,
+                         FALSE, TablePadding, TablePadding);
+    gtk_misc_set_alignment(GTK_MISC(TrackLabel),1,0.5);
+
     TrackMButtonSequence = gtk_button_new();
     gtk_widget_set_size_request(TrackMButtonSequence,MButtonSize,MButtonSize);
-    et_grid_attach_full (GTK_GRID (Table), TrackMButtonSequence, 4, 4, 1, 1,
+    et_grid_attach_full (GTK_GRID (Table), TrackMButtonSequence, 1, row, 1, 1,
                          FALSE, FALSE, TablePadding, TablePadding);
     g_signal_connect(G_OBJECT(TrackMButtonSequence),"clicked",G_CALLBACK(Mini_Button_Clicked),NULL);
     gtk_widget_set_tooltip_text(TrackMButtonSequence,_("Number selected tracks sequentially. "
@@ -904,10 +959,6 @@ Create_Tag_Area (void)
     gtk_widget_set_can_default(TrackMButtonSequence,TRUE); // To have enough space to display the icon
     gtk_widget_set_can_focus(TrackMButtonSequence,FALSE);   // To have enough space to display the icon
 
-    TrackLabel = gtk_label_new(_("Track #:"));
-    et_grid_attach_full (GTK_GRID (Table), TrackLabel, 5, 4, 1, 1, FALSE,
-                         FALSE, TablePadding, TablePadding);
-    gtk_misc_set_alignment(GTK_MISC(TrackLabel),1,0.5);
 
     if (TrackEntryComboModel != NULL)
         gtk_list_store_clear(TrackEntryComboModel);
@@ -916,7 +967,7 @@ Create_Tag_Area (void)
 
     TrackEntryCombo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(TrackEntryComboModel));
     gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(TrackEntryCombo),MISC_COMBO_TEXT);
-    et_grid_attach_full (GTK_GRID (Table), TrackEntryCombo, 6, 4, 1, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), TrackEntryCombo, 2, row, 1, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
     gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(TrackEntryCombo),3); // Three columns to display track 
numbers list
 
@@ -926,13 +977,13 @@ Create_Tag_Area (void)
         G_CALLBACK(Insert_Only_Digit),NULL);
 
     Label = gtk_label_new("/");
-    et_grid_attach_full (GTK_GRID (Table), Label, 7, 4, 1, 1, FALSE, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), Label, 3, row, 1, 1, FALSE, FALSE,
                          TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(Label),0.5,0.5);
 
     TrackMButtonNbrFiles = gtk_button_new();
     gtk_widget_set_size_request(TrackMButtonNbrFiles,MButtonSize,MButtonSize);
-    et_grid_attach_full (GTK_GRID (Table), TrackMButtonNbrFiles, 8, 4, 1, 1,
+    et_grid_attach_full (GTK_GRID (Table), TrackMButtonNbrFiles, 4, row, 1, 1,
                          FALSE, FALSE, TablePadding, TablePadding);
     g_signal_connect(G_OBJECT(TrackMButtonNbrFiles),"clicked",G_CALLBACK(Mini_Button_Clicked),NULL);
     gtk_widget_set_tooltip_text(TrackMButtonNbrFiles,_("Set the number of files, in the same directory of 
the displayed file, to the selected tracks."));
@@ -946,7 +997,7 @@ Create_Tag_Area (void)
     TrackTotalEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (TrackTotalEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), TrackTotalEntry, 9, 4, 1, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), TrackTotalEntry, 5, row, 1, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
     gtk_entry_set_width_chars (GTK_ENTRY (TrackTotalEntry), 3);
     g_signal_connect (G_OBJECT (GTK_ENTRY (TrackTotalEntry)), "insert-text",
@@ -959,8 +1010,9 @@ Create_Tag_Area (void)
 
 
     /* Genre */
+    row++;
     GenreLabel = gtk_label_new(_("Genre:"));
-    et_grid_attach_full (GTK_GRID (Table), GenreLabel, 0, 5, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), GenreLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(GenreLabel),1,0.5);
 
@@ -979,7 +1031,7 @@ Create_Tag_Area (void)
     gtk_entry_completion_set_text_column(completion, 0);
     gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(GenreComboModel), MISC_COMBO_TEXT, 
Combo_Alphabetic_Sort, NULL, NULL);
     gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(GenreComboModel), MISC_COMBO_TEXT, 
GTK_SORT_ASCENDING);
-    et_grid_attach_full (GTK_GRID (Table), GenreCombo, 1, 5, 9, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), GenreCombo, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding, TablePadding);
     Load_Genres_List_To_UI();
     gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(GenreCombo),2); // Two columns to display genres list
@@ -992,15 +1044,16 @@ Create_Tag_Area (void)
     Attach_Popup_Menu_To_Tag_Entries(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(GenreCombo))));
 
     /* Comment */
+    row++;
     CommentLabel = gtk_label_new(_("Comment:"));
-    et_grid_attach_full (GTK_GRID (Table), CommentLabel, 0, 6, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), CommentLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(CommentLabel),1,0.5);
 
     CommentEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (CommentEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), CommentEntry, 1, 6, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), CommentEntry, 1, row, 9, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
 
     // Use of a text view instead of an entry...
@@ -1026,15 +1079,16 @@ Create_Tag_Area (void)
 
 
     /* Composer (name of the composers) */
+    row++;
     ComposerLabel = gtk_label_new(_("Composer:"));
-    et_grid_attach_full (GTK_GRID (Table), ComposerLabel, 0, 7, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), ComposerLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(ComposerLabel),1,0.5);
 
     ComposerEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (ComposerEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), ComposerEntry, 1, 7, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), ComposerEntry, 1, row, 9, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (ComposerEntry));
@@ -1047,15 +1101,16 @@ Create_Tag_Area (void)
 
     /* Translators: Original Artist / Performer. Please try to keep this string
      * as short as possible, as it must fit into a narrow column. */
+    row++;
     OrigArtistLabel = gtk_label_new(_("Orig. artist:"));
-    et_grid_attach_full (GTK_GRID (Table), OrigArtistLabel, 0, 8, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), OrigArtistLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(OrigArtistLabel),1,0.5);
 
     OrigArtistEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (OrigArtistEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), OrigArtistEntry, 1, 8, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), OrigArtistEntry, 1, row, 9, 1, TRUE,
                          TRUE,TablePadding,TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (OrigArtistEntry));
@@ -1067,15 +1122,16 @@ Create_Tag_Area (void)
 
 
     /* Copyright */
+    row++;
     CopyrightLabel = gtk_label_new(_("Copyright:"));
-    et_grid_attach_full (GTK_GRID (Table), CopyrightLabel, 0, 9, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), CopyrightLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(CopyrightLabel),1,0.5);
 
     CopyrightEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (CopyrightEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), CopyrightEntry, 1, 9, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), CopyrightEntry, 1, row, 9, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (CopyrightEntry));
@@ -1087,15 +1143,16 @@ Create_Tag_Area (void)
 
 
     /* URL */
+    row++;
     URLLabel = gtk_label_new(_("URL:"));
-    et_grid_attach_full (GTK_GRID (Table), URLLabel, 0, 10, 1, 1, FALSE, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), URLLabel, 0, row, 1, 1, FALSE, FALSE,
                          TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(URLLabel),1,0.5);
 
     URLEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (URLEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), URLEntry, 1, 10, 9, 1, TRUE, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), URLEntry, 1, row, 9, 1, TRUE, TRUE,
                          TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (URLEntry));
@@ -1107,15 +1164,16 @@ Create_Tag_Area (void)
 
 
     /* Encoded by */
+    row++;
     EncodedByLabel = gtk_label_new(_("Encoded by:"));
-    et_grid_attach_full (GTK_GRID (Table), EncodedByLabel, 0, 11, 1, 1, FALSE,
+    et_grid_attach_full (GTK_GRID (Table), EncodedByLabel, 0, row, 1, 1, FALSE,
                          FALSE, TablePadding, TablePadding);
     gtk_misc_set_alignment(GTK_MISC(EncodedByLabel),1,0.5);
 
     EncodedByEntry = gtk_entry_new();
     gtk_entry_set_icon_from_icon_name (GTK_ENTRY (EncodedByEntry),
                                        GTK_ENTRY_ICON_SECONDARY, "insert-text");
-    et_grid_attach_full (GTK_GRID (Table), EncodedByEntry, 1, 11, 9, 1, TRUE,
+    et_grid_attach_full (GTK_GRID (Table), EncodedByEntry, 1, row, 9, 1, TRUE,
                          TRUE, TablePadding, TablePadding);
 
     et_tag_field_connect_signals (GTK_ENTRY (EncodedByEntry));
@@ -1131,8 +1189,9 @@ Create_Tag_Area (void)
     focusable_widgets_list = g_list_prepend(focusable_widgets_list,ArtistEntry);
     focusable_widgets_list = g_list_prepend(focusable_widgets_list,AlbumArtistEntry);
     focusable_widgets_list = g_list_prepend(focusable_widgets_list,AlbumEntry);
-    focusable_widgets_list = g_list_prepend(focusable_widgets_list,DiscNumberEntry);
     focusable_widgets_list = g_list_prepend(focusable_widgets_list,YearEntry);
+    focusable_widgets_list = g_list_prepend(focusable_widgets_list,DiscNumberEntryCombo);
+    focusable_widgets_list = g_list_prepend(focusable_widgets_list,DiscNumberTotalEntry);
     //focusable_widgets_list = g_list_prepend(focusable_widgets_list,TrackMButtonSequence); // Doesn't work 
as focus disabled for this widget to have enought space to display icon
     focusable_widgets_list = g_list_prepend(focusable_widgets_list,TrackEntryCombo);
     //focusable_widgets_list = g_list_prepend(focusable_widgets_list,TrackMButtonNbrFiles);
@@ -1395,22 +1454,150 @@ Mini_Button_Clicked (GObject *object)
         else
             msg = g_strdup(_("Removed album name from selected files."));
     }
-    else if (object == G_OBJECT (DiscNumberEntry))
+    else if (object==G_OBJECT(DiscNumberMButtonSequence))
     {
-        string_to_set = gtk_editable_get_chars(GTK_EDITABLE(DiscNumberEntry),0,-1);
+        /* This part doesn't set the same disc number to all files, but sequence the discs.
+         * So we must browse the whole 'etfilelistfull' to get position of each selected file.
+         * Note : 'etfilelistfull' and 'etfilelist' must be sorted in the same order */
+        GList *etfilelistfull = NULL;
+        gchar *path = NULL;
+        gchar *path1 = NULL;
+        gint i = 1;
+
+        etfilelistfull = g_list_first(ETCore->ETFileList);
+
+        // Sort 'etfilelistfull' and 'etfilelist' in the same order
+        etfilelist     = ET_Sort_File_List(etfilelist,SORTING_FILE_MODE);
+        etfilelistfull = ET_Sort_File_List(etfilelistfull,SORTING_FILE_MODE);
+
+        while (etfilelist && etfilelistfull)
+        {
+            // To get the path of the file
+            File_Name *FileNameCur = (File_Name *)((ET_File *)etfilelistfull->data)->FileNameCur->data;
+            // The ETFile in the selected file list
+            etfile = etfilelist->data;
+
+            // Increment the counter when entering a new directory
+            g_free(path1);
+            path1 = g_path_get_dirname(FileNameCur->value);
+            if (path && path1 && strcmp(path, path1) != 0)
+                i++;
+
+            string_to_set = et_disc_number_to_string (i);
+
+            // The file is in the selection?
+            if ( (ET_File *)etfilelistfull->data == etfile )
+            {
+                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_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
+
+                if (!etfilelist->next) break;
+                etfilelist = g_list_next(etfilelist);
+            }
+
+            g_free(string_to_set);
+            g_free(path);
+            path = g_strdup(path1);
+
+            etfilelistfull = g_list_next(etfilelistfull);
+        }
+        g_free(path);
+        g_free(path1);
+        msg = g_strdup_printf (_("Selected discs numbered sequentially."));
+    }
+    else if (object==G_OBJECT(DiscNumberMButtonNbrFolders))
+    {
+        // count the number of folders in the selected directory
+        // only folders containing a file in the list will be counted
+        GList *etfilelistfull = NULL;
+        gchar *path           = NULL;
+        gchar *path1          = NULL;
+
+        int number_of_folders = 1;
+
+        etfilelistfull = g_list_first(ETCore->ETFileList);
+
+        // Sort 'etfilelistfull'
+        etfilelistfull = ET_Sort_File_List(etfilelistfull,SORTING_FILE_MODE);
+
+        while (etfilelistfull)
+        {
+            // To get the path of the file
+            File_Name *FileNameCur = (File_Name *)((ET_File *)etfilelistfull->data)->FileNameCur->data;
+            // The ETFile in the selected file list
+            etfile = etfilelist->data;
+
+            // Increment the counter when entering a new directory
+            g_free(path1);
+            path1 = g_path_get_dirname(FileNameCur->value);
+            if (path && path1 && strcmp(path, path1) != 0)
+                number_of_folders++;
+
+            g_free(path);
+            path = g_strdup(path1);
+
+            etfilelistfull = g_list_next(etfilelistfull);
+        }
+        g_free(path);
+        g_free(path1);
+
+
+        while (etfilelist)
+        {
+            etfile = (ET_File *)etfilelist->data;
+
+            string_to_set = et_disc_number_to_string (number_of_folders);
+
+            if (!string_to_set1)
+                string_to_set1 = g_strdup(string_to_set); // Just for the message below...
+
+            FileTag = ET_File_Tag_Item_New();
+            ET_Copy_File_Tag_Item(etfile,FileTag);
+            ET_Set_Field_File_Tag_Item (&FileTag->disc_total, string_to_set);
+            ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
+
+            if (!etfilelist->next) break;
+            etfilelist = g_list_next(etfilelist);
+        }
+
+        if ( string_to_set1 != NULL && g_utf8_strlen(string_to_set1, -1)>0 ) //&& atoi(string_to_set1)>0 )
+        {
+            msg = g_strdup_printf(_("Selected files tagged with disc like 'xx/%s'."),string_to_set1);
+        }else
+        {
+            msg = g_strdup(_("Removed total disc number from selected files."));
+        }
+    }
+    else if (object == G_OBJECT (DiscNumberTotalEntry))
+    {
+        string_to_set = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo)))));
+        string_to_set1 = gtk_editable_get_chars(GTK_EDITABLE(DiscNumberTotalEntry),0,-1);
 
         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);
-        else
-            msg = g_strdup(_("Removed disc number from selected files."));
+
+        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 'xx/%s'."),string_to_set1);
+            }else
+            {
+                msg = g_strdup_printf(_("Selected files tagged with disc number like 'xx'."));
+            }
+        }else
+        {
+            msg = g_strdup(_("Removed disc number number from selected files."));
+        }
     }
     else if (object == G_OBJECT (YearEntry))
     {
@@ -3375,6 +3562,8 @@ gboolean Read_Directory (gchar *path_real)
 
         /* Load the list attached to the TrackEntry */
         Load_Track_List_To_UI();
+        /* Load the list attached to the DiscNumberEntryCombo */
+        Load_Disc_List_To_UI();
 
         /* Display the first file */
         //No need to select first item, because Browser_Display_Tree_Or_Artist_Album_List() does this
@@ -3941,7 +4130,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
             {
                 // ID3v1 : Hide specifics ID3v2 fields if not activated!
                 gtk_widget_hide(GTK_WIDGET(DiscNumberLabel));
-                gtk_widget_hide(GTK_WIDGET(DiscNumberEntry));
+                gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonSequence));
+                gtk_widget_hide(GTK_WIDGET(DiscNumberEntryCombo));
+                gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+                gtk_widget_hide(GTK_WIDGET(DiscNumberTotalEntry));
                 gtk_widget_hide(GTK_WIDGET(ComposerLabel));
                 gtk_widget_hide(GTK_WIDGET(ComposerEntry));
                 gtk_widget_hide(GTK_WIDGET(OrigArtistLabel));
@@ -3961,7 +4153,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
             }else
             {
                 gtk_widget_show(GTK_WIDGET(DiscNumberLabel));
-                gtk_widget_show(GTK_WIDGET(DiscNumberEntry));
+                gtk_widget_show(GTK_WIDGET(DiscNumberMButtonSequence));
+                gtk_widget_show(GTK_WIDGET(DiscNumberEntryCombo));
+                gtk_widget_show(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+                gtk_widget_show(GTK_WIDGET(DiscNumberTotalEntry));
                 gtk_widget_show(GTK_WIDGET(ComposerLabel));
                 gtk_widget_show(GTK_WIDGET(ComposerEntry));
                 gtk_widget_show(GTK_WIDGET(OrigArtistLabel));
@@ -3984,7 +4179,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
 #ifdef ENABLE_OGG
         case OGG_TAG:
             gtk_widget_show(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_show(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_show(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_show(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_show(GTK_WIDGET(ComposerLabel));
             gtk_widget_show(GTK_WIDGET(ComposerEntry));
             gtk_widget_show(GTK_WIDGET(OrigArtistLabel));
@@ -4007,7 +4205,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
 #ifdef ENABLE_FLAC
         case FLAC_TAG:
             gtk_widget_show(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_show(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_show(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_show(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_show(GTK_WIDGET(ComposerLabel));
             gtk_widget_show(GTK_WIDGET(ComposerEntry));
             gtk_widget_show(GTK_WIDGET(OrigArtistLabel));
@@ -4029,7 +4230,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
 
         case APE_TAG:
             gtk_widget_show(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_show(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_show(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_show(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_show(GTK_WIDGET(ComposerLabel));
             gtk_widget_show(GTK_WIDGET(ComposerEntry));
             gtk_widget_show(GTK_WIDGET(OrigArtistLabel));
@@ -4051,7 +4255,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
 #ifdef ENABLE_MP4
         case MP4_TAG:
             gtk_widget_hide(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_hide(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_hide(GTK_WIDGET(ComposerLabel));
             gtk_widget_hide(GTK_WIDGET(ComposerEntry));
             gtk_widget_hide(GTK_WIDGET(OrigArtistLabel));
@@ -4074,7 +4281,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
 #ifdef ENABLE_WAVPACK
         case WAVPACK_TAG:
             gtk_widget_show(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_show(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_show(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_show(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_show(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_show(GTK_WIDGET(ComposerLabel));
             gtk_widget_show(GTK_WIDGET(ComposerEntry));
             gtk_widget_show(GTK_WIDGET(OrigArtistLabel));
@@ -4097,7 +4307,10 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
         case UNKNOWN_TAG:
         default:
             gtk_widget_hide(GTK_WIDGET(DiscNumberLabel));
-            gtk_widget_hide(GTK_WIDGET(DiscNumberEntry));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonSequence));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberEntryCombo));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberMButtonNbrFolders));
+            gtk_widget_hide(GTK_WIDGET(DiscNumberTotalEntry));
             gtk_widget_hide(GTK_WIDGET(ComposerLabel));
             gtk_widget_hide(GTK_WIDGET(ComposerEntry));
             gtk_widget_hide(GTK_WIDGET(OrigArtistLabel));
@@ -4132,7 +4345,8 @@ void Clear_Tag_Entry_Fields (void)
     gtk_entry_set_text(GTK_ENTRY(ArtistEntry),                      "");
     gtk_entry_set_text(GTK_ENTRY(AlbumArtistEntry),                 "");
     gtk_entry_set_text(GTK_ENTRY(AlbumEntry),                       "");
-    gtk_entry_set_text(GTK_ENTRY(DiscNumberEntry),                  "");
+    gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo))), "");
+    gtk_entry_set_text(GTK_ENTRY(DiscNumberTotalEntry),                             "");
     gtk_entry_set_text(GTK_ENTRY(YearEntry),                        "");
     gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(TrackEntryCombo))),  "");
     gtk_entry_set_text(GTK_ENTRY(TrackTotalEntry),                  "");
diff --git a/src/easytag.h b/src/easytag.h
index ac51396..9f2af24 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -76,7 +76,9 @@ GtkWidget    *TitleEntry;
 GtkWidget    *ArtistEntry;
 GtkWidget    *AlbumArtistEntry;
 GtkWidget    *AlbumEntry;
-GtkWidget    *DiscNumberEntry;
+GtkWidget    *DiscNumberEntryCombo;
+GtkListStore *DiscNumberEntryComboModel;
+GtkWidget    *DiscNumberTotalEntry;
 GtkWidget    *YearEntry;
 GtkWidget    *TrackEntryCombo;
 GtkListStore *TrackEntryComboModel;
@@ -110,6 +112,8 @@ GtkWidget    *EncodedByLabel;
 // Mini buttons
 GtkWidget    *TrackMButtonSequence;
 GtkWidget    *TrackMButtonNbrFiles;
+GtkWidget    *DiscNumberMButtonSequence;
+GtkWidget    *DiscNumberMButtonNbrFolders;
 
 /* Other for picture. */
 GtkToolItem *remove_image_toolitem;
diff --git a/src/et_core.c b/src/et_core.c
index c532298..0f1c0bc 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);
@@ -2935,10 +2947,22 @@ ET_Display_File_Tag_To_UI (ET_File *ETFile)
     if (FileTag && FileTag->disc_number)
     {
         gchar *tmp = Try_To_Validate_Utf8_String(FileTag->disc_number);
-        gtk_entry_set_text(GTK_ENTRY(DiscNumberEntry), tmp);
+        gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo))), tmp);
         g_free(tmp);
     }else
-        gtk_entry_set_text(GTK_ENTRY(DiscNumberEntry),"");
+        gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo))),"");
+
+    /* Show number of dicsc of the album */
+    if (FileTag && FileTag->disc_total)
+    {
+        gchar *tmp = Try_To_Validate_Utf8_String (FileTag->disc_total);
+        gtk_entry_set_text (GTK_ENTRY (DiscNumberTotalEntry), tmp);
+        g_free(tmp);
+    }
+    else
+    {
+        gtk_entry_set_text (GTK_ENTRY (DiscNumberTotalEntry), "");
+    }
 
     /* Show year */
     if (FileTag && FileTag->year)
@@ -3432,7 +3456,7 @@ ET_Save_File_Tag_From_UI (File_Tag *FileTag)
     }
 
     /* Disc Number */
-    buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(DiscNumberEntry)));
+    buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(DiscNumberEntryCombo)))));
     Strip_String(buffer);
 
     if ( g_utf8_strlen(buffer, -1) > 0 )
@@ -3443,6 +3467,20 @@ ET_Save_File_Tag_From_UI (File_Tag *FileTag)
         g_free(buffer);
     }
 
+    /* Discs Total */
+    buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(DiscNumberTotalEntry)));
+    Strip_String(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);
+    }
+
     /* Year */
     buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(YearEntry)));
     Strip_String(buffer);
@@ -3669,6 +3707,18 @@ 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));
+        Strip_String (FileTag->disc_total);
+    } else
+    {
+        FileTag->disc_total = NULL;
+    }
+
+
     /* Year */
     if ( FileTagCur->year && g_utf8_strlen(FileTagCur->year, -1)>0 )
     {
@@ -4120,6 +4170,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 fd1fe1a..fe8ee82 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -517,6 +517,38 @@ void Load_Track_List_To_UI (void)
 }
 
 /*
+ * Load the disc numbers into the track combo list
+ * We limit the preloaded values to 30 to avoid lost of time with lot of folders...
+ */
+void Load_Disc_List_To_UI (void)
+{
+    guint len;
+    guint i;
+    GtkTreeIter iter;
+    gchar *text;
+
+    g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+                      DiscNumberEntryComboModel != NULL);
+
+    // remove the entries in the list to avoid duplicates
+    gtk_list_store_clear(DiscNumberEntryComboModel);
+
+    // Number mini of items
+    // Length limited to 30 (instead to the number of folders)!
+    len = 30;
+
+    // Create list of disc numbers
+    for (i=1; i<=len; i++)
+    {
+        text = et_disc_number_to_string (i);
+
+        gtk_list_store_append(GTK_LIST_STORE(DiscNumberEntryComboModel), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(DiscNumberEntryComboModel), &iter, MISC_COMBO_TEXT, text, -1);
+        g_free(text);
+    }
+}
+
+/*
  * Change mouse cursor
  */
 void Init_Mouse_Cursor (void)
@@ -2286,9 +2318,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;
 
 
@@ -2354,6 +2387,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;
@@ -2371,9 +2412,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);
@@ -2393,6 +2435,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) )
@@ -2411,6 +2454,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);
@@ -2460,6 +2504,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;
 
@@ -2476,10 +2521,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
@@ -2497,6 +2540,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_number)
+        {
+            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;
@@ -2510,7 +2576,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
diff --git a/src/misc.h b/src/misc.h
index 7a24554..69c8719 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -70,6 +70,7 @@ void Insert_Only_Digit (GtkEditable *editable,const gchar *text,gint length,gint
 gboolean Parse_Date (void);
 void Load_Genres_List_To_UI (void);
 void Load_Track_List_To_UI  (void);
+void Load_Disc_List_To_UI  (void);
 void Init_Character_Translation_Table (void);
 void Init_Custom_Icons (void);
 gchar *Check_If_Executable_Exists (const gchar *program);


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