[totem] Hide technical errors from libgdata and fix some reference problems



commit 794b7af90ddb9207cadebfc21890fe5ca7e5ca0c
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Jun 3 18:00:12 2009 +0100

    Hide technical errors from libgdata and fix some reference problems
    
    2009-06-03  Philip Withnall  <philip tecnocode co uk>
    
    	* configure.in:
    	* src/plugins/youtube/totem-youtube.c
    	(increment_progress_bar_fraction), (query_finished_cb),
    	(execute_query): Bump to libgdata >= 0.4.0 to work around
    	locale-dependency problems in string parsing. Fix some reference
    	problems in the YouTube plugin and hide ugly technical error messages
    	from libgdata. (Helps: #584691)
---
 ChangeLog                           |   10 ++++++++++
 configure.in                        |    4 ++--
 src/plugins/youtube/totem-youtube.c |   21 +++++++++++++++++----
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de7e830..0683073 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-06-03  Philip Withnall  <philip tecnocode co uk>
 
+	* configure.in:
+	* src/plugins/youtube/totem-youtube.c
+	(increment_progress_bar_fraction), (query_finished_cb),
+	(execute_query): Bump to libgdata >= 0.4.0 to work around
+	locale-dependency problems in string parsing. Fix some reference
+	problems in the YouTube plugin and hide ugly technical error messages
+	from libgdata. (Helps: #584691)
+
+2009-06-03  Philip Withnall  <philip tecnocode co uk>
+
 	* src/plugins/youtube/totem-youtube.c (new_from_stream_thread): Fix
 	a double-free when downloading YouTube video thumbnails.
 
diff --git a/configure.in b/configure.in
index 46d510f..729e514 100644
--- a/configure.in
+++ b/configure.in
@@ -554,10 +554,10 @@ for plugin in ${used_plugins}; do
 			fi
 		;;
 		youtube)
-			PKG_CHECK_MODULES(LIBGDATA, libgdata >= 0.1.1,
+			PKG_CHECK_MODULES(LIBGDATA, libgdata >= 0.4.0,
 				[HAVE_LIBGDATA=yes], [HAVE_LIBGDATA=no])
 			if test "${HAVE_LIBGDATA}" != "yes" ; then
-				plugin_error_or_ignore "you need libgdata >= 0.1.1 installed for the YouTube plugin"
+				plugin_error_or_ignore "you need libgdata >= 0.4.0 installed for the YouTube plugin"
 				add_plugin="0"
 			fi
 
diff --git a/src/plugins/youtube/totem-youtube.c b/src/plugins/youtube/totem-youtube.c
index becf664..b6df5d7 100644
--- a/src/plugins/youtube/totem-youtube.c
+++ b/src/plugins/youtube/totem-youtube.c
@@ -456,7 +456,8 @@ increment_progress_bar_fraction (TotemYouTubePlugin *self, guint tree_view)
 			gtk_widget_set_sensitive (self->cancel_button, FALSE);
 
 		/* Unref cancellable */
-		g_object_unref (self->cancellable[tree_view]);
+		if (self->cancellable[tree_view] != NULL)
+			g_object_unref (self->cancellable[tree_view]);
 		self->cancellable[tree_view] = NULL;
 	}
 }
@@ -644,7 +645,7 @@ thumbnail_opened_cb (GObject *source_object, GAsyncResult *result, ThumbnailData
 
 	g_debug ("Creating thumbnail from stream");
 	totem_gdk_pixbuf_new_from_stream_at_scale_async (G_INPUT_STREAM (input_stream), THUMBNAIL_WIDTH, -1, TRUE,
-						   self->cancellable[data->tree_view], (GAsyncReadyCallback) thumbnail_loaded_cb, data);
+							 self->cancellable[data->tree_view], (GAsyncReadyCallback) thumbnail_loaded_cb, data);
 	g_object_unref (input_stream);
 }
 
@@ -678,7 +679,17 @@ query_finished_cb (GObject *source_object, GAsyncResult *result, QueryData *data
 
 		/* Error! */
 		window = totem_get_main_window (data->plugin->totem);
-		totem_interface_error (_("Error Searching for Videos"), error->message, window);
+		if (g_error_matches (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_PROTOCOL_ERROR) == TRUE) {
+			/* Hide the ugly technical message libgdata gives behind a nice one telling them it's out of date (which it likely is
+			 * if we're receiving a protocol error). */
+			totem_interface_error (_("Error Searching for Videos"),
+					       _("The response from the server could not be understood. "
+					         "Please check you are running the latest version of libgdata."), window);
+		} else {
+			/* Spew out the error message as provided */
+			totem_interface_error (_("Error Searching for Videos"), error->message, window);
+		}
+
 		g_object_unref (window);
 		g_error_free (error);
 		goto free_data;
@@ -774,8 +785,10 @@ execute_query (TotemYouTubePlugin *self, guint tree_view, gboolean clear_tree_vi
 	QueryData *data;
 
 	/* Cancel previous searches on this tree view */
-	if (self->cancellable[tree_view] != NULL)
+	if (self->cancellable[tree_view] != NULL) {
 		g_cancellable_cancel (self->cancellable[tree_view]);
+		g_object_unref (self->cancellable[tree_view]);
+	}
 
 	/* Clear the tree views */
 	if (clear_tree_view == TRUE)



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