totem r5552 - in trunk: . src



Author: hadess
Date: Thu Aug 14 10:05:52 2008
New Revision: 5552
URL: http://svn.gnome.org/viewvc/totem?rev=5552&view=rev

Log:
2008-08-14  Bastien Nocera  <hadess hadess net>

	* src/totem-playlist.c (playlist_select_subtitle_action_callback),
	(playlist_copy_location_action_callback): Always call
	totem_add_subtitle with the path of the currently playing movie
	* src/totem-uri.c (totem_add_subtitle): When passed a path, still
	use the last open path to be in, but also add a shortcut to
	the currently playing movie, so you can easily access it to open
	a subtitle (Closes: #545984)



Modified:
   trunk/ChangeLog
   trunk/src/totem-playlist.c
   trunk/src/totem-uri.c

Modified: trunk/src/totem-playlist.c
==============================================================================
--- trunk/src/totem-playlist.c	(original)
+++ trunk/src/totem-playlist.c	Thu Aug 14 10:05:52 2008
@@ -461,18 +461,39 @@
 void
 playlist_select_subtitle_action_callback (GtkAction *action, TotemPlaylist *playlist)
 {
-	char *subtitle;
+	char *subtitle, *current, *path;
 	GList *l;
+	GFile *file, *dir;
 	TotemPlaylistStatus playing;
 	GtkTreeIter iter;
 
-	subtitle = totem_add_subtitle (totem_playlist_get_toplevel (playlist), NULL);
+	l = gtk_tree_selection_get_selected_rows (playlist->priv->selection, NULL);
+	gtk_tree_model_get_iter (playlist->priv->model, &iter, l->data);
+	g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
+	g_list_free (l);
 
-	if (subtitle == NULL)
+	/* Look for the directory of the current movie */
+	gtk_tree_model_get (playlist->priv->model, &iter,
+			    FILENAME_COL, &current,
+			    -1);
+
+	if (current == NULL)
 		return;
 
-	l = gtk_tree_selection_get_selected_rows (playlist->priv->selection, NULL);
-	gtk_tree_model_get_iter (playlist->priv->model, &iter, l->data);
+	path = NULL;
+	file = g_file_new_for_commandline_arg (current);
+	dir = g_file_get_parent (file);
+	g_object_unref (file);
+	if (dir != NULL) {
+		path = g_file_get_path (dir);
+		g_object_unref (dir);
+	}
+
+	subtitle = totem_add_subtitle (totem_playlist_get_toplevel (playlist), path);
+	g_free (path);
+
+	if (subtitle == NULL)
+		return;
 
 	gtk_tree_model_get (playlist->priv->model, &iter,
 			    PLAYING_COL, &playing,
@@ -495,16 +516,15 @@
 playlist_copy_location_action_callback (GtkAction *action, TotemPlaylist *playlist)
 {
 	GList *l;
-	GtkTreePath *path;
 	GtkClipboard *clip;
 	char *url;
 	GtkTreeIter iter;
 
 	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_iter (playlist->priv->model, &iter, l->data);
+	g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
+	g_list_free (l);
 
 	gtk_tree_model_get (playlist->priv->model,
 			&iter,
@@ -520,8 +540,6 @@
 	gtk_clipboard_set_text (clip, url, -1);
 	g_free (url);
 
-	g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
-	g_list_free (l);
 }
 
 static gboolean

Modified: trunk/src/totem-uri.c
==============================================================================
--- trunk/src/totem-uri.c	(original)
+++ trunk/src/totem-uri.c	Thu Aug 14 10:05:52 2008
@@ -516,16 +516,20 @@
 
 	conf = gconf_client_get_default ();
 	set_folder = TRUE;
-	if (path != NULL) {
+
+	new_path = gconf_client_get_string (conf, "/apps/totem/open_path", NULL);
+	if (new_path != NULL && *new_path != '\0') {
 		set_folder = gtk_file_chooser_set_current_folder_uri
-			(GTK_FILE_CHOOSER (fs), path);
-	} else {
-		new_path = gconf_client_get_string (conf, "/apps/totem/open_path", NULL);
-		if (new_path != NULL && *new_path != '\0') {
+			(GTK_FILE_CHOOSER (fs), new_path);
+	}
+	g_free (new_path);
+
+	if (path != NULL) {
+		if (set_folder == FALSE) {
 			set_folder = gtk_file_chooser_set_current_folder_uri
-				(GTK_FILE_CHOOSER (fs), new_path);
+				(GTK_FILE_CHOOSER (fs), path);
 		}
-		g_free (new_path);
+		gtk_file_chooser_add_shortcut_folder_uri (GTK_FILE_CHOOSER (fs), path, NULL);
 	}
 	
 	if (set_folder == FALSE) {



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