[totem] main: Use signal to collect subtitle URI location



commit 2575313b45c45332938761ce3780ab01a09e8e5a
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Apr 21 21:33:20 2012 +0100

    main: Use signal to collect subtitle URI location
    
    Instead of hard-coding this in our core.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674469

 src/totem-object.c      |   45 ++++++++++++++++++++++++---------------------
 src/totem-preferences.c |    1 -
 src/totem-private.h     |    1 -
 src/totem.h             |    2 ++
 4 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index 5879266..f4cf53f 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -113,7 +113,6 @@ enum {
 	PROP_SEEKABLE,
 	PROP_CURRENT_TIME,
 	PROP_CURRENT_MRL,
-	PROP_AUTOLOAD_SUBTITLES,
 	PROP_REMEMBER_POSITION
 };
 
@@ -122,6 +121,7 @@ enum {
 	FILE_CLOSED,
 	METADATA_UPDATED,
 	GET_USER_AGENT,
+	GET_TEXT_SUBTITLE,
 	LAST_SIGNAL
 };
 
@@ -283,16 +283,6 @@ totem_object_class_init (TotemObjectClass *klass)
 							      NULL, G_PARAM_READABLE));
 
 	/**
-	 * TotemObject:autoload-subtitles:
-	 *
-	 * If %TRUE, Totem will automatically load any subtitle files it finds for each newly opened video.
-	 **/
-	g_object_class_install_property (object_class, PROP_AUTOLOAD_SUBTITLES,
-					 g_param_spec_boolean ("autoload-subtitles", "Autoload subtitles?",
-					                       "Whether to automatically load any subtitle files Totem finds.",
-							       FALSE, G_PARAM_READWRITE));
-
-	/**
 	 * TotemObject:remember-position:
 	 *
 	 * If %TRUE, Totem will remember the position it was at last time a given file was opened.
@@ -371,6 +361,25 @@ totem_object_class_init (TotemObjectClass *klass)
 			      accumulator_first_non_null_wins, NULL,
 			      totemobject_marshal_STRING__STRING,
 			      G_TYPE_STRING, 1, G_TYPE_STRING);
+
+	/**
+	 * TotemObject::get-text-subtitle:
+	 * @totem: the #TotemObject which received the signal
+	 * @mrl: the MRL of the opened stream
+	 *
+	 * The #TotemObject::get-text-subtitle signal is emitted before opening a stream, so that plugins
+	 * have the opportunity to detect or download text subtitles for the stream if necessary.
+	 *
+	 * Return value: allocated string representing the URI of the subtitle to use for @mrl
+	 */
+	totem_table_signals[GET_TEXT_SUBTITLE] =
+		g_signal_new ("get-text-subtitle",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (TotemObjectClass, get_text_subtitle),
+			      accumulator_first_non_null_wins, NULL,
+			      totemobject_marshal_STRING__STRING,
+			      G_TYPE_STRING, 1, G_TYPE_STRING);
 }
 
 static void
@@ -395,10 +404,6 @@ totem_object_set_property (GObject *object,
 	TotemObject *totem = TOTEM_OBJECT (object);
 
 	switch (property_id) {
-		case PROP_AUTOLOAD_SUBTITLES:
-			totem->autoload_subs = g_value_get_boolean (value);
-			g_object_notify (object, "autoload-subtitles");
-			break;
 		case PROP_REMEMBER_POSITION:
 			totem->remember_position = g_value_get_boolean (value);
 			g_object_notify (object, "remember-position");
@@ -438,9 +443,6 @@ totem_object_get_property (GObject *object,
 	case PROP_CURRENT_MRL:
 		g_value_set_string (value, totem->mrl);
 		break;
-	case PROP_AUTOLOAD_SUBTITLES:
-		g_value_set_boolean (value, totem->autoload_subs);
-		break;
 	case PROP_REMEMBER_POSITION:
 		g_value_set_boolean (value, totem->remember_position);
 		break;
@@ -1671,13 +1673,14 @@ totem_action_set_mrl_with_warning (TotemObject *totem,
 		gboolean caps;
 		gdouble volume;
 		char *user_agent;
-		char *autoload_sub = NULL;
+		char *autoload_sub;
 		GError *err = NULL;
 
 		bacon_video_widget_set_logo_mode (totem->bvw, FALSE);
 
-		if (subtitle == NULL && totem->autoload_subs != FALSE)
-			autoload_sub = totem_uri_get_subtitle_uri (mrl);
+		autoload_sub = NULL;
+		if (subtitle == NULL)
+			g_signal_emit (G_OBJECT (totem), totem_table_signals[GET_TEXT_SUBTITLE], 0, mrl, &autoload_sub);
 
 		user_agent = NULL;
 		g_signal_emit (G_OBJECT (totem), totem_table_signals[GET_USER_AGENT], 0, mrl, &user_agent);
diff --git a/src/totem-preferences.c b/src/totem-preferences.c
index eba0657..64e1880 100644
--- a/src/totem-preferences.c
+++ b/src/totem-preferences.c
@@ -360,7 +360,6 @@ totem_setup_preferences (Totem *totem)
 	/* Auto-load subtitles */
 	item = gtk_builder_get_object (totem->xml, "tpw_auto_subtitles_checkbutton");
 	g_settings_bind (totem->settings, "autoload-subtitles", item, "active", G_SETTINGS_BIND_DEFAULT);
-	g_settings_bind (totem->settings, "autoload-subtitles", totem, "autoload-subtitles", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY);
 
 	/* Auto-load external chapters */
 	item = gtk_builder_get_object (totem->xml, "tpw_auto_chapters_checkbutton");
diff --git a/src/totem-private.h b/src/totem-private.h
index 6d025d3..10c4cfd 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -117,7 +117,6 @@ struct _TotemObject {
 	GtkWidget *languages;
 	GList *subtitles_list;
 	GList *language_list;
-	gboolean autoload_subs;
 
 	/* Fullscreen */
 	TotemFullscreen *fs;
diff --git a/src/totem.h b/src/totem.h
index 46de8ab..59a8f95 100644
--- a/src/totem.h
+++ b/src/totem.h
@@ -173,6 +173,8 @@ typedef struct {
 						 guint track_num);
 	char * (*get_user_agent)		(TotemObject *totem,
 						 const char  *mrl);
+	char * (*get_text_subtitle)		(TotemObject *totem,
+						 const char  *mrl);
 } TotemObjectClass;
 
 GType	totem_object_get_type			(void);



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