X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fintf.m;h=5b2a35529a3672d4f9dc5977a4dedf6a41e06e9f;hb=215c1a851ceb2a32c721381954ffa0b68c547432;hp=d30c33907b885187294224b353df5191507eb5ac;hpb=ea5a42d20686edc7dee96ae9f9a6527ed893b409;p=vlc diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index d30c33907b..5b2a35529a 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -2,7 +2,7 @@ * intf.m: MacOS X interface plugin ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: intf.m,v 1.6 2002/12/04 20:51:23 jlj Exp $ + * $Id: intf.m,v 1.10 2002/12/14 19:34:06 gbazin Exp $ * * Authors: Jon Lech Johansen * Christophe Massiot @@ -195,9 +195,10 @@ static void Run( intf_thread_t *p_intf ) [o_mi_quit setTitle: _NS("Quit vlc")]; [o_mu_file setTitle: _NS("File")]; - [o_mi_open_file setTitle: _NS("Open File")]; - [o_mi_open_disc setTitle: _NS("Open Disc")]; - [o_mi_open_net setTitle: _NS("Open Network")]; + [o_mi_open_file setTitle: _NS("Open File...")]; + [o_mi_open_generic setTitle: _NS("Open Generic...")]; + [o_mi_open_disc setTitle: _NS("Open Disc...")]; + [o_mi_open_net setTitle: _NS("Open Network...")]; [o_mi_open_recent setTitle: _NS("Open Recent")]; [o_mi_open_recent_cm setTitle: _NS("Clear Menu")]; @@ -221,10 +222,12 @@ static void Run( intf_thread_t *p_intf ) [o_mi_previous setTitle: _NS("Prev")]; [o_mi_next setTitle: _NS("Next")]; [o_mi_loop setTitle: _NS("Loop")]; - [o_mi_vol_up setTitle: _NS("Volume Up")]; - [o_mi_vol_down setTitle: _NS("Volume Down")]; + [o_mi_vol_up setTitle: _NS("Louder")]; + [o_mi_vol_down setTitle: _NS("Softer")]; [o_mi_mute setTitle: _NS("Mute")]; + [o_mi_channels setTitle: _NS("Channels")]; [o_mi_fullscreen setTitle: _NS("Fullscreen")]; + [o_mi_screen setTitle: _NS("Screen")]; [o_mi_deinterlace setTitle: _NS("Deinterlace")]; [o_mi_program setTitle: _NS("Program")]; [o_mi_title setTitle: _NS("Title")]; @@ -298,9 +301,14 @@ static void Run( intf_thread_t *p_intf ) p_intf->p_sys->p_input = NULL; } - if( p_intf->p_sys->p_input ) + if( p_intf->p_sys->p_input != NULL ) { - input_thread_t *p_input = p_intf->p_sys->p_input; + vlc_bool_t b_need_menus = 0; + input_thread_t * p_input = p_intf->p_sys->p_input; + aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, + FIND_ANYWHERE ); + vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, + FIND_ANYWHERE ); vlc_mutex_lock( &p_input->stream.stream_lock ); @@ -310,7 +318,7 @@ static void Run( intf_thread_t *p_intf ) if( p_input->stream.b_changed ) { [self manageMode]; - [self setupMenus]; + b_need_menus = 1; p_intf->p_sys->b_playing = 1; } @@ -318,10 +326,37 @@ static void Run( intf_thread_t *p_intf ) p_input->stream.p_selected_area->i_part ) { p_intf->p_sys->b_chapter_update = 1; - [self setupMenus]; + b_need_menus = 1; } } + if ( p_aout != NULL ) + { + vlc_value_t val; + if ( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) + >= 0 && val.b_bool ) + { + p_intf->p_sys->b_aout_update = 1; + b_need_menus = 1; + } + vlc_object_release( (vlc_object_t *)p_aout ); + } + + if ( p_vout != NULL ) + { + vlc_value_t val; + if ( var_Get( (vlc_object_t *)p_vout, "intf-change", &val ) + >= 0 && val.b_bool ) + { + p_intf->p_sys->b_vout_update = 1; + b_need_menus = 1; + } + vlc_object_release( (vlc_object_t *)p_vout ); + } + + if ( b_need_menus ) + [self setupMenus]; + vlc_mutex_unlock( &p_input->stream.stream_lock ); } else if( p_intf->p_sys->b_playing && !p_intf->b_die ) @@ -464,7 +499,7 @@ static void Run( intf_thread_t *p_intf ) vlc_bool_t b_control = 0; intf_thread_t * p_intf = [NSApp getIntf]; - if( p_intf->p_sys->p_input ) + if( p_intf->p_sys->p_input != NULL ) { /* control buttons for free pace streams */ b_control = p_intf->p_sys->p_input->stream.b_pace_control; @@ -488,6 +523,8 @@ static void Run( intf_thread_t *p_intf ) [o_mi_chapter setEnabled: FALSE]; [o_mi_language setEnabled: FALSE]; [o_mi_subtitle setEnabled: FALSE]; + [o_mi_channels setEnabled: FALSE]; + [o_mi_screen setEnabled: FALSE]; } } @@ -680,6 +717,48 @@ static void Run( intf_thread_t *p_intf ) p_intf->p_sys->b_spu_update = 0; } + if ( p_intf->p_sys->b_aout_update ) + { + aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, + FIND_ANYWHERE ); + + if ( p_aout != NULL ) + { + vlc_value_t val; + val.b_bool = 0; + + var_Set( (vlc_object_t *)p_aout, "intf-change", val ); + + [self setupVarMenu: o_mi_channels target: (vlc_object_t *)p_aout + var: "audio-channels" selector: @selector(toggleVar:)]; + + vlc_object_release( (vlc_object_t *)p_aout ); + } + + p_intf->p_sys->b_aout_update = 0; + } + + if ( p_intf->p_sys->b_vout_update ) + { + vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, + FIND_ANYWHERE ); + + if ( p_vout != NULL ) + { + vlc_value_t val; + val.b_bool = 0; + + var_Set( (vlc_object_t *)p_vout, "intf-change", val ); + + [self setupVarMenu: o_mi_screen target: (vlc_object_t *)p_vout + var: "video-device" selector: @selector(toggleVar:)]; + + vlc_object_release( (vlc_object_t *)p_vout ); + } + + p_intf->p_sys->b_vout_update = 0; + } + vlc_mutex_lock( &p_input->stream.stream_lock ); #undef p_input @@ -701,6 +780,11 @@ static void Run( intf_thread_t *p_intf ) [o_menu removeItemAtIndex: 0]; } + /* make sensitive : we can't change it after we build the menu, and + * before, we don't yet how many items we will have. So make it + * always sensitive. --Meuuh */ + [o_mi setEnabled: TRUE]; + vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); #define ES p_intf->p_sys->p_input->stream.pp_es[i] @@ -745,10 +829,63 @@ static void Run( intf_thread_t *p_intf ) #undef ES vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); +} + +- (void)setupVarMenu:(NSMenuItem *)o_mi + target:(vlc_object_t *)p_object + var:(const char *)psz_variable + selector:(SEL)pf_callback +{ + int i, i_nb_items; + NSMenu * o_menu = [o_mi submenu]; + vlc_value_t val; + char * psz_value; + + /* remove previous items */ + i_nb_items = [o_menu numberOfItems]; + for( i = 0; i < i_nb_items; i++ ) + { + [o_menu removeItemAtIndex: 0]; + } + + if ( var_Get( p_object, psz_variable, &val ) < 0 ) + { + return; + } + psz_value = val.psz_string; + + if ( var_Change( p_object, psz_variable, + VLC_VAR_GETLIST, &val ) < 0 ) + { + free( psz_value ); + return; + } /* make (un)sensitive */ - [o_mi setEnabled: - [o_menu numberOfItems] ? TRUE : FALSE]; + [o_mi setEnabled: (val.p_list->i_count > 0)]; + + for ( i = 0; i < val.p_list->i_count; i++ ) + { + NSMenuItem * o_lmi; + NSString * o_title; + + o_title = [NSString stringWithCString: val.p_list->p_values[i].psz_string]; + o_lmi = [o_menu addItemWithTitle: o_title + action: pf_callback keyEquivalent: @""]; + /* FIXME: this isn't 64-bit clean ! */ + [o_lmi setTag: (int)psz_variable]; + [o_lmi setRepresentedObject: + [NSValue valueWithPointer: p_object]]; + [o_lmi setTarget: o_controls]; + + if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) + [o_lmi setState: NSOnState]; + } + + var_Change( p_object, psz_variable, VLC_VAR_FREELIST, + &val ); + + free( psz_value ); } - (IBAction)clearRecentItems:(id)sender @@ -772,6 +909,11 @@ static void Run( intf_thread_t *p_intf ) [o_prefs createPrefPanel: @"main"]; } +- (id)getMIDevice +{ + return o_mi_device; +} + @end @implementation VLCMain (NSMenuValidation) @@ -845,91 +987,19 @@ static void Run( intf_thread_t *p_intf ) - (void)handlePortMessage:(NSPortMessage *)o_msg { - NSData * o_req; - vout_req_t * p_req; - - o_req = [[o_msg components] lastObject]; - p_req = *((vout_req_t **)[o_req bytes]); - - [p_req->o_lock lock]; - - if( p_req->i_type == VOUT_REQ_CREATE_WINDOW ) - { - VLCView * o_view; - - p_req->p_vout->p_sys->o_window = [VLCWindow alloc]; - [p_req->p_vout->p_sys->o_window setVout: p_req->p_vout]; - [p_req->p_vout->p_sys->o_window setReleasedWhenClosed: YES]; - - if( p_req->p_vout->b_fullscreen ) - { - [p_req->p_vout->p_sys->o_window - initWithContentRect: [[NSScreen mainScreen] frame] - styleMask: NSBorderlessWindowMask - backing: NSBackingStoreBuffered - defer: NO screen: [NSScreen mainScreen]]; - - [p_req->p_vout->p_sys->o_window - setLevel: NSModalPanelWindowLevel]; - } - else - { - unsigned int i_stylemask = NSTitledWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask; - - [p_req->p_vout->p_sys->o_window - initWithContentRect: p_req->p_vout->p_sys->s_rect - styleMask: i_stylemask - backing: NSBackingStoreBuffered - defer: NO screen: [NSScreen mainScreen]]; - - if( !p_req->p_vout->p_sys->b_pos_saved ) - { - [p_req->p_vout->p_sys->o_window center]; - } - } - - o_view = [[VLCView alloc] init]; - [o_view setVout: p_req->p_vout]; - [o_view setMenu: o_mu_controls]; - [p_req->p_vout->p_sys->o_window setContentView: o_view]; - [o_view autorelease]; - - [o_view lockFocus]; - p_req->p_vout->p_sys->p_qdport = [o_view qdPort]; - [o_view unlockFocus]; - - [p_req->p_vout->p_sys->o_window setTitle: [NSString - stringWithCString: VOUT_TITLE " (QuickTime)"]]; - [p_req->p_vout->p_sys->o_window makeKeyAndOrderFront: nil]; - - p_req->i_result = 1; - } - else if( p_req->i_type == VOUT_REQ_DESTROY_WINDOW ) - { - if( !p_req->p_vout->b_fullscreen ) - { - NSRect s_rect; - - s_rect = [[p_req->p_vout->p_sys->o_window contentView] frame]; - p_req->p_vout->p_sys->s_rect.size = s_rect.size; - - s_rect = [p_req->p_vout->p_sys->o_window frame]; - p_req->p_vout->p_sys->s_rect.origin = s_rect.origin; - - p_req->p_vout->p_sys->b_pos_saved = 1; - } - - p_req->p_vout->p_sys->p_qdport = nil; - [p_req->p_vout->p_sys->o_window close]; - p_req->p_vout->p_sys->o_window = nil; - - p_req->i_result = 1; - } - - [p_req->o_lock unlockWithCondition: 1]; + NSData * o_data; + NSValue * o_value; + NSInvocation * o_inv; + vout_thread_t * p_vout; + + o_data = [[o_msg components] lastObject]; + o_inv = *((NSInvocation **)[o_data bytes]); + [o_inv getArgument: &o_value atIndex: 2]; + p_vout = (vout_thread_t *)[o_value pointerValue]; + + [p_vout->p_sys->o_lock lock]; + [o_inv invoke]; + [p_vout->p_sys->o_lock unlockWithCondition: 1]; } @end -