rhythmbox r5616 - in trunk: . shell sources



Author: hadess
Date: Fri Mar 14 17:03:37 2008
New Revision: 5616
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5616&view=rev

Log:
2008-03-14  Bastien Nocera  <hadess hadess net>

	* shell/rb-shell.c (rb_shell_load_uri):
	* sources/rb-removable-media-source.c
	(rb_removable_media_source_class_init), (impl_want_uri),
	(impl_uri_is_source): Fix files from removable devices
	being imported in the main library instead of staying in
	their own source when Rhythmbox is activated from nautilus
	(Closes: #519737)



Modified:
   trunk/ChangeLog
   trunk/shell/rb-shell.c
   trunk/sources/rb-removable-media-source.c

Modified: trunk/shell/rb-shell.c
==============================================================================
--- trunk/shell/rb-shell.c	(original)
+++ trunk/shell/rb-shell.c	Fri Mar 14 17:03:37 2008
@@ -3327,6 +3327,14 @@
 								     uri, error))
 					return FALSE;
 			}
+		} else if (result == TOTEM_PL_PARSER_RESULT_IGNORED && rb_uri_is_local (uri)) {
+			/* That happens for directories */
+			playlist_source = rb_shell_guess_source_for_uri (shell, uri);
+			if (playlist_source == NULL || rb_source_uri_is_source (playlist_source, uri) == FALSE) {
+				rb_debug ("%s is a directory, but doesn't have a source, adding as a dir", uri);
+				if (!rb_shell_add_uri (shell, uri, NULL, NULL, error))
+					return FALSE;
+			}
 		} else {
 			rb_debug ("%s didn't parse as a playlist", uri);
 			if (!rb_shell_add_uri (shell, uri, NULL, NULL, error))

Modified: trunk/sources/rb-removable-media-source.c
==============================================================================
--- trunk/sources/rb-removable-media-source.c	(original)
+++ trunk/sources/rb-removable-media-source.c	Fri Mar 14 17:03:37 2008
@@ -62,6 +62,8 @@
 static void impl_paste (RBSource *source, GList *entries);
 #endif
 static gboolean impl_receive_drag (RBSource *asource, GtkSelectionData *data);
+static guint impl_want_uri (RBSource *source, const char *uri);
+static gboolean impl_uri_is_source (RBSource *source, const char *uri);
 
 typedef struct
 {
@@ -102,6 +104,8 @@
 	source_class->impl_delete = NULL;
 	source_class->impl_get_config_widget = NULL;
 	source_class->impl_show_popup = (RBSourceFeatureFunc) rb_false_function;
+	source_class->impl_want_uri = impl_want_uri;
+	source_class->impl_uri_is_source = impl_uri_is_source;
 
 	browser_source_class->impl_get_paned_key = NULL;
 	browser_source_class->impl_has_drop_support = (RBBrowserSourceFeatureFunc) rb_false_function;
@@ -367,6 +371,50 @@
 
 #endif
 
+static guint
+impl_want_uri (RBSource *source, const char *uri)
+{
+	GnomeVFSVolume *volume;
+	char *activation_uri;
+	int retval, len;
+
+	retval = 0;
+
+	/* A default version for use with the audio players
+	 * that use mass storage */
+	if (g_str_has_prefix (uri, "file://") == FALSE)
+		return 0;
+
+	g_object_get (G_OBJECT (source),
+		      "volume", &volume,
+		      NULL);
+	if (volume == NULL)
+		return 0;
+
+	activation_uri = gnome_vfs_volume_get_activation_uri (volume);
+	if (activation_uri == NULL)
+		return 0;
+
+	len = strlen (uri);
+	if (uri[len - 1] == '/') {
+		if (strncmp (uri, activation_uri, len - 1) == 0)
+			retval = 100;
+	} else if (strcmp (uri, activation_uri) == 0)
+		retval = 100;
+
+	g_free (activation_uri);
+
+	return retval;
+}
+
+static gboolean
+impl_uri_is_source (RBSource *source, const char *uri)
+{
+	if (impl_want_uri (source, uri) == 100)
+		return TRUE;
+	return FALSE;
+}
+
 static RhythmDB *
 get_db_for_source (RBSource *source)
 {



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