rhythmbox r6044 - in trunk: . plugins/ipod sources



Author: teuf
Date: Thu Nov 13 10:55:37 2008
New Revision: 6044
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6044&view=rev

Log:
2008-11-13  Christophe Fergeau  <teuf gnome org>

        * sources/rb-removable-media-source.c
        * sources/rb-removable-media-source.h: add
        rb_removable_media_source_should_paste_no_duplicate helper which
        can be used as a vfunc for RbRemovableMediaSource::should_paste for
        sources that want to disallow copying of duplicate songs. For now,
        duplicate checking is done by comparing song title/album/artist
        (which is a bit simplistic ;)
        * plugins/ipod/rb-ipod-source.c: use this helper function instead
        of having dedicated code in the ipod plugin

Modified:
   trunk/ChangeLog
   trunk/plugins/ipod/rb-ipod-source.c
   trunk/sources/rb-removable-media-source.c
   trunk/sources/rb-removable-media-source.h

Modified: trunk/plugins/ipod/rb-ipod-source.c
==============================================================================
--- trunk/plugins/ipod/rb-ipod-source.c	(original)
+++ trunk/plugins/ipod/rb-ipod-source.c	Thu Nov 13 10:55:37 2008
@@ -77,8 +77,6 @@
 
 #ifdef ENABLE_IPOD_WRITING
 static GList * impl_get_mime_types (RBRemovableMediaSource *source);
-static gboolean impl_should_paste (RBRemovableMediaSource *source,
-				   RhythmDBEntry *entry);
 static gboolean impl_track_added (RBRemovableMediaSource *source,
 				  RhythmDBEntry *entry,
 				  const char *dest,
@@ -160,7 +158,7 @@
 
 #ifdef ENABLE_IPOD_WRITING
 	source_class->impl_can_paste = (RBSourceFeatureFunc) rb_true_function;
-	rms_class->impl_should_paste = impl_should_paste;
+	rms_class->impl_should_paste = rb_removable_media_source_should_paste_no_duplicate;
 	rms_class->impl_track_added = impl_track_added;
 	rms_class->impl_build_dest_uri = impl_build_dest_uri;
 	rms_class->impl_get_mime_types = impl_get_mime_types;
@@ -1371,55 +1369,6 @@
 }
 
 static gboolean
-impl_should_paste (RBRemovableMediaSource *source,
-		   RhythmDBEntry *entry)
-{
-	RhythmDBEntryType entry_type;
-	RhythmDB *db;
-	RBShell *shell;
-	const char *title;
-	const char *album;
-	const char *artist;
-	GtkTreeModel *query_model;
-	GtkTreeIter iter;
-	gboolean no_match;
-	 
-	RBRemovableMediaSourceClass *rms_class = RB_REMOVABLE_MEDIA_SOURCE_CLASS (g_type_class_peek_parent (RB_REMOVABLE_MEDIA_SOURCE_GET_CLASS (source)));
-	/* chain up to parent impl */
-	if (!rms_class->impl_should_paste (source, entry))
-		return FALSE;
-
-	g_object_get (source, "shell", &shell, "entry-type", &entry_type, NULL);
-	g_object_get (shell, "db", &db, NULL);
-	g_object_unref (shell);
-
-	query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db));
-	title = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE);
-	album = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM);
-	artist = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST);
-	rhythmdb_do_full_query (db, RHYTHMDB_QUERY_RESULTS (query_model),
-				RHYTHMDB_QUERY_PROP_EQUALS,
-				RHYTHMDB_PROP_TYPE, entry_type,
-				RHYTHMDB_QUERY_PROP_EQUALS,
-				RHYTHMDB_PROP_ARTIST, artist,
-				RHYTHMDB_QUERY_PROP_EQUALS,
-				RHYTHMDB_PROP_ALBUM, album,
-				RHYTHMDB_QUERY_PROP_EQUALS,
-				RHYTHMDB_PROP_TITLE, title,
-				RHYTHMDB_QUERY_END);
-
-	no_match = (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (query_model),
-						 &iter));
-	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
-	g_object_unref(query_model);
-	g_object_unref (db);
-	if (no_match == FALSE) {
-		rb_debug ("not adding %s - %s - %s to the ipod since it's already present\n", title, album, artist);
-	}
-	return no_match;
-}
-
-static gboolean
 impl_track_added (RBRemovableMediaSource *source,
 		  RhythmDBEntry *entry,
 		  const char *dest,

Modified: trunk/sources/rb-removable-media-source.c
==============================================================================
--- trunk/sources/rb-removable-media-source.c	(original)
+++ trunk/sources/rb-removable-media-source.c	Thu Nov 13 10:55:37 2008
@@ -638,6 +638,55 @@
 		return NULL;
 }
 
+gboolean
+rb_removable_media_source_should_paste_no_duplicate (RBRemovableMediaSource *source,
+						     RhythmDBEntry *entry)
+{
+	RhythmDBEntryType entry_type;
+	RhythmDB *db;
+	RBShell *shell;
+	const char *title;
+	const char *album;
+	const char *artist;
+	GtkTreeModel *query_model;
+	GtkTreeIter iter;
+	gboolean no_match;
+	 
+	RBRemovableMediaSourceClass *rms_class = RB_REMOVABLE_MEDIA_SOURCE_CLASS (g_type_class_peek_parent (RB_REMOVABLE_MEDIA_SOURCE_GET_CLASS (source)));
+	/* chain up to parent impl */
+	if (!rms_class->impl_should_paste (source, entry))
+		return FALSE;
+
+	g_object_get (source, "shell", &shell, "entry-type", &entry_type, NULL);
+	g_object_get (shell, "db", &db, NULL);
+	g_object_unref (shell);
+
+	query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db));
+	title = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE);
+	album = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM);
+	artist = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST);
+	rhythmdb_do_full_query (db, RHYTHMDB_QUERY_RESULTS (query_model),
+				RHYTHMDB_QUERY_PROP_EQUALS,
+				RHYTHMDB_PROP_TYPE, entry_type,
+				RHYTHMDB_QUERY_PROP_EQUALS,
+				RHYTHMDB_PROP_ARTIST, artist,
+				RHYTHMDB_QUERY_PROP_EQUALS,
+				RHYTHMDB_PROP_ALBUM, album,
+				RHYTHMDB_QUERY_PROP_EQUALS,
+				RHYTHMDB_PROP_TITLE, title,
+				RHYTHMDB_QUERY_END);
+
+	no_match = (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (query_model),
+						 &iter));
+	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
+	g_object_unref(query_model);
+	g_object_unref (db);
+	if (no_match == FALSE) {
+		rb_debug ("not adding %s - %s - %s to  removable device since it's already present\n", title, album, artist);
+	}
+	return no_match;
+}
+
 static gboolean
 impl_should_paste (RBRemovableMediaSource *source, RhythmDBEntry *entry)
 {

Modified: trunk/sources/rb-removable-media-source.h
==============================================================================
--- trunk/sources/rb-removable-media-source.h	(original)
+++ trunk/sources/rb-removable-media-source.h	Thu Nov 13 10:55:37 2008
@@ -83,6 +83,9 @@
 GList *		rb_removable_media_source_get_mime_types	(RBRemovableMediaSource *source);
 gboolean	rb_removable_media_source_should_paste		(RBRemovableMediaSource *source,
 								 RhythmDBEntry *entry);
+gboolean        rb_removable_media_source_should_paste_no_duplicate (RBRemovableMediaSource *source,
+								     RhythmDBEntry *entry);
+
 
 G_END_DECLS
 



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