totem r5343 - in branches/gnome-2-22: . bindings/python src src/plugins/youtube



Author: pwithnall
Date: Mon Apr  7 23:39:51 2008
New Revision: 5343
URL: http://svn.gnome.org/viewvc/totem?rev=5343&view=rev

Log:
2008-04-07  Philip Withnall  <pwithnall svn gnome org>

	* bindings/python/totem.defs:
	* bindings/python/totem.override:
	* src/plugins/youtube/youtube.py:
	* src/totem-object.c: (totem_get_video_widget_backend_name):
	* src/totem.h: Add runtime checks for flvdemux and souphttpsrc and
	display an error if they're not present for YouTube videos.
	(Closes: #522547)



Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/bindings/python/totem.defs
   branches/gnome-2-22/bindings/python/totem.override
   branches/gnome-2-22/src/plugins/youtube/youtube.py
   branches/gnome-2-22/src/totem-object.c
   branches/gnome-2-22/src/totem.h

Modified: branches/gnome-2-22/bindings/python/totem.defs
==============================================================================
--- branches/gnome-2-22/bindings/python/totem.defs	(original)
+++ branches/gnome-2-22/bindings/python/totem.defs	Mon Apr  7 23:39:51 2008
@@ -401,6 +401,12 @@
   (return-type "GtkWidget*")
 )
 
+(define-method get_video_widget_backend_name
+  (of-object "TotemObject")
+  (c-name "totem_get_video_widget_backend_name")
+  (return-type "char*")
+)
+
 (define-method get_current_time
   (of-object "TotemObject")
   (c-name "totem_get_current_time")
@@ -452,3 +458,18 @@
   )
 )
 
+
+;; From totem-interface.h
+
+(define-method interface_error_with_link
+  (of-object "TotemObject")
+  (c-name "totem_interface_error_with_link")
+  (return-type "none")
+  (parameters
+    '("const-char*" "title")
+    '("const-char*" "reason")
+    '("const-char*" "uri")
+    '("const-char*" "label")
+    '("GtkWindow" "parent")
+  )
+)

Modified: branches/gnome-2-22/bindings/python/totem.override
==============================================================================
--- branches/gnome-2-22/bindings/python/totem.override	(original)
+++ branches/gnome-2-22/bindings/python/totem.override	Mon Apr  7 23:39:51 2008
@@ -66,6 +66,23 @@
 	return Py_None;
 }
 %%
+override totem_interface_error_with_link kwargs
+static PyObject *
+_wrap_totem_interface_error_with_link (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+	static char *kwlist[] = { "title", "reason", "uri", "label", "parent", NULL };
+	char *title, *reason, *uri, *label;
+	PyGObject *parent;
+
+	if (!PyArg_ParseTupleAndKeywords (args, kwargs, "ssssO!:TotemObject.interface_error_with_link", kwlist, &title, &reason, &uri, &label, &PyGtkWindow_Type, &parent))
+		return NULL;
+    
+	totem_interface_error_with_link (title, reason, uri, label, GTK_WINDOW(parent->obj), TOTEM_OBJECT(self->obj));
+    
+	Py_INCREF (Py_None);
+	return Py_None;
+}
+%%
 override totem_plugin_load_interface kwargs
 static PyObject *
 _wrap_totem_plugin_load_interface (PyGObject *self, PyObject *args, PyObject *kwargs)

Modified: branches/gnome-2-22/src/plugins/youtube/youtube.py
==============================================================================
--- branches/gnome-2-22/src/plugins/youtube/youtube.py	(original)
+++ branches/gnome-2-22/src/plugins/youtube/youtube.py	Mon Apr  7 23:39:51 2008
@@ -23,6 +23,7 @@
 	def __init__ (self):
 		totem.Plugin.__init__(self)
 		self.debug = False
+		self.gstreamer_plugins_present = True
 
 		self.max_results = 20
 		self.button_down = False
@@ -41,6 +42,23 @@
 		self.vadjust = {}
 		self.liststore = {}
 	def activate (self, totem_object):
+		"""Check for the availability of the flvdemux and souphttpsrc GStreamer plugins"""
+		bvw_name = totem_object.get_video_widget_backend_name ()
+
+		if bvw_name.find ("GStreamer") != -1:
+			try:
+				import pygst
+				pygst.require ("0.10")
+				import gst
+
+				registry = gst.registry_get_default ()
+				if registry.find_plugin ("flvdemux") == None or registry.find_plugin ("souphttpsrc") == None:
+					"""This means an error will be displayed when they try to play anything"""
+					self.gstreamer_plugins_present = False
+			except ImportError:
+				"""Do nothing; either it's using xine or python-gstreamer isn't installed"""
+
+		"""Continue loading the plugin as before"""		
 		self.builder = self.load_interface ("youtube.ui", True, totem_object.get_main_window (), self)
 		self.totem = totem_object
 
@@ -75,7 +93,7 @@
 		treeview = self.builder.get_object ("yt_treeview_" + treeview_name)
 		treeview.set_property ("totem", self.totem)
 		treeview.connect ("row-activated", self.on_row_activated)
-		treeview.connect ("starting-video", self.on_starting_video)
+		treeview.connect_after ("starting-video", self.on_starting_video)
 		treeview.insert_column_with_attributes (0, _("Videos"), renderer, thumbnail=0, title=1)
 
 		self.vadjust[treeview_name] = treeview.get_vadjustment ()
@@ -99,6 +117,15 @@
 		self.results["related"] = 0
 		self.get_results ("/feeds/videos/" + urllib.quote (youtube_id) + "/related?max-results=" + str (self.max_results), "related")
 	def on_starting_video (self, treeview, path, user_data):
+		"""Display an error if the required GStreamer plugins aren't installed"""
+		if self.gstreamer_plugins_present == False:
+			self.totem.interface_error_with_link (_("Totem cannot play this type of media (%s) because you do not have the appropriate plugins to handle it.") % _("YouTube"),
+							      _("Please install the necessary plugins and restart Totem to be able to play this media."),
+							      "http://www.gnome.org/projects/totem/#codecs";,
+							      _("More information about media plugins"),
+							      self.totem.get_main_window ())
+			return False
+
 		model, rows = treeview.get_selection ().get_selected_rows ()
 		iter = model.get_iter (rows[0])
 		youtube_id = model.get_value (iter, 3)
@@ -110,7 +137,7 @@
 			response = conn.getresponse ()
 		except:
 			print "Could not resolve stream MRL for YouTube video \"" + youtube_id + "\"."
-			return True
+			return False
 
 		if response.status == 303:
 			location = response.getheader("location")

Modified: branches/gnome-2-22/src/totem-object.c
==============================================================================
--- branches/gnome-2-22/src/totem-object.c	(original)
+++ branches/gnome-2-22/src/totem-object.c	Mon Apr  7 23:39:51 2008
@@ -37,6 +37,7 @@
 #include "totem-plugins-engine.h"
 #include "ev-sidebar.h"
 #include "totem-playlist.h"
+#include "bacon-video-widget.h"
 
 enum {
 	PROP_0,
@@ -233,6 +234,12 @@
 	return GTK_WIDGET (totem->bvw);
 }
 
+char *
+totem_get_video_widget_backend_name (Totem *totem)
+{
+	return bacon_video_widget_get_backend_name (totem->bvw);
+}
+
 gint64
 totem_get_current_time (Totem *totem)
 {

Modified: branches/gnome-2-22/src/totem.h
==============================================================================
--- branches/gnome-2-22/src/totem.h	(original)
+++ branches/gnome-2-22/src/totem.h	Mon Apr  7 23:39:51 2008
@@ -166,6 +166,7 @@
 GtkWindow *totem_get_main_window		(Totem *totem);
 GtkUIManager *totem_get_ui_manager		(Totem *totem);
 GtkWidget *totem_get_video_widget		(Totem *totem);
+char *totem_get_video_widget_backend_name	(Totem *totem);
 
 /* Current media information */
 char *	totem_get_short_title			(Totem *totem);



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