Commit 69d6f2ab authored by Adrian Haensler's avatar Adrian Haensler Committed by Jean-Baptiste Kempf

hotkeys: new hotkey for toggling subtitles

A subtitle track chosen by hotkey "v" is remembered in variable "spu-choice".
The hotkey "Shift+v" toggles subtitle visibility.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 298616dd
......@@ -172,6 +172,7 @@ typedef enum vlc_action {
ACTIONID_SUBPOS_DOWN,
ACTIONID_AUDIO_TRACK,
ACTIONID_SUBTITLE_TRACK,
ACTIONID_SUBTITLE_TOGGLE,
ACTIONID_INTF_TOGGLE_FSC,
ACTIONID_INTF_HIDE,
ACTIONID_INTF_BOSS,
......
......@@ -591,12 +591,63 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
i = 0;
else
i++;
var_Set( p_input, "spu-es", list.p_list->p_values[i] );
var_SetInteger( p_input, "spu-es", list.p_list->p_values[i].i_int );
var_SetInteger( p_input, "spu-choice", list.p_list->p_values[i].i_int );
DisplayMessage( p_vout, _("Subtitle track: %s"),
list2.p_list->p_values[i].psz_string );
var_FreeList( &list, &list2 );
}
break;
case ACTIONID_SUBTITLE_TOGGLE:
if( p_input )
{
vlc_value_t list, list2;
int i_count, i_sel_index, i_sel_id, i_old_id, i_new_index;
i_old_id = var_GetInteger( p_input, "spu-es" );
i_sel_id = var_GetInteger( p_input, "spu-choice" );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
&list, &list2 );
i_count = list.p_list->i_count;
if( i_count <= 1 )
{
DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") );
var_FreeList( &list, &list2 );
break;
}
for( i_sel_index = 0; i_sel_index < i_count; i_sel_index++ )
{
if( i_sel_id == list.p_list->p_values[i_sel_index].i_int )
{
break;
}
}
/* if there is nothing to toggle choose the first track */
if( !i_sel_index ) {
i_sel_index = 1;
i_sel_id = list.p_list->p_values[1].i_int;
var_SetInteger( p_input, "spu-choice", i_sel_id );
}
i_new_index = 0;
if( i_old_id != i_sel_id )
{
if( i_sel_index >= i_count )
{
var_SetInteger( p_input, "spu-choice", list.p_list->p_values[0].i_int );
}
else
{
i_new_index = i_sel_index;
}
}
var_SetInteger( p_input, "spu-es", list.p_list->p_values[i_new_index].i_int );
DisplayMessage( p_vout, _("Subtitle track: %s"),
list2.p_list->p_values[i_new_index].psz_string );
var_FreeList( &list, &list2 );
}
break;
case ACTIONID_PROGRAM_SID_NEXT:
case ACTIONID_PROGRAM_SID_PREV:
if( p_input )
......
......@@ -353,6 +353,7 @@ static const struct action actions[] =
{ "subsync-markaudio", ACTIONID_SUBSYNC_MARKAUDIO, },
{ "subsync-marksub", ACTIONID_SUBSYNC_MARKSUB, },
{ "subsync-reset", ACTIONID_SUBSYNC_RESET, },
{ "subtitle-toggle", ACTIONID_SUBTITLE_TOGGLE, },
{ "subtitle-track", ACTIONID_SUBTITLE_TRACK, },
{ "title-next", ACTIONID_TITLE_NEXT, },
{ "title-prev", ACTIONID_TITLE_PREV, },
......
......@@ -210,6 +210,10 @@ void input_ControlVarInit ( input_thread_t *p_input )
text.psz_string = _("Subtitle Track");
var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
var_Create( p_input, "spu-choice", VLC_VAR_INTEGER );
val.i_int = -1;
var_Change( p_input, "spu-choice", VLC_VAR_SETVALUE, &val, NULL );
/* Special read only objects variables for intf */
var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
......
......@@ -1349,6 +1349,8 @@ static const char *const mouse_wheel_texts[] =
#define AUDIO_TRACK_KEY_LONGTEXT N_("Cycle through the available audio tracks(languages).")
#define SUBTITLE_TRACK_KEY_TEXT N_("Cycle subtitle track")
#define SUBTITLE_TRACK_KEY_LONGTEXT N_("Cycle through the available subtitle tracks.")
#define SUBTITLE_TOGGLE_KEY_TEXT N_("Toggle subtitles")
#define SUBTITLE_TOGGLE_KEY_LONGTEXT N_("Toggle subtitle track visibility.")
#define PROGRAM_SID_NEXT_KEY_TEXT N_("Cycle next program Service ID")
#define PROGRAM_SID_NEXT_KEY_LONGTEXT N_("Cycle through the available next program Service IDs (SIDs).")
#define PROGRAM_SID_PREV_KEY_TEXT N_("Cycle previous program Service ID")
......@@ -2306,6 +2308,7 @@ vlc_module_begin ()
# define KEY_AUDIO_TRACK "b"
# define KEY_SUBTITLE_TRACK "v"
# define KEY_SUBTITLE_TOGGLE "Shift+v"
# define KEY_PROGRAM_SID_NEXT "x"
# define KEY_PROGRAM_SID_PREV "Shift+x"
# define KEY_ASPECT_RATIO "a"
......@@ -2476,6 +2479,8 @@ vlc_module_begin ()
AUDI_DEVICE_CYCLE_KEY_LONGTEXT, false )
add_key( "key-subtitle-track", KEY_SUBTITLE_TRACK,
SUBTITLE_TRACK_KEY_TEXT, SUBTITLE_TRACK_KEY_LONGTEXT, false )
add_key( "key-subtitle-toggle", KEY_SUBTITLE_TOGGLE,
SUBTITLE_TOGGLE_KEY_TEXT, SUBTITLE_TOGGLE_KEY_LONGTEXT, false )
add_key( "key-program-sid-next", KEY_PROGRAM_SID_NEXT,
PROGRAM_SID_NEXT_KEY_TEXT, PROGRAM_SID_NEXT_KEY_LONGTEXT, false )
add_key( "key-program-sid-prev", KEY_PROGRAM_SID_PREV,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment