Changeset ad018626e9d3897b036d1c6893b1456d6230f561
- 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
| r69487bf |
rad01862 |
|
| 78 | 78 | - (IBAction)backward:(id)sender; |
|---|
| 79 | 79 | |
|---|
| 80 | | - (id)getVoutView; |
|---|
| 81 | | |
|---|
| 82 | 80 | - (IBAction)volumeUp:(id)sender; |
|---|
| 83 | 81 | - (IBAction)volumeDown:(id)sender; |
|---|
| … | … | |
| 115 | 113 | |
|---|
| 116 | 114 | /***************************************************************************** |
|---|
| 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 | | /***************************************************************************** |
|---|
| 141 | 115 | * VLCTimeField interface |
|---|
| 142 | 116 | ***************************************************************************** |
|---|
| rc8897e2 |
rad01862 |
|
| 42 | 42 | |
|---|
| 43 | 43 | /***************************************************************************** |
|---|
| | 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 | /***************************************************************************** |
|---|
| 44 | 69 | * VLCControls implementation |
|---|
| 45 | 70 | *****************************************************************************/ |
|---|
| … | … | |
| 125 | 150 | empty = playlist_IsEmpty( p_playlist ); |
|---|
| 126 | 151 | PL_UNLOCK; |
|---|
| 127 | | vlc_object_release( p_playlist ); |
|---|
| | 152 | |
|---|
| | 153 | pl_Release( p_intf ); |
|---|
| 128 | 154 | |
|---|
| 129 | 155 | if( empty ) |
|---|
| … | … | |
| 133 | 159 | } |
|---|
| 134 | 160 | |
|---|
| 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] ) ) |
|---|
| 144 | 170 | { |
|---|
| 145 | 171 | /* 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]; |
|---|
| 149 | 175 | } |
|---|
| 150 | 176 | /* We have a detached vout */ |
|---|
| 151 | | else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ) |
|---|
| | 177 | else if( [[window className] isEqualToString: @"VLCVoutWindow"] ) |
|---|
| 152 | 178 | { |
|---|
| 153 | 179 | 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]; |
|---|
| 158 | 184 | } |
|---|
| 159 | 185 | |
|---|
| … | … | |
| 164 | 190 | /* Close the window directly, because we do know that there |
|---|
| 165 | 191 | * won't be anymore video. It's currently waiting a bit. */ |
|---|
| 166 | | [[[self getVoutView] window] orderOut:self]; |
|---|
| | 192 | [[[self _voutView] window] orderOut:self]; |
|---|
| 167 | 193 | } |
|---|
| 168 | 194 | |
|---|
| … | … | |
| 645 | 671 | } |
|---|
| 646 | 672 | |
|---|
| 647 | | VLCMenuExt *o_data; |
|---|
| | 673 | VLCAutoGeneratedMenuContent *o_data; |
|---|
| 648 | 674 | switch( i_type & VLC_VAR_TYPE ) |
|---|
| 649 | 675 | { |
|---|
| 650 | 676 | 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]; |
|---|
| 653 | 679 | [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; |
|---|
| 654 | 680 | break; |
|---|
| 655 | 681 | |
|---|
| 656 | 682 | 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]; |
|---|
| 659 | 685 | [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; |
|---|
| 660 | 686 | if( !( i_type & VLC_VAR_ISCOMMAND ) ) |
|---|
| … | … | |
| 737 | 763 | NSMenuItem * o_lmi; |
|---|
| 738 | 764 | NSString *o_title = @""; |
|---|
| 739 | | VLCMenuExt *o_data; |
|---|
| | 765 | VLCAutoGeneratedMenuContent *o_data; |
|---|
| 740 | 766 | |
|---|
| 741 | 767 | switch( i_type & VLC_VAR_TYPE ) |
|---|
| … | … | |
| 749 | 775 | |
|---|
| 750 | 776 | 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]; |
|---|
| 753 | 779 | [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; |
|---|
| 754 | 780 | [o_lmi setTarget: self]; |
|---|
| … | … | |
| 767 | 793 | |
|---|
| 768 | 794 | 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]; |
|---|
| 771 | 797 | [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]]; |
|---|
| 772 | 798 | [o_lmi setTarget: self]; |
|---|
| … | … | |
| 789 | 815 | { |
|---|
| 790 | 816 | NSMenuItem *o_mi = (NSMenuItem *)sender; |
|---|
| 791 | | VLCMenuExt *o_data = [[o_mi representedObject] pointerValue]; |
|---|
| | 817 | VLCAutoGeneratedMenuContent *o_data = [[o_mi representedObject] pointerValue]; |
|---|
| 792 | 818 | [NSThread detachNewThreadSelector: @selector(toggleVarThread:) |
|---|
| 793 | 819 | toTarget: self withObject: o_data]; |
|---|
| … | … | |
| 796 | 822 | } |
|---|
| 797 | 823 | |
|---|
| 798 | | - (int)toggleVarThread: (id)_o_data |
|---|
| | 824 | - (int)toggleVarThread: (id)data |
|---|
| 799 | 825 | { |
|---|
| 800 | 826 | vlc_object_t *p_object; |
|---|
| 801 | 827 | 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; |
|---|
| 803 | 831 | |
|---|
| 804 | 832 | vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW ); |
|---|
| 805 | 833 | |
|---|
| 806 | | p_object = (vlc_object_t *)vlc_object_get( VLCIntf->p_libvlc, [o_data objectID] ); |
|---|
| | 834 | p_object = [menuContent vlcObject]; |
|---|
| 807 | 835 | |
|---|
| 808 | 836 | if( p_object != NULL ) |
|---|
| 809 | 837 | { |
|---|
| 810 | | var_Set( p_object, strdup([o_data name]), [o_data value] ); |
|---|
| | 838 | var_Set( p_object, [menuContent name], [menuContent value] ); |
|---|
| 811 | 839 | vlc_object_release( p_object ); |
|---|
| 812 | 840 | [o_pool release]; |
|---|
| … | … | |
| 1042 | 1070 | |
|---|
| 1043 | 1071 | /***************************************************************************** |
|---|
| 1044 | | * VLCMenuExt implementation |
|---|
| | 1072 | * VLCAutoGeneratedMenuContent implementation |
|---|
| 1045 | 1073 | ***************************************************************************** |
|---|
| 1046 | 1074 | * Object connected to a playlistitem which remembers the data belonging to |
|---|
| 1047 | 1075 | * the variable of the autogenerated menu |
|---|
| 1048 | 1076 | *****************************************************************************/ |
|---|
| 1049 | | @implementation VLCMenuExt |
|---|
| 1050 | | |
|---|
| 1051 | | - (id)initWithVar: (const char *)_psz_name Object: (int)i_id |
|---|
| 1052 | | Value: (vlc_value_t)val ofType: (int)_i_type |
|---|
| | 1077 | @implementation VLCAutoGeneratedMenuContent |
|---|
| | 1078 | |
|---|
| | 1079 | -(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object |
|---|
| | 1080 | andValue:(vlc_value_t)val ofType:(int)type |
|---|
| 1053 | 1081 | { |
|---|
| 1054 | 1082 | self = [super init]; |
|---|
| … | … | |
| 1056 | 1084 | if( self != nil ) |
|---|
| 1057 | 1085 | { |
|---|
| 1058 | | psz_name = strdup( _psz_name ); |
|---|
| 1059 | | i_object_id = i_id; |
|---|
| | 1086 | psz_name = strdup( name ); |
|---|
| | 1087 | _vlc_object = vlc_object_yield( object ); |
|---|
| 1060 | 1088 | value = val; |
|---|
| 1061 | | i_type = _i_type; |
|---|
| | 1089 | i_type = type; |
|---|
| 1062 | 1090 | } |
|---|
| 1063 | 1091 | |
|---|
| … | … | |
| 1067 | 1095 | - (void)dealloc |
|---|
| 1068 | 1096 | { |
|---|
| | 1097 | vlc_object_release( _vlc_object ); |
|---|
| 1069 | 1098 | free( psz_name ); |
|---|
| 1070 | 1099 | [super dealloc]; |
|---|
| 1071 | 1100 | } |
|---|
| 1072 | 1101 | |
|---|
| 1073 | | - (char *)name |
|---|
| | 1102 | - (const char *)name |
|---|
| 1074 | 1103 | { |
|---|
| 1075 | 1104 | return psz_name; |
|---|
| 1076 | 1105 | } |
|---|
| 1077 | 1106 | |
|---|
| 1078 | | - (int)objectID |
|---|
| 1079 | | { |
|---|
| 1080 | | return i_object_id; |
|---|
| 1081 | | } |
|---|
| 1082 | | |
|---|
| 1083 | 1107 | - (vlc_value_t)value |
|---|
| 1084 | 1108 | { |
|---|
| 1085 | 1109 | return value; |
|---|
| 1086 | 1110 | } |
|---|
| | 1111 | |
|---|
| | 1112 | - (vlc_object_t *)vlcObject |
|---|
| | 1113 | { |
|---|
| | 1114 | return vlc_object_yield( _vlc_object ); |
|---|
| | 1115 | } |
|---|
| | 1116 | |
|---|
| 1087 | 1117 | |
|---|
| 1088 | 1118 | - (int)type |
|---|