Index: src/totem-uri.c
===================================================================
--- src/totem-uri.c	(.../trunk)	(wersja 10)
+++ src/totem-uri.c	(.../branches/totem-subtitles)	(wersja 10)
@@ -36,6 +36,7 @@
 
 static GtkFileFilter *filter_all;
 static GtkFileFilter *filter_supported;
+static GtkFileFilter *filter_subtitles;
 
 gboolean
 totem_playing_dvd (const char *uri)
@@ -87,8 +88,44 @@
 	return (S_ISBLK (buf.st_mode));
 }
 
+char * totem_create_full_path (const char *path)
+{
+	char *movie, *subtitle, *full_movie = NULL, *full_subtitle = NULL, *mrl;
+	char *sep = "#subtitle:";
+	int len = 0;
+	
+	movie = totem_uri_get_movie_uri(path);
+	subtitle = totem_uri_get_subtitle_uri(path);
+	full_movie = totem_create_one_full_path(movie);
+
+	if (subtitle != NULL)
+	{
+		full_subtitle = totem_create_one_full_path(subtitle);
+		len += strlen(full_subtitle)+strlen(sep);
+	}
+	
+	len += strlen(full_movie)+1;
+	mrl = g_malloc(len);
+	strcpy(mrl,full_movie);
+	
+	if (subtitle != NULL)
+	{
+		strcpy(mrl+strlen(full_movie),sep);
+		strcpy(mrl+strlen(full_movie)+strlen(sep),full_subtitle);
+		g_free(full_subtitle);
+	}
+
+	g_free(movie);
+	g_free(subtitle);
+	g_free(full_movie);
+
+
+	return mrl;
+}
+
+
 char*
-totem_create_full_path (const char *path)
+totem_create_one_full_path (const char *path)
 {
 	char *retval, *curdir, *curdir_withslash, *escaped;
 
@@ -153,9 +190,28 @@
 };
 
 char *
+totem_uri_get_movie_uri (const char *uri)
+{
+	char *movie = NULL, *after_q = NULL;
+	int len;
+
+	if ((after_q = strstr (uri, "#subtitle:")) != NULL) {
+		len = after_q - uri;
+		movie = g_malloc(len);
+		strncpy(movie,uri,len);
+		movie[len] = '\0';
+	} else {
+		movie = g_strdup(uri);
+	}
+	
+	return movie;
+}
+
+
+char *
 totem_uri_get_subtitle_uri (const char *uri)
 {
-	char *suffix, *subtitle;
+	char *suffix, *subtitle, *after_q;
 	guint len, i;
 	GnomeVFSURI *vfsuri;
 
@@ -163,8 +219,11 @@
 		return NULL;
 	}
 
-	if (strstr (uri, "#subtitle:") != NULL) {
-		return NULL;
+	if ((after_q = strstr (uri, "#subtitle:")) != NULL) {
+		after_q += strlen("#subtitle:");
+		subtitle = g_malloc(strlen(uri) - strlen(after_q) + 1);
+		strcpy(subtitle,after_q);
+		return subtitle;
 	}
 
 	len = strlen (uri);
@@ -227,7 +286,7 @@
 	gtk_file_filter_set_name (filter_all, _("All files"));
 	gtk_file_filter_add_pattern (filter_all, "*");
 	g_object_ref (filter_all);
-
+	
 	filter_supported = gtk_file_filter_new ();
 	gtk_file_filter_set_name (filter_supported,
 			_("Supported files"));
@@ -235,6 +294,17 @@
 		gtk_file_filter_add_mime_type (filter_supported, mime_types[i]);
 	}
 	g_object_ref (filter_supported);
+
+	filter_subtitles = gtk_file_filter_new ();
+	gtk_file_filter_set_name (filter_subtitles, _("Subtitles"));
+	gtk_file_filter_add_pattern (filter_subtitles, "*.asc");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.txt");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.sub");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.srt");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.smi");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.ssa");
+	gtk_file_filter_add_pattern (filter_subtitles, "*.txt");
+	g_object_ref (filter_subtitles);
 }
 
 void
@@ -242,6 +312,7 @@
 {
 	g_object_unref (filter_all);
 	g_object_unref (filter_supported);
+	g_object_unref (filter_subtitles);
 }
 
 GSList *
@@ -296,3 +367,50 @@
 	return filenames;
 }
 
+
+gchar *
+totem_add_subtitle (GtkWindow *parent, const char *path, char **new_path)
+{
+	gchar *filename;
+	GtkWidget *fs;
+	int response;
+	
+	fs = gtk_file_chooser_dialog_new (_("Select subtitles file"),
+	   parent,
+	   GTK_FILE_CHOOSER_ACTION_OPEN,
+	   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+	   GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
+	   NULL);
+
+	gtk_dialog_set_default_response(GTK_DIALOG (fs), GTK_RESPONSE_ACCEPT);
+	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fs), FALSE);
+	gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fs), filter_all);
+	gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fs), filter_subtitles);
+	gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fs), filter_subtitles);
+
+	if (path != NULL) {
+		gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(fs), 
+						path);
+	}
+	
+	response = gtk_dialog_run(GTK_DIALOG(fs));
+	gtk_widget_hide (fs);
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
+	if (response != GTK_RESPONSE_ACCEPT) {
+		gtk_widget_destroy (fs);
+		return NULL;
+	}
+
+	filename = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(fs));
+	if (filename != NULL && new_path != NULL) {
+		*new_path = g_path_get_dirname (filename);
+		gtk_widget_destroy (fs);
+		return filename;
+	}
+	
+	gtk_widget_destroy (fs);
+	return NULL;
+}
+
Index: src/totem-uri.h
===================================================================
--- src/totem-uri.h	(.../trunk)	(wersja 10)
+++ src/totem-uri.h	(.../branches/totem-subtitles)	(wersja 10)
@@ -29,6 +29,7 @@
 G_BEGIN_DECLS
 
 char*		totem_create_full_path	(const char *path);
+char*		totem_create_one_full_path (const char *path);
 gboolean	totem_is_media		(const char *uri);
 gboolean	totem_playing_dvd	(const char *uri);
 gboolean	totem_is_block_device	(const char *uri);
@@ -36,7 +37,11 @@
 void		totem_setup_file_filters (void);
 void		totem_destroy_file_filters (void);
 char*		totem_uri_get_subtitle_uri (const char *uri);
+char*       totem_uri_get_movie_uri (const char *uri);
 char*		totem_uri_escape_for_display (const char *uri);
+gchar*		totem_add_subtitle (GtkWindow *parent, 
+					const char *path, 
+					char **new_path);
 GSList*		totem_add_files		(GtkWindow *parent,
 					 const char *path,
 					 char **new_path);
Index: src/totem-playlist.c
===================================================================
--- src/totem-playlist.c	(.../trunk)	(wersja 10)
+++ src/totem-playlist.c	(.../branches/totem-subtitles)	(wersja 10)
@@ -210,12 +210,14 @@
 static char *
 totem_playlist_mrl_to_title (const gchar *mrl)
 {
-	char *filename_for_display, *filename, *unescaped;
+	char *filename_for_display, *filename, *unescaped, *movie;
 
-	filename = g_path_get_basename (mrl);
+	movie = totem_uri_get_movie_uri(mrl);
+	filename = g_path_get_basename (movie);
 	unescaped = gnome_vfs_unescape_string_for_display (filename);
 
-	g_free (filename);
+	g_free (movie);
+	
 	filename_for_display = g_filename_to_utf8 (unescaped,
 			-1,             /* length */
 			NULL,           /* bytes_read */
@@ -430,13 +432,70 @@
 }
 
 static void
+on_subtitles_add_activate (GtkButton *button, TotemPlaylist *playlist)
+{
+	GList *l;
+	GtkTreePath *path;
+	GtkTreeIter iter;
+	char *mrl, *movie, *url;
+	char *new_path;
+	gchar *subtitle;
+
+	subtitle = totem_add_subtitle (totem_playlist_get_toplevel (playlist),
+					playlist->_priv->path, &new_path);
+	if (subtitle == NULL) return;
+	
+	if (new_path != NULL) {
+		g_free (playlist->_priv->path);
+		playlist->_priv->path = new_path;
+	}
+
+	l = gtk_tree_selection_get_selected_rows(playlist->_priv->selection,
+		NULL);
+	path = l->data;
+
+	gtk_tree_model_get_iter(playlist->_priv->model, &iter, path);
+	gtk_tree_model_get(playlist->_priv->model, 
+		&iter, 
+		URI_COL, 
+		&url, 
+		-1);
+
+	movie = totem_uri_get_movie_uri(url);
+	mrl = g_malloc(strlen(movie)+strlen("#subtitle:")+strlen(subtitle));
+	strcpy(mrl,movie);
+	strcpy(mrl+strlen(mrl),"#subtitle:");
+	strcpy(mrl+strlen(mrl),subtitle);
+	
+	gtk_list_store_set (GTK_LIST_STORE(playlist->_priv->model), 
+		&iter, URI_COL, mrl, -1);
+	
+	if (totem_playlist_gtk_tree_path_equals(
+		path, playlist->_priv->current) != FALSE)
+	{
+		g_signal_emit (G_OBJECT (playlist),
+				totem_playlist_table_signals[CHANGED], 0,
+				NULL);
+		g_signal_handlers_unblock_by_func (playlist->_priv->treeview,
+			(GFunc) drop_cb, playlist);
+	}
+	
+	g_free(url);
+	g_free(movie);
+	g_free(mrl);
+	g_list_foreach(l, (GFunc) gtk_tree_path_free, NULL);
+	g_list_free(l);
+	g_free(subtitle);	
+}
+
+static void
 on_copy1_activate (GtkButton *button, TotemPlaylist *playlist)
 {
 	GList *l;
 	GtkTreePath *path;
 	GtkClipboard *clip;
+	GtkTreeIter iter;
 	char *url;
-	GtkTreeIter iter;
 
 	l = gtk_tree_selection_get_selected_rows (playlist->_priv->selection,
 			NULL);
@@ -1436,6 +1495,10 @@
 	g_signal_connect (G_OBJECT (item), "activate",
 			G_CALLBACK (on_copy1_activate), playlist);
 
+	item = glade_xml_get_widget (playlist->_priv->xml, "subtitles_add");
+	g_signal_connect (G_OBJECT (item), "activate",
+			G_CALLBACK (on_subtitles_add_activate), playlist);
+
 	gtk_widget_add_events (GTK_WIDGET (playlist), GDK_KEY_PRESS_MASK);
 	g_signal_connect (G_OBJECT (playlist), "key_press_event",
 			G_CALLBACK (totem_playlist_key_press), playlist);
Index: src/totem.c
===================================================================
--- src/totem.c	(.../trunk)	(wersja 10)
+++ src/totem.c	(.../branches/totem-subtitles)	(wersja 10)
@@ -763,7 +763,7 @@
 		update_mrl_label (totem, NULL);
 	} else {
 		gboolean caps;
-		char *subtitle_uri;
+		char *subtitle_uri, *movie_uri;
 		GError *err = NULL;
 
 		if (bacon_video_widget_get_logo_mode (totem->bvw) != FALSE)
@@ -773,9 +773,10 @@
 		}
 
 		subtitle_uri = totem_uri_get_subtitle_uri (mrl);
+		movie_uri = totem_uri_get_movie_uri (mrl);
 		totem_gdk_window_set_waiting_cursor (totem->win->window);
 		retval = bacon_video_widget_open_with_subtitle (totem->bvw,
-				mrl, subtitle_uri, &err);
+				movie_uri, subtitle_uri, &err);
 		gdk_window_set_cursor (totem->win->window, NULL);
 		totem->mrl = g_strdup (mrl);
 
Index: data/playlist.glade
===================================================================
--- data/playlist.glade	(.../trunk)	(wersja 10)
+++ data/playlist.glade	(.../branches/totem-subtitles)	(wersja 10)
@@ -336,6 +336,15 @@
       </child>
     </widget>
   </child>
+
+  <child>
+    <widget class="GtkMenuItem" id="subtitles_add">
+      <property name="visible">True</property>
+      <property name="label" translatable="yes">_Add Subtitles</property>
+      <property name="use_underline">True</property>
+      <signal name="activate" handler="on_subtitles_add_activate" last_modification_time="Tue, 14 Mar 2006 18:28:26 GMT"/>
+    </widget>
+  </child>
 </widget>
 
 </glade-interface>
