Changeset ad018626e9d3897b036d1c6893b1456d6230f561

Show
Ignore:
Timestamp:
20/09/08 19:25:38 (3 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1221931538 +0200
git-parent:

[77e710083e01461f3bcda759177866f4c90a0878]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1221931538 +0200
Message:

macosx: Don't use object_id in controls.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/macosx/controls.h

    r69487bf rad01862  
    7878- (IBAction)backward:(id)sender; 
    7979 
    80 - (id)getVoutView; 
    81  
    8280- (IBAction)volumeUp:(id)sender; 
    8381- (IBAction)volumeDown:(id)sender; 
     
    115113 
    116114/***************************************************************************** 
    117  * VLCMenuExt interface 
    118  ***************************************************************************** 
    119  * This holds our data for autogenerated menus 
    120  *****************************************************************************/ 
    121 @interface VLCMenuExt : NSObject 
    122 { 
    123     char *psz_name; 
    124     int i_object_id; 
    125     vlc_value_t value; 
    126     int i_type; 
    127 } 
    128  
    129 - (id)initWithVar: (const char *)_psz_name  
    130            Object: (int)i_id 
    131             Value: (vlc_value_t)val  
    132            ofType: (int)_i_type; 
    133 - (char *)name; 
    134 - (int)objectID; 
    135 - (vlc_value_t)value; 
    136 - (int)type; 
    137  
    138 @end 
    139  
    140 /***************************************************************************** 
    141115 * VLCTimeField interface 
    142116 ***************************************************************************** 
  • modules/gui/macosx/controls.m

    rc8897e2 rad01862  
    4242 
    4343/***************************************************************************** 
     44 * VLCAutoGeneratedMenuContent interface 
     45 ***************************************************************************** 
     46 * This holds our data for autogenerated menus 
     47 *****************************************************************************/ 
     48@interface VLCAutoGeneratedMenuContent : NSObject 
     49{ 
     50    char *psz_name; 
     51    vlc_object_t * _vlc_object; 
     52    vlc_value_t value; 
     53    int i_type; 
     54} 
     55 
     56- (id)initWithVariableName: (const char *)name  
     57           ofObject: (vlc_object_t *)object 
     58           andValue: (vlc_value_t)value  
     59           ofType: (int)type; 
     60- (const char *)name; 
     61- (vlc_value_t)value; 
     62- (vlc_object_t *)vlcObject; 
     63- (int)type; 
     64 
     65@end 
     66 
     67#pragma mark - 
     68/***************************************************************************** 
    4469 * VLCControls implementation 
    4570 *****************************************************************************/ 
     
    125150    empty = playlist_IsEmpty( p_playlist ); 
    126151    PL_UNLOCK; 
    127     vlc_object_release( p_playlist ); 
     152 
     153    pl_Release( p_intf ); 
    128154 
    129155    if( empty ) 
     
    133159} 
    134160 
    135 /* Small helper method */ 
    136  
    137 -(id) getVoutView 
    138 { 
    139     id o_window; 
    140     id o_vout_view = nil; 
    141     id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList]; 
    142     NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator]; 
    143     while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) ) 
     161/* Small helper method (Private) */ 
     162 
     163- (id)_voutView 
     164{ 
     165    id window; 
     166    id voutView = nil; 
     167    id embeddedViewList = [[VLCMain sharedInstance] getEmbeddedList]; 
     168    NSEnumerator *enumerator = [[NSApp orderedWindows] objectEnumerator]; 
     169    while( !voutView && ( window = [enumerator nextObject] ) ) 
    144170    { 
    145171        /* We have an embedded vout */ 
    146         if( [o_embedded_vout_list windowContainsEmbedded: o_window] ) 
    147         { 
    148             o_vout_view = [o_embedded_vout_list getViewForWindow: o_window]; 
     172        if( [embeddedViewList windowContainsEmbedded: window] ) 
     173        { 
     174            voutView = [embeddedViewList getViewForWindow: window]; 
    149175        } 
    150176        /* We have a detached vout */ 
    151         else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ) 
     177        else if( [[window className] isEqualToString: @"VLCVoutWindow"] ) 
    152178        { 
    153179            msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" ); 
    154             o_vout_view = [o_window getVoutView]; 
    155         } 
    156     } 
    157     return o_vout_view
     180            voutView = [window getVoutView]; 
     181        } 
     182    } 
     183    return [[voutView retain] autorelease]
    158184} 
    159185 
     
    164190    /* Close the window directly, because we do know that there 
    165191     * won't be anymore video. It's currently waiting a bit. */ 
    166     [[[self getVoutView] window] orderOut:self]; 
     192    [[[self _voutView] window] orderOut:self]; 
    167193} 
    168194 
     
    645671    } 
    646672 
    647     VLCMenuExt *o_data; 
     673    VLCAutoGeneratedMenuContent *o_data; 
    648674    switch( i_type & VLC_VAR_TYPE ) 
    649675    { 
    650676    case VLC_VAR_VOID: 
    651         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id 
    652                 Value: val ofType: i_type]; 
     677        o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object 
     678                andValue: val ofType: i_type]; 
    653679        [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; 
    654680        break; 
    655681 
    656682    case VLC_VAR_BOOL: 
    657         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id 
    658                 Value: val ofType: i_type]; 
     683        o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object 
     684                andValue: val ofType: i_type]; 
    659685        [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; 
    660686        if( !( i_type & VLC_VAR_ISCOMMAND ) ) 
     
    737763        NSMenuItem * o_lmi; 
    738764        NSString *o_title = @""; 
    739         VLCMenuExt *o_data; 
     765        VLCAutoGeneratedMenuContent *o_data; 
    740766 
    741767        switch( i_type & VLC_VAR_TYPE ) 
     
    749775 
    750776            o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""]; 
    751             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id 
    752                     Value: another_val ofType: i_type]; 
     777            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object 
     778                    andValue: another_val ofType: i_type]; 
    753779            [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; 
    754780            [o_lmi setTarget: self]; 
     
    767793 
    768794            o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ]; 
    769             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id 
    770                     Value: val_list.p_list->p_values[i] ofType: i_type]; 
     795            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object 
     796                    andValue: val_list.p_list->p_values[i] ofType: i_type]; 
    771797            [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]]; 
    772798            [o_lmi setTarget: self]; 
     
    789815{ 
    790816    NSMenuItem *o_mi = (NSMenuItem *)sender; 
    791     VLCMenuExt *o_data = [[o_mi representedObject] pointerValue]; 
     817    VLCAutoGeneratedMenuContent *o_data = [[o_mi representedObject] pointerValue]; 
    792818    [NSThread detachNewThreadSelector: @selector(toggleVarThread:) 
    793819        toTarget: self withObject: o_data]; 
     
    796822} 
    797823 
    798 - (int)toggleVarThread: (id)_o_data 
     824- (int)toggleVarThread: (id)data 
    799825{ 
    800826    vlc_object_t *p_object; 
    801827    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
    802     VLCMenuExt *o_data = (VLCMenuExt *)_o_data; 
     828 
     829    assert([data isKindOfClass:[VLCAutoGeneratedMenuContent class]]); 
     830    VLCAutoGeneratedMenuContent *menuContent = (VLCAutoGeneratedMenuContent *)data; 
    803831 
    804832    vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW ); 
    805833 
    806     p_object = (vlc_object_t *)vlc_object_get( VLCIntf->p_libvlc, [o_data objectID] )
     834    p_object = [menuContent vlcObject]
    807835 
    808836    if( p_object != NULL ) 
    809837    { 
    810         var_Set( p_object, strdup([o_data name]), [o_data value] ); 
     838        var_Set( p_object, [menuContent name], [menuContent value] ); 
    811839        vlc_object_release( p_object ); 
    812840        [o_pool release]; 
     
    10421070 
    10431071/***************************************************************************** 
    1044  * VLCMenuExt implementation 
     1072 * VLCAutoGeneratedMenuContent implementation 
    10451073 ***************************************************************************** 
    10461074 * Object connected to a playlistitem which remembers the data belonging to 
    10471075 * the variable of the autogenerated menu 
    10481076 *****************************************************************************/ 
    1049 @implementation VLCMenuEx
    1050  
    1051 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id 
    1052         Value: (vlc_value_t)val ofType: (int)_i_type 
     1077@implementation VLCAutoGeneratedMenuConten
     1078 
     1079-(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object 
     1080        andValue:(vlc_value_t)val ofType:(int)type 
    10531081{ 
    10541082    self = [super init]; 
     
    10561084    if( self != nil ) 
    10571085    { 
    1058         psz_name = strdup( _psz_name ); 
    1059         i_object_id = i_id
     1086        psz_name = strdup( name ); 
     1087        _vlc_object = vlc_object_yield( object )
    10601088        value = val; 
    1061         i_type = _i_type; 
     1089        i_type = type; 
    10621090    } 
    10631091 
     
    10671095- (void)dealloc 
    10681096{ 
     1097    vlc_object_release( _vlc_object ); 
    10691098    free( psz_name ); 
    10701099    [super dealloc]; 
    10711100} 
    10721101 
    1073 - (char *)name 
     1102- (const char *)name 
    10741103{ 
    10751104    return psz_name; 
    10761105} 
    10771106 
    1078 - (int)objectID 
    1079 { 
    1080     return i_object_id; 
    1081 } 
    1082  
    10831107- (vlc_value_t)value 
    10841108{ 
    10851109    return value; 
    10861110} 
     1111 
     1112- (vlc_object_t *)vlcObject 
     1113{ 
     1114    return vlc_object_yield( _vlc_object ); 
     1115} 
     1116 
    10871117 
    10881118- (int)type