summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2007-11-25 01:17:47 +0000
committerBastien Nocera <hadess@src.gnome.org>2007-11-25 01:17:47 +0000
commit883b19662144e8c2a89b9d6d68c7e5c5fefc3b7b (patch)
tree3c685967850a0d64789ff6bce05906d85309d08b
parentbdebaccb0d3412ee4f7592384a1ad727ad9ada6f (diff)
downloadtotem-883b19662144e8c2a89b9d6d68c7e5c5fefc3b7b.tar.gz
Remove row_activated signal, it's already implemented in the list view
2007-11-25 Bastien Nocera <hadess@hadess.net> * src/plugins/mythtv/totem-mythtv.c: (create_treeview): Remove row_activated signal, it's already implemented in the list view * bindings/python/totem.defs: * data/playlist.ui: * src/totem-menu.c: (clear_playlist_action_callback): * src/totem-object.c: (totem_add_to_playlist_and_play): * src/totem-playlist.c: (playlist_select_subtitle_action_callback), (playlist_copy_location_action_callback), (playlist_show_popup_menu), (totem_playlist_set_reorderable), (update_current_from_playlist), (totem_playlist_add_files), (playlist_remove_files), (init_treeview), (totem_playlist_add_one_mrl), (totem_playlist_add_mrl), (totem_playlist_clear), (totem_playlist_get_current_mrl), (totem_playlist_get_current_title), (totem_playlist_set_previous), (totem_playlist_class_init): * src/totem-playlist.h: * src/totem-session.c: (totem_session_restore): * src/totem-uri.c: (totem_setup_file_filters), (totem_add_subtitle), (totem_add_files): * src/totem-uri.h: * src/totem.c: (totem_action_set_mrl_and_play), (totem_action_open_dialog), (totem_action_load_media), (totem_action_play_media_device), (totem_action_play_media), (totem_action_play_pause), (window_state_event_cb), (totem_open_location_response_cb), (totem_action_set_mrl_with_warning), (totem_action_set_mrl), (totem_action_direction), (totem_action_drop_files), (on_got_redirect), (totem_action_set_playlist_index), (totem_action_remote), (playlist_changed_cb), (current_removed_cb), (subtitle_changed_cb), (on_eos_event), (totem_action_handle_key_press), (playlist_widget_setup), (main): * src/totem.h: Add big patch by Kamil Pawlowski <kamilpe@gmail.com>, adds text subtitle selection in the UI via right-clicking on the playlist item (Closes: #165981) svn path=/trunk/; revision=4901
-rw-r--r--ChangeLog40
-rw-r--r--bindings/python/totem.defs3
-rw-r--r--data/playlist.ui9
-rw-r--r--src/plugins/mythtv/totem-mythtv.c22
-rw-r--r--src/totem-menu.c2
-rw-r--r--src/totem-object.c8
-rw-r--r--src/totem-playlist.c70
-rw-r--r--src/totem-playlist.h4
-rw-r--r--src/totem-session.c16
-rw-r--r--src/totem-uri.c61
-rw-r--r--src/totem-uri.h2
-rw-r--r--src/totem-video-list.c2
-rw-r--r--src/totem.c159
-rw-r--r--src/totem.h7
14 files changed, 298 insertions, 107 deletions
diff --git a/ChangeLog b/ChangeLog
index 7d3e895a8..751f337ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+2007-11-25 Bastien Nocera <hadess@hadess.net>
+
+ * src/plugins/mythtv/totem-mythtv.c: (create_treeview):
+ Remove row_activated signal, it's already implemented in
+ the list view
+
+ * bindings/python/totem.defs:
+ * data/playlist.ui:
+ * src/totem-menu.c: (clear_playlist_action_callback):
+ * src/totem-object.c: (totem_add_to_playlist_and_play):
+ * src/totem-playlist.c: (playlist_select_subtitle_action_callback),
+ (playlist_copy_location_action_callback),
+ (playlist_show_popup_menu), (totem_playlist_set_reorderable),
+ (update_current_from_playlist), (totem_playlist_add_files),
+ (playlist_remove_files), (init_treeview),
+ (totem_playlist_add_one_mrl), (totem_playlist_add_mrl),
+ (totem_playlist_clear), (totem_playlist_get_current_mrl),
+ (totem_playlist_get_current_title), (totem_playlist_set_previous),
+ (totem_playlist_class_init):
+ * src/totem-playlist.h:
+ * src/totem-session.c: (totem_session_restore):
+ * src/totem-uri.c: (totem_setup_file_filters),
+ (totem_add_subtitle), (totem_add_files):
+ * src/totem-uri.h:
+ * src/totem.c: (totem_action_set_mrl_and_play),
+ (totem_action_open_dialog), (totem_action_load_media),
+ (totem_action_play_media_device), (totem_action_play_media),
+ (totem_action_play_pause), (window_state_event_cb),
+ (totem_open_location_response_cb),
+ (totem_action_set_mrl_with_warning), (totem_action_set_mrl),
+ (totem_action_direction), (totem_action_drop_files),
+ (on_got_redirect), (totem_action_set_playlist_index),
+ (totem_action_remote), (playlist_changed_cb), (current_removed_cb),
+ (subtitle_changed_cb), (on_eos_event),
+ (totem_action_handle_key_press), (playlist_widget_setup), (main):
+ * src/totem.h:
+ Add big patch by Kamil Pawlowski <kamilpe@gmail.com>, adds text
+ subtitle selection in the UI via right-clicking on the playlist
+ item (Closes: #165981)
+
2007-11-24 Philip Withnall <pwithnall@svn.gnome.org>
* src/totem-cell-renderer-video.c: (get_size): Render the
diff --git a/bindings/python/totem.defs b/bindings/python/totem.defs
index 963fa81d0..6035dd83b 100644
--- a/bindings/python/totem.defs
+++ b/bindings/python/totem.defs
@@ -275,6 +275,7 @@
(return-type "gboolean")
(parameters
'("const-char*" "mrl")
+ '("const-char*" "subtitle")
)
)
@@ -284,6 +285,7 @@
(return-type "none")
(parameters
'("const-char*" "mrl")
+ '("const-char*" "subtitle")
)
)
@@ -293,6 +295,7 @@
(return-type "gboolean")
(parameters
'("const-char*" "mrl")
+ '("const-char*" "subtitle")
'("gboolean" "warn")
)
)
diff --git a/data/playlist.ui b/data/playlist.ui
index 6cc970fbd..c9607c19c 100644
--- a/data/playlist.ui
+++ b/data/playlist.ui
@@ -22,12 +22,21 @@
<signal name="activate" handler="playlist_copy_location_action_callback"/>
</object>
</child>
+ <child>
+ <object class="GtkAction" id="select-subtitle">
+ <property name="label" translatable="yes">Select text subtitle...</property>
+ <property name="tooltip" translatable="yes">Select a file to use for text subtitles</property>
+ <property name="stock-id">gtk-open</property>
+ <signal name="activate" handler="playlist_select_subtitle_action_callback"/>
+ </object>
+ </child>
</object>
</child>
<ui>
<popup name="totem-playlist-popup">
<menuitem name="remove" action="remove"/>
<menuitem name="copy-location" action="copy-location"/>
+ <menuitem name="select-subtitle" action="select-subtitle"/>
</popup>
</ui>
</object>
diff --git a/src/plugins/mythtv/totem-mythtv.c b/src/plugins/mythtv/totem-mythtv.c
index 9254b711a..ac77d40e8 100644
--- a/src/plugins/mythtv/totem-mythtv.c
+++ b/src/plugins/mythtv/totem-mythtv.c
@@ -172,25 +172,6 @@ get_thumbnail (TotemMythtvPlugin *plugin, char *fname)
}
static void
-row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- TotemMythtvPlugin *plugin)
-{
- GtkTreeIter iter;
- char *uri;
-
- if (gtk_tree_model_get_iter (plugin->model, &iter, path) == FALSE)
- g_return_if_reached ();
-
- gtk_tree_model_get (plugin->model, &iter,
- URI_COL, &uri, -1);
- g_return_if_fail (uri != NULL);
-
- totem_action_set_mrl_and_play (plugin->totem, uri);
-}
-
-static void
create_treeview (TotemMythtvPlugin *plugin)
{
TotemCellRendererVideo *renderer;
@@ -220,9 +201,6 @@ create_treeview (TotemMythtvPlugin *plugin)
NULL);
gtk_tree_view_set_headers_visible (plugin->treeview, FALSE);
-
- g_signal_connect (G_OBJECT (plugin->treeview), "row-activated",
- G_CALLBACK (row_activated_cb), plugin);
}
static void
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 6a10fd79c..b6b272a4c 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -1252,7 +1252,7 @@ void
clear_playlist_action_callback (GtkAction *action, Totem *totem)
{
totem_playlist_clear (totem->playlist);
- totem_action_set_mrl (totem, NULL);
+ totem_action_set_mrl (totem, NULL, NULL);
}
static const GtkActionEntry seek_entries_ltr[] = {
diff --git a/src/totem-object.c b/src/totem-object.c
index 52a32313c..19e7eeb55 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -254,12 +254,14 @@ totem_add_to_playlist_and_play (Totem *totem,
if (playlist_changed)
{
- char *mrl;
+ char *mrl, *subtitle;
+ subtitle = NULL;
totem_playlist_set_current (totem->playlist, end + 1);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
}
}
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 31b7ac904..ed071e154 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -49,6 +49,7 @@ void playlist_remove_button_clicked (GtkWidget *button, TotemPlaylist *playlist)
void totem_playlist_up_files (GtkWidget *widget, TotemPlaylist *playlist);
void totem_playlist_down_files (GtkWidget *widget, TotemPlaylist *playlist);
void playlist_copy_location_action_callback (GtkAction *action, TotemPlaylist *playlist);
+void playlist_select_subtitle_action_callback (GtkAction *action, TotemPlaylist *playlist);
void playlist_remove_action_callback (GtkAction *action, TotemPlaylist *playlist);
typedef gboolean (*PlaylistCallback) (TotemPlaylist *playlist, const char *mrl,
@@ -118,6 +119,7 @@ enum {
CURRENT_REMOVED,
REPEAT_TOGGLED,
SHUFFLE_TOGGLED,
+ SUBTITLE_CHANGED,
LAST_SIGNAL
};
@@ -129,6 +131,7 @@ enum {
CACHE_TITLE_COL,
CACHE_ARTIST_COL,
CACHE_ALBUM_COL,
+ SUBTITLE_URI_COL,
NUM_COLS
};
@@ -444,6 +447,39 @@ drop_cb (GtkWidget *widget,
}
void
+playlist_select_subtitle_action_callback (GtkAction *action, TotemPlaylist *playlist)
+{
+ char *subtitle;
+ GList *l;
+ TotemPlaylistStatus playing;
+ GtkTreeIter iter;
+
+ subtitle = totem_add_subtitle (totem_playlist_get_toplevel (playlist), NULL);
+
+ if (subtitle == NULL)
+ return;
+
+ l = gtk_tree_selection_get_selected_rows (playlist->_priv->selection, NULL);
+ gtk_tree_model_get_iter (playlist->_priv->model, &iter, l->data);
+
+ gtk_tree_model_get (playlist->_priv->model, &iter,
+ PLAYING_COL, &playing,
+ -1);
+
+ gtk_list_store_set (GTK_LIST_STORE(playlist->_priv->model), &iter,
+ SUBTITLE_URI_COL, subtitle,
+ -1);
+
+ if (playing != TOTEM_PLAYLIST_STATUS_NONE) {
+ g_signal_emit (G_OBJECT (playlist),
+ totem_playlist_table_signals[SUBTITLE_CHANGED], 0,
+ NULL);
+ }
+
+ g_free(subtitle);
+}
+
+void
playlist_copy_location_action_callback (GtkAction *action, TotemPlaylist *playlist)
{
GList *l;
@@ -1251,6 +1287,7 @@ init_treeview (GtkWidget *treeview, TotemPlaylist *playlist)
G_TYPE_BOOLEAN,
G_TYPE_STRING,
G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_STRING));
/* the treeview */
@@ -1783,7 +1820,7 @@ totem_playlist_clear_with_gnome_vfs_volume (TotemPlaylist *playlist,
}
char *
-totem_playlist_get_current_mrl (TotemPlaylist *playlist)
+totem_playlist_get_current_mrl (TotemPlaylist *playlist, char **subtitle)
{
GtkTreeIter iter;
char *path;
@@ -1794,13 +1831,19 @@ totem_playlist_get_current_mrl (TotemPlaylist *playlist)
return NULL;
if (gtk_tree_model_get_iter (playlist->_priv->model, &iter,
- playlist->_priv->current) == FALSE)
+ playlist->_priv->current) == FALSE)
return NULL;
- gtk_tree_model_get (playlist->_priv->model,
- &iter,
- URI_COL, &path,
- -1);
+ if (subtitle != NULL) {
+ gtk_tree_model_get (playlist->_priv->model, &iter,
+ URI_COL, &path,
+ SUBTITLE_URI_COL, subtitle,
+ -1);
+ } else {
+ gtk_tree_model_get (playlist->_priv->model, &iter,
+ URI_COL, &path,
+ -1);
+ }
return path;
}
@@ -2274,7 +2317,7 @@ totem_playlist_class_init (TotemPlaylistClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TotemPlaylistClass,
- current_removed),
+ current_removed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -2283,7 +2326,7 @@ totem_playlist_class_init (TotemPlaylistClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TotemPlaylistClass,
- repeat_toggled),
+ repeat_toggled),
NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
@@ -2292,9 +2335,18 @@ totem_playlist_class_init (TotemPlaylistClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TotemPlaylistClass,
- shuffle_toggled),
+ shuffle_toggled),
NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ totem_playlist_table_signals[SUBTITLE_CHANGED] =
+ g_signal_new ("subtitle-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (TotemPlaylistClass,
+ subtitle_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
diff --git a/src/totem-playlist.h b/src/totem-playlist.h
index b4213c987..2edbca970 100644
--- a/src/totem-playlist.h
+++ b/src/totem-playlist.h
@@ -65,6 +65,7 @@ struct TotemPlaylistClass {
void (*current_removed) (TotemPlaylist *playlist);
void (*repeat_toggled) (TotemPlaylist *playlist, gboolean repeat);
void (*shuffle_toggled) (TotemPlaylist *playlist, gboolean toggled);
+ void (*subtitle_changed) (TotemPlaylist *playlist);
};
GtkType totem_playlist_get_type (void);
@@ -91,7 +92,8 @@ void totem_playlist_save_current_playlist_ext (TotemPlaylist *playlist,
gboolean totem_playlist_clear (TotemPlaylist *playlist);
void totem_playlist_clear_with_gnome_vfs_volume (TotemPlaylist *playlist,
GnomeVFSVolume *volume);
-char *totem_playlist_get_current_mrl (TotemPlaylist *playlist);
+char *totem_playlist_get_current_mrl (TotemPlaylist *playlist,
+ char **subtitle);
char *totem_playlist_get_current_title (TotemPlaylist *playlist,
gboolean *custom);
char *totem_playlist_get_title (TotemPlaylist *playlist,
diff --git a/src/totem-session.c b/src/totem-session.c
index 61e9741cc..16d0d9419 100644
--- a/src/totem-session.c
+++ b/src/totem-session.c
@@ -122,17 +122,17 @@ totem_session_setup (Totem *totem, char **argv)
void
totem_session_restore (Totem *totem, char **filenames)
{
- char *mrl, *uri;
+ char *mrl, *uri, *subtitle;
g_return_if_fail (filenames[0] != NULL);
uri = filenames[0];
+ subtitle = NULL;
totem_signal_block_by_data (totem->playlist, totem);
- if (totem_playlist_add_mrl_with_cursor (totem->playlist, uri, NULL) == FALSE)
- {
+ if (totem_playlist_add_mrl_with_cursor (totem->playlist, uri, NULL) == FALSE) {
totem_signal_unblock_by_data (totem->playlist, totem);
- totem_action_set_mrl (totem, NULL);
+ totem_action_set_mrl (totem, NULL, NULL);
g_free (uri);
return;
}
@@ -141,18 +141,18 @@ totem_session_restore (Totem *totem, char **filenames)
if (totem->index != 0)
totem_playlist_set_current (totem->playlist, totem->index);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
- totem_action_set_mrl_with_warning (totem, mrl, FALSE);
+ totem_action_set_mrl_with_warning (totem, mrl, subtitle, FALSE);
- if (totem->seek_to != 0)
- {
+ if (totem->seek_to != 0) {
bacon_video_widget_seek_time (totem->bvw,
totem->seek_to, NULL);
}
bacon_video_widget_pause (totem->bvw);
g_free (mrl);
+ g_free (subtitle);
return;
}
diff --git a/src/totem-uri.c b/src/totem-uri.c
index fb04d309a..f40f88f20 100644
--- a/src/totem-uri.c
+++ b/src/totem-uri.c
@@ -35,6 +35,7 @@
#include "totem-private.h"
static GtkFileFilter *filter_all = NULL;
+static GtkFileFilter *filter_subs = NULL;
static GtkFileFilter *filter_supported = NULL;
static GtkFileFilter *filter_audio = NULL;
static GtkFileFilter *filter_video = NULL;
@@ -432,6 +433,15 @@ totem_setup_file_filters (void)
gtk_file_filter_add_mime_type (filter_video, "application/x-cd-image");
gtk_file_filter_add_mime_type (filter_video, "application/x-cue");
g_object_ref (filter_video);
+
+ /* Subtitles files */
+ filter_subs = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter_subs, _("Subtitle files"));
+ gtk_file_filter_add_mime_type (filter_subs, "application/x-subrip"); /* *.srt */
+ gtk_file_filter_add_mime_type (filter_subs, "text/plain"); /* *.asc, *.txt */
+ /* FIXME add missing *.sub, *.smi, and *.ssa */
+ g_object_ref (filter_subs);
+
}
void
@@ -487,6 +497,57 @@ totem_add_pictures_dir (GtkWidget *chooser)
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), dir, NULL);
}
+char *
+totem_add_subtitle (GtkWindow *parent, const char *path)
+{
+ GtkWidget *fs;
+ GConfClient *conf;
+ char *new_path;
+ char *subtitle = NULL;
+ gboolean set_folder;
+
+ fs = gtk_file_chooser_dialog_new (_("Select text subtitle"),
+ parent,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fs), TRUE);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fs), filter_all);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fs), filter_subs);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fs), filter_subs);
+
+ conf = gconf_client_get_default ();
+ set_folder = TRUE;
+ if (path != NULL) {
+ 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') {
+ set_folder = gtk_file_chooser_set_current_folder_uri
+ (GTK_FILE_CHOOSER (fs), new_path);
+ }
+ g_free (new_path);
+ }
+
+ if (set_folder == FALSE) {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fs),
+ g_get_home_dir ());
+ }
+ totem_add_default_dirs (GTK_FILE_CHOOSER (fs));
+
+ if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT) {
+ char *filename;
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs));
+ subtitle = g_filename_to_uri (filename, NULL, NULL);
+ g_free(filename);
+ }
+
+ gtk_widget_destroy (fs);
+ return subtitle;
+}
+
GSList *
totem_add_files (GtkWindow *parent, const char *path)
{
diff --git a/src/totem-uri.h b/src/totem-uri.h
index e08ce4fe5..3b3f1d4a4 100644
--- a/src/totem-uri.h
+++ b/src/totem-uri.h
@@ -42,6 +42,8 @@ char* totem_uri_get_subtitle_uri (const char *uri);
char* totem_uri_escape_for_display (const char *uri);
GSList* totem_add_files (GtkWindow *parent,
const char *path);
+char* totem_add_subtitle (GtkWindow *parent,
+ const char *path);
void totem_add_pictures_dir (GtkWidget *chooser);
G_END_DECLS
diff --git a/src/totem-video-list.c b/src/totem-video-list.c
index ae553ed50..5a468bc19 100644
--- a/src/totem-video-list.c
+++ b/src/totem-video-list.c
@@ -119,7 +119,7 @@ totem_video_list_init (TotemVideoList *self)
g_signal_connect (self, "row-activated", G_CALLBACK (row_activated_cb), NULL);
g_signal_connect (self, "query-tooltip", G_CALLBACK (query_tooltip_cb), NULL);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (self)),
- "changed", G_CALLBACK (selection_changed_cb), GTK_TREE_VIEW (self));
+ "changed", G_CALLBACK (selection_changed_cb), GTK_TREE_VIEW (self));
}
static void
diff --git a/src/totem.c b/src/totem.c
index 7543129bc..71003b191 100644
--- a/src/totem.c
+++ b/src/totem.c
@@ -420,9 +420,9 @@ totem_action_seek (Totem *totem, double pos)
}
void
-totem_action_set_mrl_and_play (Totem *totem, const char *mrl)
+totem_action_set_mrl_and_play (Totem *totem, const char *mrl, const char *subtitle)
{
- if (totem_action_set_mrl (totem, mrl) != FALSE)
+ if (totem_action_set_mrl (totem, mrl, subtitle) != FALSE)
totem_action_play (totem);
}
@@ -450,11 +450,13 @@ totem_action_open_dialog (Totem *totem, const char *path, gboolean play)
g_slist_free (filenames);
if (play != FALSE) {
- char *mrl;
+ char *mrl, *subtitle;
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ subtitle = NULL;
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
}
return TRUE;
@@ -552,8 +554,8 @@ totem_action_play_media_device (Totem *totem, const char *device)
char *mrl;
if (totem_action_load_media_device (totem, device) != FALSE) {
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, NULL);
+ totem_action_set_mrl_and_play (totem, mrl, NULL);
g_free (mrl);
}
}
@@ -564,8 +566,8 @@ totem_action_play_media (Totem *totem, TotemDiscMediaType type, const char *devi
char *mrl;
if (totem_action_load_media (totem, type, device) != FALSE) {
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, NULL);
+ totem_action_set_mrl_and_play (totem, mrl, NULL);
g_free (mrl);
}
}
@@ -582,16 +584,17 @@ totem_action_play_pause (Totem *totem)
{
if (totem->mrl == NULL)
{
- char *mrl;
+ char *mrl, *subtitle;
/* Try to pull an mrl from the playlist */
- mrl = totem_playlist_get_current_mrl (totem->playlist);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
if (mrl == NULL) {
play_pause_set_label (totem, STATE_STOPPED);
return;
} else {
- totem_action_set_mrl_and_play (totem, mrl);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
return;
}
}
@@ -719,16 +722,17 @@ totem_open_location_response_cb (GtkDialog *dialog, gint response, Totem *totem)
if (uri != NULL)
{
- char *mrl;
+ char *mrl, *subtitle;
const char *filenames[2];
filenames[0] = uri;
filenames[1] = NULL;
totem_action_open_files (totem, (char **) filenames);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
}
g_free (uri);
@@ -868,8 +872,10 @@ update_mrl_label (Totem *totem, const char *name)
}
gboolean
-totem_action_set_mrl_with_warning (Totem *totem, const char *mrl,
- gboolean warn)
+totem_action_set_mrl_with_warning (Totem *totem,
+ const char *mrl,
+ const char *subtitle,
+ gboolean warn)
{
gboolean retval = TRUE;
@@ -915,16 +921,18 @@ totem_action_set_mrl_with_warning (Totem *totem, const char *mrl,
} else {
gboolean caps;
gdouble volume;
- char *subtitle_uri = NULL;
+ char *autoload_sub = NULL;
GError *err = NULL;
bacon_video_widget_set_logo_mode (totem->bvw, FALSE);
- if (totem->autoload_subs != FALSE)
- subtitle_uri = totem_uri_get_subtitle_uri (mrl);
+ if (subtitle == NULL && totem->autoload_subs != FALSE)
+ autoload_sub = totem_uri_get_subtitle_uri (mrl);
+
totem_gdk_window_set_waiting_cursor (totem->win->window);
- retval = bacon_video_widget_open_with_subtitle (totem->bvw,
- mrl, subtitle_uri, &err);
+ retval = bacon_video_widget_open_with_subtitle (totem->bvw, mrl,
+ subtitle ? subtitle : autoload_sub, &err);
+ g_free (autoload_sub);
gdk_window_set_cursor (totem->win->window, NULL);
totem->mrl = g_strdup (mrl);
@@ -983,9 +991,9 @@ totem_action_set_mrl_with_warning (Totem *totem, const char *mrl,
}
gboolean
-totem_action_set_mrl (Totem *totem, const char *mrl)
+totem_action_set_mrl (Totem *totem, const char *mrl, const char *subtitle)
{
- return totem_action_set_mrl_with_warning (totem, mrl, TRUE);
+ return totem_action_set_mrl_with_warning (totem, mrl, subtitle, TRUE);
}
static gboolean
@@ -1019,11 +1027,14 @@ totem_action_direction (Totem *totem, TotemPlaylistDirection dir)
|| bacon_video_widget_is_seekable (totem->bvw) == FALSE
|| totem_time_within_seconds (totem) != FALSE)
{
- char *mrl;
+ char *mrl, *subtitle;
+ subtitle = NULL;
totem_playlist_set_direction (totem->playlist, dir);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
+
+ g_free (subtitle);
g_free (mrl);
} else {
totem_action_seek (totem, 0);
@@ -1286,14 +1297,15 @@ totem_action_drop_files (Totem *totem, GtkSelectionData *data,
/* ... and reconnect because we're nice people */
if (cleared != FALSE)
{
- char *mrl;
+ char *mrl, *subtitle;
g_signal_connect (G_OBJECT (totem->playlist),
"changed", G_CALLBACK (playlist_changed_cb),
totem);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
}
return TRUE;
@@ -1369,7 +1381,7 @@ on_got_redirect (BaconVideoWidget *bvw, const char *mrl, Totem *totem)
{
gchar *old_mrl, *new_mrl;
- old_mrl = totem_playlist_get_current_mrl (TOTEM_PLAYLIST (totem->playlist));
+ old_mrl = totem_playlist_get_current_mrl (TOTEM_PLAYLIST (totem->playlist), NULL);
new_mrl = totem_pl_parser_resolve_url (old_mrl, mrl);
g_free (old_mrl);
@@ -1857,12 +1869,14 @@ totem_action_next_angle (Totem *totem)
void
totem_action_set_playlist_index (Totem *totem, guint index)
{
- char *mrl;
+ char *mrl, *subtitle;
+ subtitle = NULL;
totem_playlist_set_current (totem->playlist, index);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_and_play (totem, mrl);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
}
void
@@ -1915,7 +1929,7 @@ totem_action_remote (Totem *totem, TotemRemoteCommand cmd, const char *url)
if (url == NULL) {
bacon_video_widget_close (totem->bvw);
totem_file_closed (totem);
- totem_action_set_mrl (totem, NULL);
+ totem_action_set_mrl (totem, NULL, NULL);
break;
}
if (strcmp (url, "dvd:") == 0) {
@@ -2068,17 +2082,20 @@ gboolean totem_action_remote_get_setting (Totem *totem,
static void
playlist_changed_cb (GtkWidget *playlist, Totem *totem)
{
- char *mrl;
+ char *mrl, *subtitle;
+ subtitle = NULL;
update_buttons (totem);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
if (mrl == NULL)
return;
if (totem_playlist_get_playing (totem->playlist) == TOTEM_PLAYLIST_STATUS_NONE)
- totem_action_set_mrl_and_play (totem, mrl);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
+
g_free (mrl);
+ g_free (subtitle);
}
static void
@@ -2090,23 +2107,39 @@ item_activated_cb (GtkWidget *playlist, Totem *totem)
static void
current_removed_cb (GtkWidget *playlist, Totem *totem)
{
- char *mrl;
+ char *mrl, *subtitle;
/* Set play button status */
+ subtitle = NULL;
play_pause_set_label (totem, STATE_STOPPED);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
- if (mrl == NULL)
- {
+ if (mrl == NULL) {
+ g_free (subtitle);
totem_playlist_set_at_start (totem->playlist);
update_buttons (totem);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
} else {
update_buttons (totem);
}
- totem_action_set_mrl_and_play (totem, mrl);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
g_free (mrl);
+ g_free (subtitle);
+}
+
+static void
+subtitle_changed_cb (GtkWidget *playlist, Totem *totem)
+{
+ char *mrl, *subtitle;
+
+ totem_action_stop (totem);
+ subtitle = NULL;
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_and_play (totem, mrl, subtitle);
+
+ g_free (mrl);
+ g_free (subtitle);
}
static void
@@ -2212,16 +2245,18 @@ on_eos_event (GtkWidget *widget, Totem *totem)
if (totem_playlist_has_next_mrl (totem->playlist) == FALSE
&& totem_playlist_get_repeat (totem->playlist) == FALSE)
{
- char *mrl;
+ char *mrl, *subtitle;
/* Set play button status */
totem_playlist_set_at_start (totem->playlist);
update_buttons (totem);
totem_action_stop (totem);
- mrl = totem_playlist_get_current_mrl (totem->playlist);
- totem_action_set_mrl_with_warning (totem, mrl, FALSE);
+ subtitle = NULL;
+ mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+ totem_action_set_mrl_with_warning (totem, mrl, subtitle, FALSE);
bacon_video_widget_pause (totem->bvw);
g_free (mrl);
+ g_free (subtitle);
} else {
totem_action_next (totem);
}
@@ -2866,23 +2901,27 @@ playlist_widget_setup (Totem *totem)
gtk_widget_show_all (GTK_WIDGET (totem->playlist));
g_signal_connect (G_OBJECT (totem->playlist), "active-name-changed",
- G_CALLBACK (on_playlist_change_name), totem);
+ G_CALLBACK (on_playlist_change_name), totem);
g_signal_connect (G_OBJECT (totem->playlist), "item-activated",
- G_CALLBACK (item_activated_cb), totem);
+ G_CALLBACK (item_activated_cb), totem);
g_signal_connect (G_OBJECT (totem->playlist),
- "changed", G_CALLBACK (playlist_changed_cb),
- totem);
+ "changed", G_CALLBACK (playlist_changed_cb),
+ totem);
g_signal_connect (G_OBJECT (totem->playlist),
- "current-removed", G_CALLBACK (current_removed_cb),
- totem);
+ "current-removed", G_CALLBACK (current_removed_cb),
+ totem);
g_signal_connect (G_OBJECT (totem->playlist),
- "repeat-toggled",
- G_CALLBACK (playlist_repeat_toggle_cb),
- totem);
+ "repeat-toggled",
+ G_CALLBACK (playlist_repeat_toggle_cb),
+ totem);
g_signal_connect (G_OBJECT (totem->playlist),
- "shuffle-toggled",
- G_CALLBACK (playlist_shuffle_toggle_cb),
- totem);
+ "shuffle-toggled",
+ G_CALLBACK (playlist_shuffle_toggle_cb),
+ totem);
+ g_signal_connect (G_OBJECT (totem->playlist),
+ "subtitle-changed",
+ G_CALLBACK (subtitle_changed_cb),
+ totem);
}
static void
@@ -3171,7 +3210,7 @@ main (int argc, char **argv)
} else if (optionstate.filenames != NULL && totem_action_open_files (totem, optionstate.filenames)) {
totem_action_play_pause (totem);
} else {
- totem_action_set_mrl (totem, NULL);
+ totem_action_set_mrl (totem, NULL, NULL);
}
/* Set the logo at the last minute so we won't try to show it before a video */
diff --git a/src/totem.h b/src/totem.h
index 884497ad4..483150eb2 100644
--- a/src/totem.h
+++ b/src/totem.h
@@ -130,12 +130,15 @@ void totem_action_seek_time (Totem *totem, gint64 sec);
void totem_action_seek_relative (Totem *totem, gint64 offset);
void totem_action_volume_relative (Totem *totem, double off_pct);
gboolean totem_action_set_mrl (Totem *totem,
- const char *mrl);
+ const char *mrl,
+ const char *subtitle);
void totem_action_set_mrl_and_play (Totem *totem,
- const char *mrl);
+ const char *mrl,
+ const char *subtitle);
gboolean totem_action_set_mrl_with_warning (Totem *totem,
const char *mrl,
+ const char *subtitle,
gboolean warn);
void totem_action_play_media (Totem *totem,