diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m index d63577cec549c229f7a078cb491c4fbc91f4b243..9b52acb0c99d7d539623102f21e585d7bbbb386f 100644 --- a/modules/gui/macosx/controls.m +++ b/modules/gui/macosx/controls.m @@ -2,7 +2,7 @@ * controls.m: MacOS X interface plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: controls.m,v 1.34 2003/05/01 01:11:17 hartman Exp $ + * $Id: controls.m,v 1.35 2003/05/05 22:04:11 hartman Exp $ * * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Christophe Massiot <massiot@via.ecp.fr> @@ -611,24 +611,23 @@ - (IBAction)toggleVar:(id)sender { - NSMenuItem * o_mi = (NSMenuItem *)sender; + NSMenuItem *o_mi = (NSMenuItem *)sender; + NSMenu *o_mu = [o_mi menu]; if( [o_mi state] == NSOffState ) { - const char * psz_variable = (const char *)[o_mi tag]; - char * psz_value = [NSApp delocalizeString: [o_mi title]]; + const char * psz_variable = (const char *) + [[[o_mu supermenu] itemWithTitle: [o_mu title]] tag]; vlc_object_t * p_object = (vlc_object_t *) [[o_mi representedObject] pointerValue]; vlc_value_t val; - /* psz_string sucks */ - val.psz_string = (char *)psz_value; + val.i_int = (int)[o_mi tag]; if ( var_Set( p_object, psz_variable, val ) < 0 ) { - msg_Warn( p_object, "cannot set variable (%s)", psz_value ); + msg_Warn( p_object, "cannot set variable %s: with %d", psz_variable, val.i_int ); } - - free( psz_value ); + if (psz_variable) free(psz_variable); } } diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f37984231866604fbd29ea3f0a25fdb86b8b1a1f..35e0f1dc225bcb669e3ad7123b6ffe748b7ab89c 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-2003 VideoLAN - * $Id: intf.m,v 1.72 2003/05/04 22:42:16 gbazin Exp $ + * $Id: intf.m,v 1.73 2003/05/05 22:04:11 hartman Exp $ * * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Christophe Massiot <massiot@via.ecp.fr> @@ -1186,7 +1186,6 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) var_Set( (vlc_object_t *)p_aout, "intf-change", val ); -#error fixme! look at rc.c line 823 [self setupVarMenu: o_mi_channels target: (vlc_object_t *)p_aout var: "audio-channels" selector: @selector(toggleVar:)]; @@ -1309,11 +1308,12 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) var:(const char *)psz_variable selector:(SEL)pf_callback { - int i, i_nb_items; + int i, i_nb_items, i_value; NSMenu * o_menu = [o_mi submenu]; - vlc_value_t val; - char * psz_value; - + vlc_value_t val, text; + + [o_mi setTag: (int)psz_variable]; + /* remove previous items */ i_nb_items = [o_menu numberOfItems]; for( i = 0; i < i_nb_items; i++ ) @@ -1325,12 +1325,11 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) { return; } - psz_value = val.psz_string; + i_value = val.i_int; if ( var_Change( p_object, psz_variable, - VLC_VAR_GETLIST, &val, NULL ) < 0 ) + VLC_VAR_GETLIST, &val, &text ) < 0 ) { - free( psz_value ); return; } @@ -1342,23 +1341,24 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) NSMenuItem * o_lmi; NSString * o_title; - o_title = [NSApp localizedString: val.p_list->p_values[i].psz_string]; - o_lmi = [o_menu addItemWithTitle: o_title + o_title = [NSApp localizedString: text.p_list->p_values[i].psz_string]; + + o_lmi = [o_menu addItemWithTitle: [o_title copy] action: pf_callback keyEquivalent: @""]; + /* FIXME: this isn't 64-bit clean ! */ - [o_lmi setTag: (int)psz_variable]; + [o_lmi setTag: val.p_list->p_values[i].i_int]; [o_lmi setRepresentedObject: [NSValue valueWithPointer: p_object]]; [o_lmi setTarget: o_controls]; - if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) + if ( i_value == val.p_list->p_values[i].i_int ) [o_lmi setState: NSOnState]; } var_Change( p_object, psz_variable, VLC_VAR_FREELIST, - &val, NULL ); + &val, &text ); - free( psz_value ); } - (IBAction)clearRecentItems:(id)sender diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 7e5ca767f25074e004bd1ee3bcdd5bcd84261281..535a468663d8711963b9526e25df1cf9249f6619 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -2,7 +2,7 @@ * vout.m: MacOS X video output plugin ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: vout.m,v 1.46 2003/05/04 22:42:16 gbazin Exp $ + * $Id: vout.m,v 1.47 2003/05/05 22:04:11 hartman Exp $ * * Authors: Colin Delacroix <colin@zoy.org> * Florian G. Pflug <fgp@phlo.org> @@ -181,14 +181,16 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 ) { int i = 1; - vlc_value_t val; + vlc_value_t val, text; NSScreen * o_screen; int i_option = config_GetInt( p_vout, "macosx-vdev" ); - var_Create( p_vout, "video-device", VLC_VAR_STRING | + var_Create( p_vout, "video-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); - + text.psz_string = _("Video device"); + var_Change( p_vout, "video-device", VLC_VAR_SETTEXT, &text, NULL ); + NSEnumerator * o_enumerator = [o_screens objectEnumerator]; while( (o_screen = [o_enumerator nextObject]) != NULL ) @@ -200,15 +202,15 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) "%s %d (%dx%d)", _("Screen"), i, (int)s_rect.size.width, (int)s_rect.size.height ); - val.psz_string = psz_temp; + text.psz_string = psz_temp; + val.i_int = i; var_Change( p_vout, "video-device", - VLC_VAR_ADDCHOICE, &val, NULL ); + VLC_VAR_ADDCHOICE, &val, &text ); if( ( i - 1 ) == i_option ) { var_Set( p_vout, "video-device", val ); } - i++; } @@ -1215,11 +1217,10 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) } else { - unsigned int i_index = 0; NSArray *o_screens = [NSScreen screens]; - - if( !sscanf( val.psz_string, _("Screen %d"), &i_index ) || - [o_screens count] < i_index ) + unsigned int i_index = val.i_int; + + if( [o_screens count] < i_index ) { o_screen = [NSScreen mainScreen]; b_main_screen = 1; @@ -1230,9 +1231,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic ) o_screen = [o_screens objectAtIndex: i_index]; config_PutInt( p_vout, "macosx-vdev", i_index ); b_main_screen = (i_index == 0); - } - - free( val.psz_string ); + } } if( p_vout->b_fullscreen )