[totem] Bug 594817 - Hangs playing a search result



commit 93fa0f29dae15fb1fb8ff7e340e390bfb7038127
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Sep 11 00:45:17 2009 +0100

    Bug 594817 - Hangs playing a search result
    
    When querying for info on files we want to add to the recent files,
    we might as well use the async functions, saves us hanging on
    remote files.

 src/totem-menu.c |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 4a27eef..4084ece 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -688,23 +688,20 @@ totem_setup_recent (Totem *totem)
 	totem_recent_manager_changed_callback (totem->recent_manager, totem);
 }
 
-void
-totem_action_add_recent (Totem *totem, const char *uri)
+static void
+recent_info_cb (GFile *file,
+		GAsyncResult *res,
+		Totem *totem)
 {
 	GtkRecentData data;
 	char *groups[] = { NULL, NULL };
-	GFile *file;
 	GFileInfo *file_info;
+	const char *uri;
 
 	memset (&data, 0, sizeof (data));
 
-	if (totem_is_special_mrl (uri) != FALSE)
-		return;
-
-	file = g_file_new_for_uri (uri);
-	file_info = g_file_query_info (file,
-				       G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
-				       G_FILE_QUERY_INFO_NONE, NULL, NULL);
+	file_info = g_file_query_info_finish (file, res, NULL);
+	uri = g_object_get_data (G_OBJECT (file), "uri");
 
 	/* Probably an unsupported URI scheme */
 	if (file_info == NULL) {
@@ -719,7 +716,6 @@ totem_action_add_recent (Totem *totem, const char *uri)
 		g_object_unref (file_info);
 		groups[0] = (gchar*) "Totem";
 	}
-	g_object_unref (file);
 
 	data.app_name = g_strdup (g_get_application_name ());
 	data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
@@ -733,6 +729,23 @@ totem_action_add_recent (Totem *totem, const char *uri)
 	g_free (data.mime_type);
 	g_free (data.app_name);
 	g_free (data.app_exec);
+
+	g_object_unref (file);
+}
+
+void
+totem_action_add_recent (Totem *totem, const char *uri)
+{
+	GFile *file;
+
+	if (totem_is_special_mrl (uri) != FALSE)
+		return;
+
+	file = g_file_new_for_uri (uri);
+	g_object_set_data_full (G_OBJECT (file), "uri", g_strdup (uri), 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);
 }
 
 /* Play Disc menu items */



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