]> git.sesse.net Git - vlc/commitdiff
* ALL:
authorDerk-Jan Hartman <hartman@videolan.org>
Sun, 1 Jun 2003 23:48:17 +0000 (23:48 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Sun, 1 Jun 2003 23:48:17 +0000 (23:48 +0000)
  - Changed the autogenerated menu's in a system working similar to wxWindows.
  - The deinterlace menu is autogenerated now. However it seems the problem
    with on the fly filter changes still exists.

extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib
modules/gui/macosx/controls.h
modules/gui/macosx/controls.m
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m

index e9fbbcbae8aeae3684b9d154bb069c507616c46b..7e47f2fd17b572cf5b8af7c5ebf225bcebe9070f 100644 (file)
@@ -19,7 +19,6 @@
         {
             ACTIONS = {
                 backward = id; 
-                deinterlace = id; 
                 faster = id; 
                 forward = id; 
                 loop = id; 
index 10f81100fb62a176e4dd4c19dd0d14ddaff5f10b..f0132c853dcb60b79c549c90e398aada3b2fe193 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ
index 19ae587b185e9150a4249b5b35d0faf7ba02b87c..b2eb9a5e34d89fcf4842a8f8e3e8ff28d92838a6 100644 (file)
@@ -2,7 +2,7 @@
  * controls.h: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.h,v 1.4 2003/05/08 01:16:57 hartman Exp $
+ * $Id: controls.h,v 1.5 2003/06/01 23:48:17 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
 - (void)updateVolumeSlider;
 
 - (IBAction)windowAction:(id)sender;
-- (IBAction)deinterlace:(id)sender;
 
+- (void)setupVarMenuItem:(NSMenuItem *)o_mi
+                    target:(vlc_object_t *)p_object
+                    var:(const char *)psz_variable
+                    selector:(SEL)pf_callback;
+- (void)setupVarMenu:(NSMenu *)o_menu
+                    forMenuItem: (NSMenuItem *)o_parent
+                    target:(vlc_object_t *)p_object
+                    var:(const char *)psz_variable
+                    selector:(SEL)pf_callback;
 - (IBAction)toggleVar:(id)sender;
 
-@end
\ No newline at end of file
+@end
+
+/*****************************************************************************
+ * VLCMenuExt interface 
+ *****************************************************************************
+ * This holds our data for autogenerated menus
+ *****************************************************************************/
+@interface VLCMenuExt : NSObject
+{
+    char *psz_name;
+    int i_object_id;
+    vlc_value_t value;
+    int i_type;
+}
+
+- (id)initWithVar: (const char *)_psz_name Object: (int)i_id
+        Value: (vlc_value_t)val ofType: (int)_i_type;
+- (char *)name;
+- (int)objectID;
+- (vlc_value_t)value;
+- (int)type;
+
+@end
index 6769346184ab00383f1686e2282f5a7aed8e6af4..c5ef187e8456861171f73f53d287d3cb72f4ce18 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.m,v 1.39 2003/05/25 17:27:13 massiot Exp $
+ * $Id: controls.m,v 1.40 2003/06/01 23:48:17 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
     }
 }
 
-- (IBAction)deinterlace:(id)sender
+- (void)setupVarMenuItem:(NSMenuItem *)o_mi
+                    target:(vlc_object_t *)p_object
+                    var:(const char *)psz_variable
+                    selector:(SEL)pf_callback
 {
-    intf_thread_t * p_intf = [NSApp getIntf];
-    BOOL bEnable = [sender state] == NSOffState;
+    vlc_value_t val, text;
+    int i_type = var_Type( p_object, psz_variable );
+
+    switch( i_type & VLC_VAR_TYPE )
+    {
+    case VLC_VAR_VOID:
+    case VLC_VAR_BOOL:
+    case VLC_VAR_VARIABLE:
+    case VLC_VAR_STRING:
+    case VLC_VAR_INTEGER:
+        break;
+    default:
+        /* Variable doesn't exist or isn't handled */
+        return;
+    }
+    
+    /* Make sure we want to display the variable */
+    if( i_type & VLC_VAR_HASCHOICE )
+    {
+        var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
+        if( val.i_int == 0 ) return;
+        if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
+            return;
+    }
+    
+    /* Get the descriptive name of the variable */
+    var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
+    [o_mi setTitle: [NSApp localizedString: text.psz_string ?
+                                        text.psz_string : strdup( psz_variable ) ]];
 
-    if( bEnable && ![[sender title] isEqualToString: @"none"] )
+    var_Get( p_object, psz_variable, &val );
+    if( i_type & VLC_VAR_HASCHOICE )
     {
-        config_PutPsz( p_intf, "filter", "deinterlace" );
-       config_PutPsz( p_intf, "deinterlace-mode",
-                    [[sender title] UTF8String] );
+        NSMenu *o_menu = [o_mi submenu];
+
+        [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
+                        var:psz_variable selector:pf_callback];
+        
+        if( text.psz_string ) free( text.psz_string );
+        return;
     }
-    else
+
+    VLCMenuExt *o_data;
+    switch( i_type & VLC_VAR_TYPE )
     {
-        config_PutPsz( p_intf, "filter", NULL );
+    case VLC_VAR_VOID:
+        o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
+                Value: val ofType: i_type];
+        [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
+        break;
+
+    case VLC_VAR_BOOL:
+        o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
+                Value: val ofType: i_type];
+        [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
+        [o_mi setState: val.b_bool ? TRUE : FALSE ];
+        break;
+
+    default:
+        if( text.psz_string ) free( text.psz_string );
+        return;
     }
+
+    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
+    if( text.psz_string ) free( text.psz_string );
 }
 
-- (IBAction)toggleVar:(id)sender
+
+- (void)setupVarMenu:(NSMenu *)o_menu
+                    forMenuItem: (NSMenuItem *)o_parent
+                    target:(vlc_object_t *)p_object
+                    var:(const char *)psz_variable
+                    selector:(SEL)pf_callback
 {
-    NSMenuItem *o_mi = (NSMenuItem *)sender;
-    NSMenu *o_mu = [o_mi menu];
-    
-    if( [o_mi state] == NSOffState )
+    vlc_value_t val, val_list, text_list;
+    int i_type, i, i_nb_items;
+
+    /* remove previous items */
+    i_nb_items = [o_menu numberOfItems];
+    for( i = 0; i < i_nb_items; i++ )
+    {
+        [o_menu removeItemAtIndex: 0];
+    }
+
+    /* Check the type of the object variable */
+    i_type = var_Type( p_object, psz_variable );
+
+    /* Make sure we want to display the variable */
+    if( i_type & VLC_VAR_HASCHOICE )
+    {
+        var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
+        if( val.i_int == 0 ) return;
+        if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
+            return;
+    }
+    else
+    {
+        return;
+    }
+
+    switch( i_type & VLC_VAR_TYPE )
     {
-        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;
-        val.i_int = (int)[o_mi tag];
+    case VLC_VAR_VOID:
+    case VLC_VAR_BOOL:
+    case VLC_VAR_VARIABLE:
+    case VLC_VAR_STRING:
+    case VLC_VAR_INTEGER:
+        break;
+    default:
+        /* Variable doesn't exist or isn't handled */
+        return;
+    }
 
-        if ( var_Set( p_object, psz_variable, val ) < 0 )
+    if( var_Get( p_object, psz_variable, &val ) < 0 )
+    {
+        return;
+    }
+
+    if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
+                    &val_list, &text_list ) < 0 )
+    {
+        if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
+        return;
+    }
+
+    /* make (un)sensitive */
+    [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
+
+    for( i = 0; i < val_list.p_list->i_count; i++ )
+    {
+        vlc_value_t another_val;
+        NSMenuItem * o_lmi;
+        NSString *o_title = @"";
+        VLCMenuExt *o_data;
+
+        switch( i_type & VLC_VAR_TYPE )
         {
-            msg_Warn( p_object, "cannot set variable %s: with %d", psz_variable, val.i_int );
+        case VLC_VAR_VARIABLE:
+
+            /* This is causing crashes for the moment.
+            o_title = [NSApp localizedString: text_list.p_list->p_values[i].psz_string ?
+                text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
+            
+            o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
+                Value: val ofType: i_type];
+            [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
+
+            // Create a submenu
+            NSMenu *o_menu = [o_lmi submenu];
+
+            [self setupVarMenu: o_menu forMenuItem: o_lmi target:p_object
+                            var:psz_variable selector:pf_callback];
+*/
+            return;
+
+        case VLC_VAR_STRING:
+            another_val.psz_string =
+                strdup(val_list.p_list->p_values[i].psz_string);
+
+            o_title = [NSApp localizedString: text_list.p_list->p_values[i].psz_string ?
+                text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
+
+            o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
+            o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
+                    Value: another_val ofType: i_type];
+            [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
+            [o_lmi setTarget: self];
+            
+            if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) )
+                [o_lmi setState: TRUE ];
+
+            break;
+
+        case VLC_VAR_INTEGER:
+
+             o_title = text_list.p_list->p_values[i].psz_string ?
+                                 [NSApp localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
+                                 [NSString stringWithFormat: @"%d",
+                                 val_list.p_list->p_values[i].i_int];
+
+            o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
+            o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
+                    Value: val_list.p_list->p_values[i] ofType: i_type];
+            [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
+            [o_lmi setTarget: self];
+
+            if( val_list.p_list->p_values[i].i_int == val.i_int )
+                [o_lmi setState: TRUE ];
+            break;
+
+        default:
+          break;
         }
     }
+    
+    /* clean up everything */
+    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
+    var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
+}
+
+- (IBAction)toggleVar:(id)sender
+{
+    NSMenuItem *o_mi = (NSMenuItem *)sender;
+    VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
+    vlc_object_t *p_object;
+
+    p_object = (vlc_object_t *)vlc_object_get( [NSApp getIntf],
+                                    [o_data objectID] );
+    if( p_object == NULL ) return;
+
+    var_Set( p_object, strdup([o_data name]), [o_data value] );
+    vlc_object_release( p_object );
+    
+    return;
 }
 
 @end
 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
 {
     BOOL bEnabled = TRUE;
-    NSMenu * o_menu = [o_mi menu];
     intf_thread_t * p_intf = [NSApp getIntf];
 
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
             vlc_object_release( (vlc_object_t *)p_vout );
         }
     }
-    else if( [[o_mi title] isEqualToString: _NS("Float On Top")] )
-    {
-        
-        bEnabled = TRUE;
-    }
-    else if( o_menu != nil && 
-             [[o_menu title] isEqualToString: _NS("Deinterlace")] )
-    {
-        char * psz_filter = config_GetPsz( p_intf, "filter" );
-        
-        if( psz_filter != NULL )
-        {
-            free( psz_filter );
-            
-            psz_filter = config_GetPsz( p_intf, "deinterlace-mode" );
-        }
-
-        if( psz_filter != NULL )
-        {
-            if( strcmp( psz_filter, [[o_mi title] UTF8String] ) == 0 )
-            {
-                [o_mi setState: NSOnState];
-            }
-            else
-            {
-                [o_mi setState: NSOffState];
-            }
-
-            free( psz_filter );
-        }
-        else
-        {
-            if( [[o_mi title] isEqualToString: @"none"] )
-            {
-                [o_mi setState: NSOnState];
-            }
-            else
-            {
-                [o_mi setState: NSOffState];
-            }
-        }
-    }
 
     if( p_playlist != NULL )
     {
 }
 
 @end
+
+/*****************************************************************************
+ * VLCMenuExt implementation 
+ *****************************************************************************
+ * Object connected to a playlistitem which remembers the data belonging to
+ * the variable of the autogenerated menu
+ *****************************************************************************/
+@implementation VLCMenuExt
+
+- (id)initWithVar: (const char *)_psz_name Object: (int)i_id
+        Value: (vlc_value_t)val ofType: (int)_i_type
+{
+    self = [super init];
+
+    if( self != nil )
+    {
+        psz_name = strdup( _psz_name );
+        i_object_id = i_id;
+        value = val;
+        i_type = _i_type;
+    }
+
+    return( self );
+}
+
+- (void)dealloc
+{
+    free( psz_name );
+}
+
+- (char *)name
+{
+    return psz_name;
+}
+
+- (int)objectID
+{
+    return i_object_id;
+}
+
+- (vlc_value_t)value
+{
+    return value;
+}
+
+- (int)type
+{
+    return i_type;
+}
+
+@end
index 067e398075c9ef528eef405fb0573b88dd319abc..620b9e727fb0863c1443c06bafbe2d154d22474b 100644 (file)
@@ -2,7 +2,7 @@
  * intf.h: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: intf.h,v 1.41 2003/05/26 14:59:37 hartman Exp $
+ * $Id: intf.h,v 1.42 2003/06/01 23:48:17 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -231,27 +231,19 @@ struct intf_sys_t
 - (void)manage:(playlist_t *)p_playlist;
 - (void)manageMode:(playlist_t *)p_playlist;
 - (void)manageIntf:(NSTimer *)o_timer;
+- (void)setupMenus;
 
 - (void)updateMessageArray;
 - (void)playStatusUpdated:(BOOL)b_pause;
 - (void)setSubmenusEnabled:(BOOL)b_enabled;
 - (void)manageVolumeSlider;
-
-- (void)setupMenus:(input_thread_t *)p_input;
-- (void)setupVarMenu:(NSMenuItem *)o_mi
-                     target:(vlc_object_t *)p_object
-                     var:(const char *)psz_var
-                     selector:(SEL)pf_callback;
+- (IBAction)timesliderUpdate:(id)sender;
 
 - (IBAction)clearRecentItems:(id)sender;
 - (void)openRecentItem:(id)sender;
 
 - (IBAction)viewPreferences:(id)sender;
-
-- (IBAction)timesliderUpdate:(id)sender;
-
 - (IBAction)closeError:(id)sender;
-
 - (IBAction)openReadMe:(id)sender;
 - (IBAction)openDocumentation:(id)sender;
 - (IBAction)reportABug:(id)sender;
index 3ad9323420db2d95bf84f1412bd492a38c9b936e..cde195e6e9a4cdc007d590e22fcd72709f6666bf 100644 (file)
@@ -2,7 +2,7 @@
  * intf.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: intf.m,v 1.87 2003/05/26 14:59:37 hartman Exp $
+ * $Id: intf.m,v 1.88 2003/06/01 23:48:17 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -378,12 +378,12 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     [o_mi_vol_up setTitle: _NS("Volume Up")];
     [o_mi_vol_down setTitle: _NS("Volume Down")];
     [o_mi_mute setTitle: _NS("Mute")];
-    [o_mi_audiotrack setTitle: _NS("Audio Track")];
-    [o_mu_audiotrack setTitle: _NS("Audio Track")];
-    [o_mi_channels setTitle: _NS("Channels")];
-    [o_mu_channels setTitle: _NS("Channels")];
-    [o_mi_device setTitle: _NS("Device")];
-    [o_mu_device setTitle: _NS("Device")];
+    [o_mi_audiotrack setTitle: _NS("Audio track")];
+    [o_mu_audiotrack setTitle: _NS("Audio track")];
+    [o_mi_channels setTitle: _NS("Audio channels")];
+    [o_mu_channels setTitle: _NS("Audio channels")];
+    [o_mi_device setTitle: _NS("Audio device")];
+    [o_mu_device setTitle: _NS("Audio device")];
     
     [o_mu_video setTitle: _NS("Video")];
     [o_mi_half_window setTitle: _NS("Half Size")];
@@ -392,12 +392,12 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     [o_mi_fittoscreen setTitle: _NS("Fit To Screen")];
     [o_mi_fullscreen setTitle: _NS("Fullscreen")];
     [o_mi_floatontop setTitle: _NS("Float On Top")];
-    [o_mi_videotrack setTitle: _NS("Video Track")];
-    [o_mu_videotrack setTitle: _NS("Video Track")];
+    [o_mi_videotrack setTitle: _NS("Video track")];
+    [o_mu_videotrack setTitle: _NS("Video track")];
     [o_mi_screen setTitle: _NS("Screen")];
     [o_mu_screen setTitle: _NS("Screen")];
-    [o_mi_subtitle setTitle: _NS("Subtitles")];
-    [o_mu_subtitle setTitle: _NS("Subtitles")];
+    [o_mi_subtitle setTitle: _NS("Subtitles track")];
+    [o_mu_subtitle setTitle: _NS("Subtitles track")];
     [o_mi_deinterlace setTitle: _NS("Deinterlace")];
     [o_mu_deinterlace setTitle: _NS("Deinterlace")];
 
@@ -533,15 +533,10 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
 
     if( p_input )
     {
-        vout_thread_t   * p_vout  = NULL;
-        aout_instance_t * p_aout  = NULL; 
-
         vlc_mutex_lock( &p_input->stream.stream_lock );
 
         if( !p_input->b_die )
         {
-            audio_volume_t i_volume;
-
             /* New input or stream map change */
             if( p_input->stream.b_changed )
             {
@@ -556,40 +551,6 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
             {
                 p_intf->p_sys->b_input_update = TRUE;
             }
-
-            p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
-                                              FIND_ANYWHERE );
-            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 = TRUE;
-                }
-
-                vlc_object_release( (vlc_object_t *)p_aout );
-            }
-
-            aout_VolumeGet( p_intf, &i_volume );
-            p_intf->p_sys->b_mute = ( i_volume == 0 );
-
-            p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
-                                              FIND_ANYWHERE );
-            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 = TRUE;
-                }
-
-                vlc_object_release( (vlc_object_t *)p_vout );
-            }
-            [self setupMenus: p_input];
         }
         vlc_mutex_unlock( &p_input->stream.stream_lock );
     }
@@ -661,6 +622,7 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
                                               FIND_ANYWHERE );
         if( p_vout != NULL )
         {
+            /* We need to lock the vout here to make sure it does not disappear */
             id o_vout_wnd;
             NSEnumerator * o_enum = [[NSApp windows] objectEnumerator];
             
@@ -814,6 +776,65 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
         userInfo: nil repeats: FALSE];
 }
 
+- (void)setupMenus
+{
+    intf_thread_t * p_intf = [NSApp getIntf];
+    playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
+                                                FIND_ANYWHERE );
+    
+    if( p_playlist != NULL )
+    {
+#define p_input p_playlist->p_input
+        if( p_input != NULL )
+        {
+            [o_controls setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
+                var: "program" selector: @selector(toggleVar:)];
+            
+            [o_controls setupVarMenuItem: o_mi_title target: (vlc_object_t *)p_input
+                var: "title" selector: @selector(toggleVar:)];
+            
+            [o_controls setupVarMenuItem: o_mi_chapter target: (vlc_object_t *)p_input
+                var: "chapter" selector: @selector(toggleVar:)];
+            
+            [o_controls setupVarMenuItem: o_mi_audiotrack target: (vlc_object_t *)p_input
+                var: "audio-es" selector: @selector(toggleVar:)];
+            
+            [o_controls setupVarMenuItem: o_mi_videotrack target: (vlc_object_t *)p_input
+                var: "video-es" selector: @selector(toggleVar:)];
+            
+            [o_controls setupVarMenuItem: o_mi_subtitle target: (vlc_object_t *)p_input
+                var: "spu-es" selector: @selector(toggleVar:)];
+        
+            aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+                                                        FIND_ANYWHERE );
+            if ( p_aout != NULL )
+            {
+                [o_controls setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
+                    var: "audio-channels" selector: @selector(toggleVar:)];
+            
+                [o_controls setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout
+                    var: "audio-device" selector: @selector(toggleVar:)];
+                vlc_object_release( (vlc_object_t *)p_aout );
+            }
+            
+            vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                                                FIND_ANYWHERE );
+            
+            if ( p_vout != NULL )
+            {
+                [o_controls setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout
+                    var: "video-device" selector: @selector(toggleVar:)];
+                
+                [o_controls setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
+                    var: "deinterlace" selector: @selector(toggleVar:)];
+                vlc_object_release( (vlc_object_t *)p_vout );
+            }
+        }
+#undef p_input
+    }
+    vlc_object_release( (vlc_object_t *)p_playlist );
+}
+
 - (void)updateMessageArray
 {
     int i_start, i_stop;
@@ -921,6 +942,7 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     [o_mi_videotrack setEnabled: b_enabled];
     [o_mi_subtitle setEnabled: b_enabled];
     [o_mi_channels setEnabled: b_enabled];
+    [o_mi_deinterlace setEnabled: b_enabled];
     [o_mi_device setEnabled: b_enabled];
     [o_mi_screen setEnabled: b_enabled];
 }
@@ -938,6 +960,58 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     p_intf->p_sys->b_mute = ( i_volume == 0 );
 }
 
+- (IBAction)timesliderUpdate:(id)sender
+{
+    float f_updated;
+
+    switch( [[NSApp currentEvent] type] )
+    {
+        case NSLeftMouseUp:
+        case NSLeftMouseDown:
+            f_slider = [sender floatValue];
+            return;
+
+        case NSLeftMouseDragged:
+            f_updated = [sender floatValue];
+            break;
+
+        default:
+            return;
+    }
+
+    intf_thread_t * p_intf = [NSApp getIntf];
+
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+
+    if( p_playlist == NULL )
+    {
+        return;
+    }
+
+    vlc_mutex_lock( &p_playlist->object_lock );
+
+    if( p_playlist->p_input != NULL )
+    {
+        off_t i_tell;
+        NSString * o_time;
+        char psz_time[ OFFSETTOTIME_MAX_SIZE ];
+
+#define p_area p_playlist->p_input->stream.p_selected_area
+        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
+        i_tell = f_updated / 10000. * p_area->i_size;
+        input_OffsetToTime( p_playlist->p_input, psz_time, i_tell );
+        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+#undef p_area
+
+        o_time = [NSString stringWithUTF8String: psz_time];
+        [o_timefield setStringValue: o_time]; 
+    }
+
+    vlc_mutex_unlock( &p_playlist->object_lock );
+    vlc_object_release( p_playlist );
+}
+
 - (void)terminate
 {
     NSEvent * o_event;
@@ -1008,144 +1082,6 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     [NSApp postEvent: o_event atStart: YES];
 }
 
-- (void)setupMenus:(input_thread_t *)p_input
-{
-    intf_thread_t * p_intf = [NSApp getIntf];
-    vlc_value_t val;
-
-    if( p_intf->p_sys->b_input_update )
-    {
-        val.b_bool = FALSE;
-
-        [self setupVarMenu: o_mi_program target: (vlc_object_t *)p_input
-            var: "program" selector: @selector(toggleVar:)];
-
-        [self setupVarMenu: o_mi_title target: (vlc_object_t *)p_input
-            var: "title" selector: @selector(toggleVar:)];
-
-        [self setupVarMenu: o_mi_chapter target: (vlc_object_t *)p_input
-            var: "chapter" selector: @selector(toggleVar:)];
-
-        [self setupVarMenu: o_mi_audiotrack target: (vlc_object_t *)p_input
-            var: "audio-es" selector: @selector(toggleVar:)];
-
-        [self setupVarMenu: o_mi_videotrack target: (vlc_object_t *)p_input
-            var: "video-es" selector: @selector(toggleVar:)];
-
-        [self setupVarMenu: o_mi_subtitle target: (vlc_object_t *)p_input
-            var: "spu-es" selector: @selector(toggleVar:)];
-
-        p_intf->p_sys->b_input_update = FALSE;
-        var_Set( (vlc_object_t *)p_input, "intf-change", val );
-    }
-
-    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 )
-        {
-            val.b_bool = FALSE;
-            
-            [self setupVarMenu: o_mi_channels target: (vlc_object_t *)p_aout
-                var: "audio-channels" selector: @selector(toggleVar:)];
-
-            [self setupVarMenu: o_mi_device target: (vlc_object_t *)p_aout
-                var: "audio-device" selector: @selector(toggleVar:)];
-            var_Set( (vlc_object_t *)p_aout, "intf-change", val );
-            
-            vlc_object_release( (vlc_object_t *)p_aout );
-        }
-        p_intf->p_sys->b_aout_update = FALSE;
-    }
-
-    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 )
-        {
-            val.b_bool = FALSE;
-
-            [self setupVarMenu: o_mi_screen target: (vlc_object_t *)p_vout
-                var: "video-device" selector: @selector(toggleVar:)];
-            var_Set( (vlc_object_t *)p_vout, "intf-change", val );
-            
-            vlc_object_release( (vlc_object_t *)p_vout );
-            [o_mi_close_window setEnabled: TRUE];
-        }
-        
-        p_intf->p_sys->b_vout_update = FALSE;
-    }
-}
-
-- (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, i_value;
-    NSMenu * o_menu = [o_mi submenu];
-    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++ )
-    {
-        [o_menu removeItemAtIndex: 0];
-    }
-
-    if ( var_Get( p_object, psz_variable, &val ) < 0 )
-    {
-        return;
-    }
-    i_value = val.i_int;
-
-    if ( var_Change( p_object, psz_variable,
-                     VLC_VAR_GETLIST, &val, &text ) < 0 )
-    {
-        return;
-    }
-
-    /* make (un)sensitive */
-    [o_mi setEnabled: ( val.p_list->i_count > 1 )];
-
-    for ( i = 0; i < val.p_list->i_count; i++ )
-    {
-        NSMenuItem * o_lmi;
-        NSString * o_title;
-
-        if ( text.p_list->p_values[i].psz_string )
-        {
-            o_title = [NSApp localizedString: text.p_list->p_values[i].psz_string];
-        }
-        else
-        {
-            o_title = [NSString stringWithFormat: @"%s - %d",
-                        strdup(psz_variable), val.p_list->p_values[i].i_int ];
-        }
-        o_lmi = [o_menu addItemWithTitle: [o_title copy]
-                action: pf_callback keyEquivalent: @""];
-        
-        /* FIXME: this isn't 64-bit clean ! */
-        [o_lmi setTag: val.p_list->p_values[i].i_int];
-        [o_lmi setRepresentedObject:
-            [NSValue valueWithPointer: p_object]];
-        [o_lmi setTarget: o_controls];
-
-        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, &text );
-
-}
-
 - (IBAction)clearRecentItems:(id)sender
 {
     [[NSDocumentController sharedDocumentController]
@@ -1162,58 +1098,6 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     [o_prefs showPrefs];
 }
 
-- (IBAction)timesliderUpdate:(id)sender
-{
-    float f_updated;
-
-    switch( [[NSApp currentEvent] type] )
-    {
-        case NSLeftMouseUp:
-        case NSLeftMouseDown:
-            f_slider = [sender floatValue];
-            return;
-
-        case NSLeftMouseDragged:
-            f_updated = [sender floatValue];
-            break;
-
-        default:
-            return;
-    }
-
-    intf_thread_t * p_intf = [NSApp getIntf];
-
-    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                                       FIND_ANYWHERE );
-
-    if( p_playlist == NULL )
-    {
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->object_lock );
-
-    if( p_playlist->p_input != NULL )
-    {
-        off_t i_tell;
-        NSString * o_time;
-        char psz_time[ OFFSETTOTIME_MAX_SIZE ];
-
-#define p_area p_playlist->p_input->stream.p_selected_area
-        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
-        i_tell = f_updated / 10000. * p_area->i_size;
-        input_OffsetToTime( p_playlist->p_input, psz_time, i_tell );
-        vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-#undef p_area
-
-        o_time = [NSString stringWithUTF8String: psz_time];
-        [o_timefield setStringValue: o_time]; 
-    }
-
-    vlc_mutex_unlock( &p_playlist->object_lock );
-    vlc_object_release( p_playlist );
-}
-
 - (IBAction)closeError:(id)sender
 {
     [o_err_msg setString: @""];
@@ -1307,11 +1191,17 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
 
 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
 {
+    NSString *o_title = [o_mi title];
     BOOL bEnabled = TRUE;
 
-    /* Recent Items Menu */
+    if( [o_title isEqualToString: _NS("License")] )
+    {
+        /* we need to do this only once */
+        [self setupMenus];
+    }
 
-    if( [[o_mi title] isEqualToString: _NS("Clear Menu")] )
+    /* Recent Items Menu */
+    if( [o_title isEqualToString: _NS("Clear Menu")] )
     {
         NSMenu * o_menu = [o_mi_open_recent submenu];
         int i_nb_items = [o_menu numberOfItems];
@@ -1364,7 +1254,6 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
             bEnabled = FALSE;
         }
     }
-
     return( bEnabled );
 }