Commit e3c06996 authored by Christophe Massiot's avatar Christophe Massiot

* Mac OS X port : menus for Program/Title/Chapter/Languages.

parent fb1e2cb9
......@@ -2,7 +2,7 @@
* gtk_menu.c : functions to handle menu items.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: gtk_menu.c,v 1.24 2002/04/19 13:56:11 sam Exp $
* $Id: gtk_menu.c,v 1.25 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -502,9 +502,6 @@ static gint GtkLanguageMenus( gpointer p_data,
gint i_item;
gint i;
/* cast */
p_intf = (intf_thread_t *)p_data;
/* temporary hack to avoid blank menu when an open menu is removed */
......
......@@ -2,7 +2,7 @@
* intf_macosx.c: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: intf_macosx.c,v 1.13 2002/05/06 22:59:46 massiot Exp $
* $Id: intf_macosx.c,v 1.14 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -68,6 +68,8 @@ static int intf_Open( intf_thread_t *p_intf )
p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
p_intf->p_sys->o_port = [[NSPort port] retain];
p_intf->p_sys->b_mute = 0;
p_intf->p_sys->i_part = 0;
p_intf->p_sys->b_disabled_menus = 0;
[[NSApplication sharedApplication] autorelease];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
......
......@@ -2,7 +2,7 @@
* intf_vlc_wrapper.c: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: intf_vlc_wrapper.c,v 1.13 2002/05/09 16:15:15 jlj Exp $
* $Id: intf_vlc_wrapper.c,v 1.14 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -86,7 +86,6 @@ static Intf_VLCWrapper *o_intf = nil;
return( 1 );
}
#if 0
if( p_input_bank->pp_input[0] != NULL )
{
vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
......@@ -104,11 +103,10 @@ static Intf_VLCWrapper *o_intf = nil;
vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
}
else
else if ( !p_main->p_intf->p_sys->b_disabled_menus )
{
[self setupMenus];
}
#endif
return( 0 );
}
......@@ -490,32 +488,377 @@ static Intf_VLCWrapper *o_intf = nil;
config_PutIntVariable( "channel_port", i_port );
}
- (void)toggleProgram:(id)sender
{
NSMenuItem * o_item = (NSMenuItem *)sender;
input_thread_t * p_input = p_input_bank->pp_input[0];
if( [o_item state] == NSOffState )
{
u16 i_program_id = [o_item tag];
input_ChangeProgram( p_input, i_program_id );
vlc_mutex_lock( &p_input->stream.stream_lock );
[self setupMenus];
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
}
}
- (void)toggleTitle:(id)sender
{
NSMenuItem * o_item = (NSMenuItem *)sender;
input_thread_t * p_input = p_input_bank->pp_input[0];
if( [o_item state] == NSOffState )
{
int i_title = [o_item tag];
input_ChangeArea( p_input,
p_input->stream.pp_areas[i_title] );
vlc_mutex_lock( &p_input->stream.stream_lock );
[self setupMenus];
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
}
}
- (void)toggleChapter:(id)sender
{
NSMenuItem * o_item = (NSMenuItem *)sender;
input_thread_t * p_input = p_input_bank->pp_input[0];
if( [o_item state] == NSOffState )
{
int i_chapter = [o_item tag];
p_input->stream.p_selected_area->i_part = i_chapter;
input_ChangeArea( p_input,
p_input->stream.p_selected_area );
vlc_mutex_lock( &p_input->stream.stream_lock );
[self setupMenus];
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
}
}
- (void)toggleLanguage:(id)sender
{
NSMenuItem * o_item = (NSMenuItem *)sender;
input_thread_t * p_input = p_input_bank->pp_input[0];
int i_es = [o_item tag];
input_ToggleES( p_input, p_input->stream.pp_es[i_es],
[o_item state] == NSOffState );
vlc_mutex_lock( &p_input->stream.stream_lock );
[self setupMenus];
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
}
- (void)toggleSubtitle:(id)sender
{
NSMenuItem * o_item = (NSMenuItem *)sender;
input_thread_t * p_input = p_input_bank->pp_input[0];
int i_es = [o_item tag];
input_ToggleES( p_input, p_input->stream.pp_es[i_es],
[o_item state] == NSOffState );
vlc_mutex_lock( &p_input->stream.stream_lock );
[self setupMenus];
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
}
- (void)setupMenus
{
#if 0
NSMenu *o_main_menu;
NSMenuItem *o_controls_item;
NSMenuItem *o_program_item;
NSMenuItem *o_program_item, *o_title_item, *o_chapter_item, *o_language_item,
*o_subtitle_item;
input_thread_t * p_input = p_input_bank->pp_input[0];
o_main_menu = [NSApp mainMenu];
o_controls_item = [o_main_menu itemWithTitle: @"Controls"];
o_program_item = [[o_controls_item submenu] itemWithTitle: @"Program"];
o_title_item = [[o_controls_item submenu] itemWithTitle: @"Title"];
o_chapter_item = [[o_controls_item submenu] itemWithTitle: @"Chapter"];
o_language_item = [[o_controls_item submenu] itemWithTitle: @"Language"];
o_subtitle_item = [[o_controls_item submenu] itemWithTitle: @"Subtitles"];
if( p_input_bank->pp_input[0] == NULL )
if( p_input == NULL )
{
[o_program_item setEnabled:0];
[o_title_item setEnabled:0];
[o_chapter_item setEnabled:0];
[o_language_item setEnabled:0];
[o_subtitle_item setEnabled:0];
}
else
{
NSMenu *o_program, *o_title, *o_chapter, *o_language, *o_subtitle;
SEL pf_toggle_program, pf_toggle_title, pf_toggle_chapter,
pf_toggle_language, pf_toggle_subtitle;
int i, i_nb_items;
pgrm_descriptor_t * p_pgrm;
/* ----- PROGRAMS ----- */
if( p_input->stream.i_pgrm_number < 2 )
{
NSMenu * o_program = [o_program_item submenu];
// [o_program_item setEnabled:0];
// [o_program removeItemAtIndex:0];
[o_program addItemWithTitle: @"Toto" action: nil keyEquivalent: @""];
[o_program_item setEnabled:0];
}
else
{
NSMenu * o_program = [o_program_item submenu];
// [o_program_item setEnabled:1];
// [o_program removeItemAtIndex:0];
[o_program addItemWithTitle: @"Toto" action: nil keyEquivalent: @""];
[o_program_item setEnabled:1];
o_program = [o_program_item submenu];
pf_toggle_program = @selector(toggleProgram:);
/* Remove previous program menu */
i_nb_items = [o_program numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_program removeItemAtIndex:0];
}
if( p_input->stream.p_new_program )
{
p_pgrm = p_input->stream.p_new_program;
}
#endif
else
{
p_pgrm = p_input->stream.p_selected_program;
}
/* Create program menu */
for( i = 0 ; i < p_input->stream.i_pgrm_number ; i++ )
{
char psz_title[ 256 ];
NSString * o_menu_title;
NSMenuItem * o_item;
snprintf( psz_title, sizeof(psz_title), "id %d",
p_input->stream.pp_programs[i]->i_number );
psz_title[sizeof(psz_title) - 1] = '\0';
o_menu_title = [NSString stringWithCString: psz_title];
o_item = [o_program addItemWithTitle: o_menu_title
action: pf_toggle_program keyEquivalent: @""];
[o_item setTarget: self];
[o_item setTag: p_input->stream.pp_programs[i]->i_number];
if( p_pgrm == p_input->stream.pp_programs[i] )
{
[o_item setState: 1];
}
}
}
/* ----- TITLES ----- */
if( p_input->stream.i_area_nb < 2 )
{
[o_title_item setEnabled:0];
}
else
{
[o_title_item setEnabled:1];
o_title = [o_title_item submenu];
pf_toggle_title = @selector(toggleTitle:);
/* Remove previous title menu */
i_nb_items = [o_title numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_title removeItemAtIndex:0];
}
/* Create title menu */
for( i = 1 ; i < p_input->stream.i_area_nb ; i++ )
{
char psz_title[ 256 ];
NSString * o_menu_title;
NSMenuItem * o_item;
snprintf( psz_title, sizeof(psz_title), "Title %d (%d)", i,
p_input->stream.pp_areas[i]->i_part_nb );
psz_title[sizeof(psz_title) - 1] = '\0';
o_menu_title = [NSString stringWithCString: psz_title];
o_item = [o_title addItemWithTitle: o_menu_title
action: pf_toggle_title keyEquivalent: @""];
[o_item setTag: i];
[o_item setTarget: self];
if( ( p_input->stream.pp_areas[i] ==
p_input->stream.p_selected_area ) )
{
[o_item setState: 1];
}
}
}
/* ----- CHAPTERS ----- */
if( p_input->stream.p_selected_area->i_part_nb < 2 )
{
[o_chapter_item setEnabled:0];
}
else
{
[o_chapter_item setEnabled:1];
o_chapter = [o_chapter_item submenu];
pf_toggle_chapter = @selector(toggleChapter:);
/* Remove previous chapter menu */
i_nb_items = [o_chapter numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_chapter removeItemAtIndex:0];
}
/* Create chapter menu */
for( i = 0 ; i < p_input->stream.p_selected_area->i_part_nb ; i++ )
{
char psz_title[ 256 ];
NSString * o_menu_title;
NSMenuItem * o_item;
snprintf( psz_title, sizeof(psz_title), "Chapter %d", i + 1 );
psz_title[sizeof(psz_title) - 1] = '\0';
o_menu_title = [NSString stringWithCString: psz_title];
o_item = [o_chapter addItemWithTitle: o_menu_title
action: pf_toggle_chapter keyEquivalent: @""];
[o_item setTag: i];
[o_item setTarget: self];
if( ( p_input->stream.p_selected_area->i_part == i + 1 ) )
{
[o_item setState: 1];
}
}
}
p_main->p_intf->p_sys->i_part = p_input->stream.p_selected_area->i_part;
/* ----- LANGUAGES & SUBTITLES ----- */
o_language = [o_language_item submenu];
o_subtitle = [o_subtitle_item submenu];
pf_toggle_language = @selector(toggleLanguage:);
pf_toggle_subtitle = @selector(toggleSubtitle:);
/* Remove previous language menu */
i_nb_items = [o_language numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_language removeItemAtIndex:0];
}
/* Remove previous subtitle menu */
i_nb_items = [o_subtitle numberOfItems];
for( i = 0; i < i_nb_items; i++ )
{
[o_subtitle removeItemAtIndex:0];
}
/* Create language & subtitles menus */
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
es_descriptor_t * p_es = p_input->stream.pp_es[i];
if( p_es->p_pgrm != NULL
&& p_es->p_pgrm != p_input->stream.p_selected_program )
{
continue;
}
if( p_es->i_cat == AUDIO_ES )
{
NSString * o_menu_title;
NSMenuItem * o_item;
if( *p_es->psz_desc )
{
o_menu_title = [NSString stringWithCString: p_es->psz_desc];
}
else
{
char psz_title[ 256 ];
snprintf( psz_title, sizeof(psz_title), "Language 0x%x",
p_es->i_id );
psz_title[sizeof(psz_title) - 1] = '\0';
o_menu_title = [NSString stringWithCString: psz_title];
}
o_item = [o_language addItemWithTitle: o_menu_title
action: pf_toggle_language keyEquivalent: @""];
[o_item setTag: i];
[o_item setTarget: self];
if( p_es->p_decoder_fifo != NULL )
{
[o_item setState: 1];
}
}
else if( p_es->i_cat == SPU_ES )
{
NSString * o_menu_title;
NSMenuItem * o_item;
if( *p_es->psz_desc )
{
o_menu_title = [NSString stringWithCString: p_es->psz_desc];
}
else
{
char psz_title[ 256 ];
snprintf( psz_title, sizeof(psz_title), "Subtitle 0x%x",
p_es->i_id );
psz_title[sizeof(psz_title) - 1] = '\0';
o_menu_title = [NSString stringWithCString: psz_title];
}
o_item = [o_subtitle addItemWithTitle: o_menu_title
action: pf_toggle_subtitle keyEquivalent: @""];
[o_item setTag: i];
[o_item setTarget: self];
if( p_es->p_decoder_fifo != NULL )
{
[o_item setState: 1];
}
}
}
if( [o_language numberOfItems] )
{
[o_language_item setEnabled: 1];
}
else
{
[o_language_item setEnabled: 0];
}
if( [o_subtitle numberOfItems] )
{
[o_subtitle_item setEnabled: 1];
}
else
{
[o_subtitle_item setEnabled: 0];
}
p_input->stream.b_changed = 0;
}
p_main->p_intf->p_sys->b_disabled_menus = 1;
}
@end
......@@ -2,7 +2,7 @@
* intf_vlc_wrapper.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: intf_vlc_wrapper.h,v 1.6 2002/05/06 22:59:46 massiot Exp $
* $Id: intf_vlc_wrapper.h,v 1.7 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -70,6 +70,13 @@
- (void)openDisc:(NSString*)o_type device:(NSString*)o_device title:(int)i_title chapter:(int)i_chapter;
- (void)openNet:(NSString*)o_protocol addr:(NSString*)o_addr port:(int)i_port baddr:(NSString*)o_baddr;
- (void)openNetChannel:(NSString*)o_addr port:(int)i_port;
/* menus management */
- (void)toggleProgram:(id)sender;
- (void)toggleTitle:(id)sender;
- (void)toggleChapter:(id)sender;
- (void)toggleLanguage:(id)sender;
- (void)toggleSubtitle:(id)sender;
- (void)setupMenus;
@end
......@@ -2,7 +2,7 @@
* macosx.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: macosx.h,v 1.8 2002/05/06 22:59:46 massiot Exp $
* $Id: macosx.h,v 1.9 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Eugenio Jarosiewicz <ej0@cise.ufl.edu>
......@@ -42,6 +42,7 @@ typedef struct intf_sys_s
int i_saved_volume;
int i_part;
boolean_t b_disabled_menus;
} intf_sys_t;
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.32 2002/04/23 14:16:20 sam Exp $
* $Id: input_dec.c,v 1.33 2002/05/12 01:39:36 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -91,6 +91,8 @@ vlc_thread_t input_RunDecoder( input_thread_t * p_input,
return( 0 );
}
p_input->stream.b_changed = 1;
return thread_id;
}
......@@ -131,6 +133,8 @@ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es )
/* Tell the input there is no more decoder */
p_es->p_decoder_fifo = NULL;
p_input->stream.b_changed = 1;
}
/*****************************************************************************
......
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