diff options
author | Bastien Nocera <hadess@hadess.net> | 2008-08-14 10:05:52 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@src.gnome.org> | 2008-08-14 10:05:52 +0000 |
commit | 50efbfc867b21454802a2d3978e3c514e06934a2 (patch) | |
tree | 527fecf26381b96adbb4a4667a38c4d60ed2fd4d /src | |
parent | d0e515eab64080cc8c3bd136b553eab234c33060 (diff) |
Always call totem_add_subtitle with the path of the currently playing
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)
svn path=/trunk/; revision=5552
Diffstat (limited to 'src')
-rw-r--r-- | src/totem-playlist.c | 40 | ||||
-rw-r--r-- | src/totem-uri.c | 18 |
2 files changed, 40 insertions, 18 deletions
diff --git a/src/totem-playlist.c b/src/totem-playlist.c index 9e5cf2f0..b862cef7 100644 --- a/src/totem-playlist.c +++ b/src/totem-playlist.c @@ -461,18 +461,39 @@ drop_cb (GtkWidget *widget, 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, ¤t, + -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 @@ void 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 @@ playlist_copy_location_action_callback (GtkAction *action, TotemPlaylist *playli 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 diff --git a/src/totem-uri.c b/src/totem-uri.c index 7ddda179..027c737e 100644 --- a/src/totem-uri.c +++ b/src/totem-uri.c @@ -516,16 +516,20 @@ totem_add_subtitle (GtkWindow *parent, const char *path) 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) { |