rhythmbox r5675 - in trunk: . data plugins/audiocd shell



Author: hadess
Date: Fri Apr 11 11:48:30 2008
New Revision: 5675
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5675&view=rev

Log:
2008-04-11  Bastien Nocera  <hadess hadess net>

	* data/rhythmbox.desktop.in.in: Say that we handle URLs,
	otherwise only local filenames are passed
	* plugins/audiocd/rb-audiocd-source.c
	(_gnome_vfs_to_gvfs_cdda_uri), (impl_want_uri):
	Handle new-style gvfs cdda URIs
	* shell/rb-shell.c (rb_shell_load_uri): When passing URIs that
	are ignored by the playlist parser, try to find a source that
	it could match.

	Fixes starting Rhythmbox from a CDDA nautilus window, or autostarted
	on insertion (Closes: #526139)



Modified:
   trunk/ChangeLog
   trunk/data/rhythmbox.desktop.in.in
   trunk/plugins/audiocd/rb-audiocd-source.c
   trunk/shell/rb-shell.c

Modified: trunk/data/rhythmbox.desktop.in.in
==============================================================================
--- trunk/data/rhythmbox.desktop.in.in	(original)
+++ trunk/data/rhythmbox.desktop.in.in	Fri Apr 11 11:48:30 2008
@@ -2,7 +2,7 @@
 _Name=Rhythmbox Music Player
 _GenericName=Music Player
 _Comment=Play and organize your music collection
-Exec=rhythmbox
+Exec=rhythmbox %U
 Terminal=false
 Type=Application
 Icon=rhythmbox

Modified: trunk/plugins/audiocd/rb-audiocd-source.c
==============================================================================
--- trunk/plugins/audiocd/rb-audiocd-source.c	(original)
+++ trunk/plugins/audiocd/rb-audiocd-source.c	Fri Apr 11 11:48:30 2008
@@ -768,6 +768,28 @@
 	return actions;
 }
 
+static char *
+_gnome_vfs_to_gvfs_cdda_uri (const char *gnome_vfs_uri)
+{
+	GString *retval;
+	guint i;
+
+	if (strstr (gnome_vfs_uri, "/dev/") == NULL)
+		return NULL;
+
+	retval = g_string_new ("");
+	for (i = 0; gnome_vfs_uri[i] != '\0' ;) {
+		if (strncmp (gnome_vfs_uri + i, "/dev/", 5) == 0)
+			i += 5;
+		else {
+			g_string_append_c (retval, gnome_vfs_uri[i]);
+			i++;
+		}
+	}
+
+	return g_string_free (retval, FALSE);
+}
+
 static guint
 impl_want_uri (RBSource *source, const char *uri)
 {
@@ -792,6 +814,16 @@
 
 	if (strcmp (activation_uri, uri) == 0)
 		retval = 100;
+	else {
+		char *gvfs_uri;
+
+		/* FIXME work-around "new" gvfs style URLs:
+		 * cdda://sr0/ instead of cdda:///dev/sr0 */
+		gvfs_uri = _gnome_vfs_to_gvfs_cdda_uri (activation_uri);
+		if (strncmp (gvfs_uri, uri, strlen (gvfs_uri - 1)) == 0)
+			retval = 100;
+		g_free (gvfs_uri);
+	}
 
 	g_free (activation_uri);
 

Modified: trunk/shell/rb-shell.c
==============================================================================
--- trunk/shell/rb-shell.c	(original)
+++ trunk/shell/rb-shell.c	Fri Apr 11 11:48:30 2008
@@ -3327,13 +3327,21 @@
 								     uri, error))
 					return FALSE;
 			}
-		} else if (result == TOTEM_PL_PARSER_RESULT_IGNORED && rb_uri_is_local (uri)) {
-			/* That happens for directories */
+		} else if ((result == TOTEM_PL_PARSER_RESULT_IGNORED && rb_uri_is_local (uri))
+			   || result == TOTEM_PL_PARSER_RESULT_UNHANDLED) {
+			/* That happens for directories and unhandled schemes, such as CDDA */
 			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))
+				/* Do we have a directory? */
+				if (rb_uri_is_local (uri)) {
+					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 {
+					/* Or something else? */
+					rb_debug ("%s is not handled as a playlist, isn't local, and doesn't have a source, doing nothing", uri);
 					return FALSE;
+				}
 			}
 		} else {
 			rb_debug ("%s didn't parse as a playlist", uri);
@@ -3350,7 +3358,14 @@
 
 	if (play) {
 		if (playlist_source != NULL) {
+			char *name;
+
 			rb_shell_activate_source (shell, playlist_source);
+
+			g_object_get (playlist_source, "name", &name, NULL);
+			rb_debug ("Activated source '%s' for uri %s", name, uri);
+			g_free (name);
+
 			return TRUE;
 		}
 



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