[totem] Use playlist name to add to recent files for streams



commit 28c4d82bc4375044597f90a4f43dc170573ba9b5
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 11 00:57:19 2009 +0100

    Use playlist name to add to recent files for streams
    
    When playing a YouTube video, we probably won't be able to
    get any file information, so remember the display name,
    and use that in the recent files.

 src/totem-menu.c     |    8 +++++---
 src/totem-menu.h     |    4 +++-
 src/totem-object.c   |   10 ++++++----
 src/totem-playlist.c |   17 ++++++++++++-----
 4 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 4084ece..085227d 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -696,16 +696,17 @@ recent_info_cb (GFile *file,
 	GtkRecentData data;
 	char *groups[] = { NULL, NULL };
 	GFileInfo *file_info;
-	const char *uri;
+	const char *uri, *display_name;
 
 	memset (&data, 0, sizeof (data));
 
 	file_info = g_file_query_info_finish (file, res, NULL);
 	uri = g_object_get_data (G_OBJECT (file), "uri");
+	display_name = g_object_get_data (G_OBJECT (file), "display_name");
 
 	/* Probably an unsupported URI scheme */
 	if (file_info == NULL) {
-		data.display_name = NULL;
+		data.display_name = g_strdup (display_name);
 		/* Bogus mime-type, we just want it added */
 		data.mime_type = g_strdup ("video/x-totem-stream");
 		groups[0] = (gchar*) "TotemStreams";
@@ -734,7 +735,7 @@ recent_info_cb (GFile *file,
 }
 
 void
-totem_action_add_recent (Totem *totem, const char *uri)
+totem_action_add_recent (Totem *totem, const char *uri, const char *display_name)
 {
 	GFile *file;
 
@@ -743,6 +744,7 @@ totem_action_add_recent (Totem *totem, const char *uri)
 
 	file = g_file_new_for_uri (uri);
 	g_object_set_data_full (G_OBJECT (file), "uri", g_strdup (uri), g_free);
+	g_object_set_data_full (G_OBJECT (file), "display_name", g_strdup (display_name), g_free);
 	g_file_query_info_async (file,
 				 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
 				 G_FILE_QUERY_INFO_NONE, 0, NULL, (GAsyncReadyCallback) recent_info_cb, totem);
diff --git a/src/totem-menu.h b/src/totem-menu.h
index 8d9a46e..ba93fa8 100644
--- a/src/totem-menu.h
+++ b/src/totem-menu.h
@@ -35,7 +35,9 @@ void totem_sublang_exit (Totem *totem);
 void totem_setup_play_disc (Totem *totem);
 
 void totem_setup_recent (Totem *totem);
-void totem_action_add_recent (Totem *totem, const char *uri);
+void totem_action_add_recent (Totem *totem,
+			      const char *uri,
+			      const char *display_name);
 
 G_END_DECLS
 
diff --git a/src/totem-object.c b/src/totem-object.c
index 1eabec7..5ef642d 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1762,6 +1762,7 @@ totem_action_set_mrl_with_warning (Totem *totem,
 			totem->mrl = NULL;
 			bacon_video_widget_set_logo_mode (totem->bvw, TRUE);
 		} else {
+			char *display_name;
 			/* cast is to shut gcc up */
 			const GtkTargetEntry source_table[] = {
 				{ (gchar*) "text/uri-list", 0, 0 }
@@ -1775,7 +1776,9 @@ totem_action_set_mrl_with_warning (Totem *totem,
 					     source_table, G_N_ELEMENTS (source_table),
 					     GDK_ACTION_COPY);
 
-			totem_action_add_recent (totem, totem->mrl);
+			display_name = totem_playlist_get_current_title (totem->playlist, NULL);
+			totem_action_add_recent (totem, totem->mrl, display_name);
+			g_free (display_name);
 		}
 	}
 	update_buttons (totem);
@@ -2393,10 +2396,9 @@ static void
 on_playlist_change_name (TotemPlaylist *playlist, Totem *totem)
 {
 	char *name;
-	gboolean cur;
 
-	if ((name = totem_playlist_get_current_title (playlist,
-						      &cur)) != NULL) {
+	name = totem_playlist_get_current_title (playlist, NULL);
+	if (name != NULL) {
 		update_mrl_label (totem, name);
 		g_free (name);
 	}
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 9ae3d29..ba1762e 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -2036,11 +2036,18 @@ totem_playlist_get_current_title (TotemPlaylist *playlist, gboolean *custom)
 			&iter,
 			playlist->priv->current);
 
-	gtk_tree_model_get (playlist->priv->model,
-			&iter,
-			FILENAME_COL, &path,
-			TITLE_CUSTOM_COL, custom,
-			-1);
+	if (custom != NULL) {
+		gtk_tree_model_get (playlist->priv->model,
+				    &iter,
+				    FILENAME_COL, &path,
+				    TITLE_CUSTOM_COL, custom,
+				    -1);
+	} else {
+		gtk_tree_model_get (playlist->priv->model,
+				    &iter,
+				    FILENAME_COL, &path,
+				    -1);
+	}
 
 	return path;
 }



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