totem r5844 - in trunk: . data src
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: totem r5844 - in trunk: . data src
- Date: Wed, 10 Dec 2008 19:46:08 +0000 (UTC)
Author: hadess
Date: Wed Dec 10 19:46:08 2008
New Revision: 5844
URL: http://svn.gnome.org/viewvc/totem?rev=5844&view=rev
Log:
2008-12-10 Bastien Nocera <hadess hadess net>
* data/totem.ui:
* src/totem-menu.c (select_subtitle_action_callback):
* src/totem-playlist.c (totem_playlist_select_subtitle_dialog),
(playlist_select_subtitle_action_callback):
* src/totem-playlist.h:
* src/totem-uri.c:
* src/totem-uri.h:
* src/totem.c (totem_action_set_mrl_with_warning):
Patch from Kamil Pawlowski <kamilpe gmail com> to allow
selecting a text subtitle for the currently playing
movie, from the View menu (Closes: #499463)
Modified:
trunk/ChangeLog
trunk/data/totem.ui
trunk/src/totem-menu.c
trunk/src/totem-playlist.c
trunk/src/totem-playlist.h
trunk/src/totem-uri.c
trunk/src/totem-uri.h
trunk/src/totem.c
Modified: trunk/data/totem.ui
==============================================================================
--- trunk/data/totem.ui (original)
+++ trunk/data/totem.ui Wed Dec 10 19:46:08 2008
@@ -359,6 +359,14 @@
<property name="hide-if-empty">False</property>
</object>
</child>
+ <child>
+ <object class="GtkAction" id="select-subtitle">
+ <property name="label" translatable="yes">_Select Text Subtitles...</property>
+ <property name="tooltip" translatable="yes">Select a file to use for text subtitles</property>
+ <signal name="activate" handler="select_subtitle_action_callback"/>
+ </object>
+ </child>
+
<placeholder name="subtitle-download-placeholder"/>
<child>
<object class="GtkAction" id="languages-menu">
@@ -470,6 +478,7 @@
<menuitem name="deinterlace" action="deinterlace"/>
<menuitem name="next-angle" action="next-angle"/>
<menuitem name="show-controls" action="show-controls"/>
+ <menuitem name="select-subtitle" action="select-subtitle"/>
<menu name="subtitles" action="subtitles-menu">
<placeholder name="placeholder"/>
</menu>
@@ -509,6 +518,7 @@
<menuitem name="skip-backwards" action="skip-backwards"/>
<menuitem name="show-controls" action="show-controls"/>
<menuitem name="fullscreen" action="fullscreen"/>
+ <menuitem name="select-subtitle" action="select-subtitle"/>
<separator/>
<menu name="popup-languages" action="languages-menu">
<placeholder name="placeholder"/>
Modified: trunk/src/totem-menu.c
==============================================================================
--- trunk/src/totem-menu.c (original)
+++ trunk/src/totem-menu.c Wed Dec 10 19:46:08 2008
@@ -73,6 +73,7 @@
void show_controls_action_callback (GtkToggleAction *action, Totem *totem);
void show_sidebar_action_callback (GtkToggleAction *action, Totem *totem);
void aspect_ratio_changed_callback (GtkRadioAction *action, GtkRadioAction *current, Totem *totem);
+void select_subtitle_action_callback (GtkAction *action, Totem *totem);
void clear_playlist_action_callback (GtkAction *action, Totem *totem);
/* Helper function to escape underscores in labels
@@ -1071,6 +1072,13 @@
}
void
+select_subtitle_action_callback (GtkAction *action, Totem *totem)
+{
+ totem_playlist_select_subtitle_dialog (totem->playlist,
+ TOTEM_PLAYLIST_DIALOG_PLAYING);
+}
+
+void
next_angle_action_callback (GtkAction *action, Totem *totem)
{
totem_action_next_angle (totem);
Modified: trunk/src/totem-playlist.c
==============================================================================
--- trunk/src/totem-playlist.c (original)
+++ trunk/src/totem-playlist.c Wed Dec 10 19:46:08 2008
@@ -261,6 +261,70 @@
gtk_widget_show (error_dialog);
}
+void
+totem_playlist_select_subtitle_dialog(TotemPlaylist *playlist, TotemPlaylistSelectDialog mode)
+{
+ char *subtitle, *current, *path;
+ GFile *file, *dir;
+ TotemPlaylistStatus playing;
+ GtkTreeIter iter;
+
+ if (mode == TOTEM_PLAYLIST_DIALOG_PLAYING) {
+ /* Set subtitle file for the currently playing movie */
+ gtk_tree_model_get_iter (playlist->priv->model, &iter, playlist->priv->current);
+ } else if (mode == TOTEM_PLAYLIST_DIALOG_SELECTED) {
+ /* Set subtitle file in for the first selected playlist item */
+ GList *l;
+
+ 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);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ /* Look for the directory of the current movie */
+ gtk_tree_model_get (playlist->priv->model, &iter,
+ FILENAME_COL, ¤t,
+ -1);
+
+ if (current == NULL)
+ return;
+
+ 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,
+ -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);
+}
+
+
/* This one returns a new string, in UTF8 even if the MRL is encoded
* in the locale's encoding
*/
@@ -471,55 +535,7 @@
void
playlist_select_subtitle_action_callback (GtkAction *action, TotemPlaylist *playlist)
{
- char *subtitle, *current, *path;
- GList *l;
- GFile *file, *dir;
- TotemPlaylistStatus playing;
- GtkTreeIter iter;
-
- 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);
-
- /* Look for the directory of the current movie */
- gtk_tree_model_get (playlist->priv->model, &iter,
- FILENAME_COL, ¤t,
- -1);
-
- if (current == NULL)
- return;
-
- 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,
- -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);
+ totem_playlist_select_subtitle_dialog (playlist, TOTEM_PLAYLIST_DIALOG_SELECTED);
}
void
Modified: trunk/src/totem-playlist.h
==============================================================================
--- trunk/src/totem-playlist.h (original)
+++ trunk/src/totem-playlist.h Wed Dec 10 19:46:08 2008
@@ -46,6 +46,12 @@
TOTEM_PLAYLIST_DIRECTION_PREVIOUS
} TotemPlaylistDirection;
+typedef enum {
+ TOTEM_PLAYLIST_DIALOG_SELECTED,
+ TOTEM_PLAYLIST_DIALOG_PLAYING
+} TotemPlaylistSelectDialog;
+
+
typedef struct TotemPlaylist TotemPlaylist;
typedef struct TotemPlaylistClass TotemPlaylistClass;
typedef struct TotemPlaylistPrivate TotemPlaylistPrivate;
@@ -92,6 +98,8 @@
const char *output);
void totem_playlist_save_current_playlist_ext (TotemPlaylist *playlist,
const char *output, TotemPlParserType type);
+void totem_playlist_select_subtitle_dialog (TotemPlaylist *playlist,
+ TotemPlaylistSelectDialog mode);
/* totem_playlist_clear doesn't emit the current_removed signal, even if it does
* because the caller should know what to do after it's done with clearing */
Modified: trunk/src/totem-uri.c
==============================================================================
--- trunk/src/totem-uri.c (original)
+++ trunk/src/totem-uri.c Wed Dec 10 19:46:08 2008
@@ -170,7 +170,7 @@
return ret;
}
-static gboolean
+gboolean
totem_is_special_mrl (const char *uri)
{
GMount *mount;
Modified: trunk/src/totem-uri.h
==============================================================================
--- trunk/src/totem-uri.h (original)
+++ trunk/src/totem-uri.h Wed Dec 10 19:46:08 2008
@@ -35,6 +35,7 @@
char * totem_create_full_path (const char *path);
GMount * totem_get_mount_for_media (const char *uri);
gboolean totem_playing_dvd (const char *uri);
+gboolean totem_is_special_mrl (const char *uri);
gboolean totem_is_block_device (const char *uri);
void totem_setup_file_monitoring (Totem *totem);
void totem_setup_file_filters (void);
Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c (original)
+++ trunk/src/totem.c Wed Dec 10 19:46:08 2008
@@ -1093,6 +1093,9 @@
/* Clear the playlist */
totem_action_set_sensitivity ("clear-playlist", FALSE);
+ /* Subtitle selection */
+ totem_action_set_sensitivity ("select-subtitle", FALSE);
+
/* Set the logo */
bacon_video_widget_set_logo_mode (totem->bvw, TRUE);
update_mrl_label (totem, NULL);
@@ -1132,6 +1135,9 @@
/* Clear the playlist */
totem_action_set_sensitivity ("clear-playlist", retval);
+ /* Subtitle selection */
+ totem_action_set_sensitivity ("select-subtitle", !totem_is_special_mrl (mrl) && retval);
+
/* Set the playlist */
play_pause_set_label (totem, retval ? STATE_PAUSED : STATE_STOPPED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]