Revision: 2149
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2149&view=rev
Author:   jcsjcs
Date:     2008-11-08 09:38:35 +0000 (Sat, 08 Nov 2008)

Log Message:
-----------
        * src/display_tracks.c
          src/misc_track.c: use a toggle box to show the state of the
          lyrics flag instead of 0/1.

        * src/display_tracks.c
          src/misc_track.c
          src/file.c
          src/file.h
          src/details.c
          src/details.h: clicking on the lyrics toggle box brings up the
          edit lyrics dialog.

          !!! There are two possible sources for segfaults in
          details.c/details_button_apply_clicked:

          - track_copy_artwork() writes the lyrics tag to the file and
            checks for duplicates. This might destroy the list we are just
            iterating over.

          - write_tags_to_file() writes tags to the file and checks for
            duplicates. This might destroy the list we are just iterating
            over.

          I don't have a simple solution right now.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog
    gtkpod/trunk/src/details.c
    gtkpod/trunk/src/details.h
    gtkpod/trunk/src/display_tracks.c
    gtkpod/trunk/src/file.c
    gtkpod/trunk/src/file.h
    gtkpod/trunk/src/misc_track.c

Modified: gtkpod/trunk/ChangeLog
===================================================================
--- gtkpod/trunk/ChangeLog      2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/ChangeLog      2008-11-08 09:38:35 UTC (rev 2149)
@@ -1,5 +1,32 @@
 2008-11-08 Jorg Schuler <jcsjcs at users.sourceforge.net>
 
+       * src/display_tracks.c
+         src/misc_track.c: use a toggle box to show the state of the
+         lyrics flag instead of 0/1.
+
+       * src/display_tracks.c
+         src/misc_track.c
+         src/file.c
+         src/file.h
+         src/details.c
+         src/details.h: clicking on the lyrics toggle box brings up the
+         edit lyrics dialog.
+
+         !!! There are two possible sources for segfaults in
+         details.c/details_button_apply_clicked:
+
+         - track_copy_artwork() writes the lyrics tag to the file and
+           checks for duplicates. This might destroy the list we are just
+           iterating over.
+
+         - write_tags_to_file() writes tags to the file and checks for
+           duplicates. This might destroy the list we are just iterating
+           over.
+
+         I don't have a simple solution right now.
+
+2008-11-08 Jorg Schuler <jcsjcs at users.sourceforge.net>
+
         * src/display.h
          src/file_itunesdb.c
          src/misc_conversion.c

Modified: gtkpod/trunk/src/details.c
===================================================================
--- gtkpod/trunk/src/details.c  2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/details.c  2008-11-08 09:38:35 UTC (rev 2149)
@@ -54,7 +54,7 @@
 /* string constants for preferences */
 static const gchar *DETAILS_WINDOW_DEFX="details_window_defx";
 static const gchar *DETAILS_WINDOW_DEFY="details_window_defy";
-static const gchar 
*DETAILS_WINDOW_NOTEBOOK_PAGE="details_window_notebook_page";
+const gchar *DETAILS_WINDOW_NOTEBOOK_PAGE="details_window_notebook_page";
 
 /* enum types */
 typedef enum
@@ -436,8 +436,8 @@
            {
                Track *tr = gl->data;
                write_tags_to_file (tr);
-               /* display possible duplicates that have been removed */
            }
+           /* display possible duplicates that have been removed */
            gp_duplicate_remove (NULL, NULL);
        }
     }

Modified: gtkpod/trunk/src/details.h
===================================================================
--- gtkpod/trunk/src/details.h  2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/details.h  2008-11-08 09:38:35 UTC (rev 2149)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2005-12-10 00:46:23 jcs>
+/* Time-stamp: <2008-11-08 17:35:16 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -53,6 +53,8 @@
 
 typedef struct _Detail Detail;
 
+extern const gchar *DETAILS_WINDOW_NOTEBOOK_PAGE;
+
 /* details window */
 void details_edit (GList *selected_tracks);
 void details_update_default_sizes (void);

Modified: gtkpod/trunk/src/display_tracks.c
===================================================================
--- gtkpod/trunk/src/display_tracks.c   2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/display_tracks.c   2008-11-08 09:38:35 UTC (rev 2149)
@@ -41,6 +41,7 @@
 #include <unistd.h>
 
 #include "prefs.h"
+#include "details.h"
 #include "display_private.h"
 #include "display_itdb.h"
 #include "itdb.h"
@@ -1139,14 +1140,7 @@
        itdb = track->itdb;
        g_return_if_fail (itdb);
 
-       if (column!= TM_COLUMN_LYRICS)
-       {
-               text = track_get_text (track, TM_to_T (column));
-       }
-       else
-       {
-               text = g_strdup_printf ("%d", track->lyrics_flag);
-       }
+       text = track_get_text (track, TM_to_T (column));
 
        switch (column)
        {
@@ -1188,7 +1182,6 @@
                        "xalign", 0.0, NULL);
          break;
        case TM_COLUMN_MEDIA_TYPE:
-       case TM_COLUMN_LYRICS:
          g_object_set (G_OBJECT (renderer),
                        "text", text,
                        "editable", FALSE,
@@ -1226,6 +1219,11 @@
                        "editable", FALSE,
                        "xalign", 0.0, NULL);
          break;
+       case TM_COLUMN_LYRICS:
+         g_object_set (G_OBJECT (renderer),
+                       "active", track->lyrics_flag,
+                       "activatable", TRUE, NULL);
+         break;
        case TM_COLUMN_TRANSFERRED:
          g_object_set (G_OBJECT (renderer),
                        "active", track->transferred,
@@ -1291,6 +1289,7 @@
   gint sel_rows_num;
   GList *row_list, *row_node, *first;
   gboolean active;
+  GList *selected_tracks = NULL;
 
   column = (TM_item) g_object_get_data(G_OBJECT(renderer), "column");
   multi_edit = prefs_get_int("multi_edit");
@@ -1337,6 +1336,10 @@
         if (!active) track->compilation = 1;
         else        track->compilation = 0;
         break;
+     case TM_COLUMN_LYRICS:
+        /* collect all selected tracks -- then call "edit details" */
+        selected_tracks = g_list_append (selected_tracks, track);
+        break;
      case TM_COLUMN_ARTIST:
      case TM_COLUMN_ALBUM:
      case TM_COLUMN_GENRE:
@@ -1383,9 +1386,8 @@
      case TM_COLUMN_SORT_ALBUMARTIST:
      case TM_COLUMN_SORT_COMPOSER:
      case TM_COLUMN_SORT_TVSHOW:
-     case TM_COLUMN_LYRICS:
      case TM_NUM_COLUMNS:
-        /* these are not toggle buttons */
+        /* these are not toggle buttons or are non-editable */
         break;
      }
 /*      printf ("  changed: %d\n", changed); */
@@ -1406,6 +1408,14 @@
      while (widgets_blocked && gtk_events_pending ())  gtk_main_iteration ();
   }
 
+  if ((column == TM_COLUMN_LYRICS) && (selected_tracks != NULL))
+  {
+      /* set displayed page to the lyrics page */
+      prefs_set_int (DETAILS_WINDOW_NOTEBOOK_PAGE, 3);
+      details_edit (selected_tracks);
+      g_list_free (selected_tracks);
+  }
+
   if (multi_edit && (sel_rows_num > 1)) release_widgets ();
 
   g_list_foreach(row_list, (GFunc) gtk_tree_path_free, NULL);
@@ -2242,7 +2252,6 @@
        case TM_COLUMN_SORT_ALBUMARTIST:
        case TM_COLUMN_SORT_COMPOSER:
        case TM_COLUMN_SORT_TVSHOW:
-       case TM_COLUMN_LYRICS:
          break;
        /* for some column names we want to use shorter alternatives to
         get_tm_string() */
@@ -2262,6 +2271,11 @@
          text = _("Trnsfrd");
          renderer = gtk_cell_renderer_toggle_new ();
          break;
+       case TM_COLUMN_LYRICS:
+         renderer = gtk_cell_renderer_toggle_new ();
+         g_signal_connect (G_OBJECT (renderer), "toggled",
+                       G_CALLBACK (tm_cell_toggled), model);
+         break;
        case TM_COLUMN_COMPILATION:
          text = _("Cmpl");
          renderer = gtk_cell_renderer_toggle_new ();

Modified: gtkpod/trunk/src/file.c
===================================================================
--- gtkpod/trunk/src/file.c     2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/file.c     2008-11-08 09:38:35 UTC (rev 2149)
@@ -2642,7 +2642,7 @@
 }
 
 /* Write lyrics to file */
-gboolean write_lyrics_to_file (Track *track,const gchar *lyrics)
+gboolean write_lyrics_to_file (Track *track)
 {
     gchar *path=NULL;
     gchar *buf;
@@ -2679,7 +2679,7 @@
         switch (determine_file_type (path))
         {
         case FILE_TYPE_MP3:
-            result = id3_lyrics_save (path, lyrics);
+            result = id3_lyrics_save (path, etr->lyrics);
             break;
         case FILE_TYPE_M4A:
         case FILE_TYPE_M4P:
@@ -2709,17 +2709,25 @@
        if (!warned) {
            buf = get_track_info (track, FALSE);
            gtkpod_warning (
-               _("Lyrics not found, file name not available (%s).\n\n"),
+               _("Lyrics not written, file name not available (%s).\n\n"),
                buf);
            g_free (buf);
        }
     }
-    if ((lyrics == NULL) || (strlen(lyrics)==0))
+
+    if (!result || !etr->lyrics || (strlen(etr->lyrics)==0))
     {
-       if (lyrics == NULL) lyrics = g_strdup("");
-       etr->lyrics=g_strdup(lyrics);
        track->lyrics_flag=0x00;
     }
+    else
+    {
+       track->lyrics_flag=0x01;
+    }
+    if (!etr->lyrics)
+    {
+       etr->lyrics = g_strdup ("");
+    }
+
     if (result)
     {
        /* remove track from sha1 hash and reinsert it (hash value has 
changed!) */
@@ -2727,7 +2735,7 @@
        C_FREE (etr->sha1_hash);  /* need to remove the old value manually! */
        oldtrack = sha1_track_exists_insert (itdb, track);
        if (oldtrack)
-       { /* track exists, remove and register the new version */
+       { /* track exists, remove the old track and register the new version */
            sha1_track_remove (oldtrack);
            gp_duplicate_remove (track, oldtrack);
            sha1_track_exists_insert (itdb, track);

Modified: gtkpod/trunk/src/file.h
===================================================================
--- gtkpod/trunk/src/file.h     2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/file.h     2008-11-08 09:38:35 UTC (rev 2149)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-05-06 20:20:31 jcs>
+/* Time-stamp: <2008-11-08 18:11:02 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -125,7 +125,7 @@
                                         iTunesDB *itdb_d,
                                         GList *tracks);
 gboolean read_lyrics_from_file (Track *track, gchar **lyrics);
-gboolean write_lyrics_to_file (Track *track, const gchar *lyrics);
+gboolean write_lyrics_to_file (Track *track);
 /* needed to adapt the prefs structure */
 extern const gchar *EXPORT_FILES_SPECIAL_CHARSET;
 extern const gchar *EXPORT_FILES_CHECK_EXISTING;

Modified: gtkpod/trunk/src/misc_track.c
===================================================================
--- gtkpod/trunk/src/misc_track.c       2008-11-08 08:02:15 UTC (rev 2148)
+++ gtkpod/trunk/src/misc_track.c       2008-11-08 09:38:35 UTC (rev 2149)
@@ -1013,7 +1013,7 @@
        }
        else if ((changed) && (item == T_LYRICS))
        {
-           write_lyrics_to_file (totrack,etotr->lyrics);
+           write_lyrics_to_file (totrack);
        }
        /* handle items that have two entries */
        if (item == T_PC_PATH)
@@ -1427,7 +1427,7 @@
     case T_GAPLESS_TRACK_FLAG:
        break;
     case T_LYRICS:
-       read_lyrics_from_file (track,&text);
+       read_lyrics_from_file (track, &text);
        break;
     }
     return text;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to