Changeset bf680e8fb64910e8d968addce71139d135a9b33f

Show
Ignore:
Timestamp:
05/07/04 03:27:35 (4 years ago)
Author:
Derk-Jan Hartman <hartman@videolan.org>
git-committer:
Derk-Jan Hartman <hartman@videolan.org> 1088990855 +0000
git-parent:

[7b5375e2c9f6a7b6a2f187c114b4275326ca0a77]

git-author:
Derk-Jan Hartman <hartman@videolan.org> 1088990855 +0000
Message:

* OSX lowlevel work

  • The VLCApplication is now launched at the vlc.c level instead of at the module level. Allows VLC to be a more valid Mac application, also removes the vout intf dependancy (use ncurses to disp. video :).
    This wasn't done at the libvlc level, because a mozilla plugin would no longer be able to function properly.
  • Some functionality of the macosx vout may not work without the OS X GUI, and not all of this is checked yet.
  • There is a symlink in VLC.app/Contents/Mac called clivlc that will force it back to a fullblown cli app when you want, so it can still be run by a user who isn't logged in via GUI.
  • there are some autorelease leaks which need to be tackled.
  • moved a lot of the VLCApplication func. to the VLCMain class.
  • VLCMain is a +sharedInstance now.
  • the complete OS X interface is still badly broken because of the many API changes lately. any volunteers?

Examples:
VLC.app/Contents/MacOS/VLC [-I macosx]
launches VLC as before (requires you to be logged in via GUI)

VLC.app/Contents/MacOS/VLC -I ncurses
launch vlc with a ncurses intf and display video on your mac
(requires you to be logged in via GUI)

VLC.app/Contents/MacOS/clivlc -I telnet -d
launch vlm remotely trough ssh in daemon mode, on a GUI'less server for instance, and stream your vids

Now how is that for combining GUI and cli in one application on the mac?!!? :)
jlj? I finally understand now how the OS X interface works !

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Makefile.am

    r6b46f68 rbf680e8  
    493493    $(INSTALL) $(top_builddir)/vlc \ 
    494494           $(top_builddir)/VLC.app/Contents/MacOS/VLC 
     495    ln -sf ./VLC $(top_builddir)/VLC.app/Contents/MacOS/clivlc 
    495496    $(INSTALL) -d $(top_builddir)/VLC.app/Contents/MacOS/modules 
    496497    for i in "" `$(VLC_CONFIG) --target plugin` ; do \ 
  • TODO

    r264724a rbf680e8  
    184184Status: Todo 
    185185 
     186Task 
     187Difficulty: Medium 
     188Urgency: Wishlist 
     189Platform: any 
     190Description: IceCast/ShoutCast serving 
     191This would be a nice thing for the sake of completeness of VLC's streaming capabilities. 
     192Status: Todo 
    186193 
    187194Task 
  • configure.ac

    r7b55e81 rbf680e8  
    121121    VLC_ADD_LDFLAGS([vlc ffmpeg],[-all_load]) 
    122122    VLC_ADD_LDFLAGS([mp4], [-framework IOKit -framework CoreFoundation]) 
     123    VLC_ADD_CFLAGS([vlc],[-x objective-c]) 
    123124    VLC_ADD_LDFLAGS([vlc],[-Wl,-multiply_defined,suppress]) 
    124125    ;; 
     
    12381239          if test -n "${enable_dvdread}" 
    12391240          then 
    1240             AC_MSG_WARN([Please get libdvdread from http://www.dtek.chalmers.se/groups/dvd/downloads.shtml]) 
    12411241            AC_MSG_ERROR([cannot find libdvdread headers]) 
    12421242          fi 
  • extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib

    r458cd04 rbf680e8  
    2222    <key>IBOpenObjects</key> 
    2323    <array> 
     24        <integer>21</integer> 
     25        <integer>1617</integer> 
     26        <integer>1647</integer> 
    2427        <integer>29</integer> 
    25         <integer>1617</integer> 
    26         <integer>21</integer> 
    27         <integer>1647</integer> 
    2828    </array> 
    2929    <key>IBSystem Version</key> 
    30     <string>7F44</string> 
     30    <string>7H63</string> 
    3131</dict> 
    3232</plist> 
  • modules/gui/macosx/applescript.m

    r8b501c4 rbf680e8  
    4242    if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] ) 
    4343    { 
    44         intf_thread_t * p_intf = [NSApp getIntf]
     44        intf_thread_t * p_intf = VLCIntf
    4545        playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    4646                                                        FIND_ANYWHERE ); 
     
    8585    NSString *o_command = [[self commandDescription] commandName]; 
    8686 
    87     intf_thread_t * p_intf = [NSApp getIntf]
     87    intf_thread_t * p_intf = VLCIntf
    8888    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    8989                                                    FIND_ANYWHERE ); 
  • modules/gui/macosx/controls.m

    r103019a rbf680e8  
    4646    vlc_value_t val; 
    4747    playlist_t * p_playlist; 
    48     intf_thread_t * p_intf = [NSApp getIntf]
     48    intf_thread_t * p_intf = VLCIntf
    4949    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    5050                                                       FIND_ANYWHERE ); 
     
    8888- (IBAction)stop:(id)sender 
    8989{ 
    90     intf_thread_t * p_intf = [NSApp getIntf]
     90    intf_thread_t * p_intf = VLCIntf
    9191    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    9292                                                       FIND_ANYWHERE ); 
     
    101101- (IBAction)faster:(id)sender 
    102102{ 
    103     intf_thread_t * p_intf = [NSApp getIntf]
     103    intf_thread_t * p_intf = VLCIntf
    104104    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    105105                                                       FIND_ANYWHERE ); 
     
    116116- (IBAction)slower:(id)sender 
    117117{ 
    118     intf_thread_t * p_intf = [NSApp getIntf]
     118    intf_thread_t * p_intf = VLCIntf
    119119    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    120120                                                       FIND_ANYWHERE ); 
     
    131131- (IBAction)prev:(id)sender 
    132132{ 
    133     intf_thread_t * p_intf = [NSApp getIntf]
     133    intf_thread_t * p_intf = VLCIntf
    134134    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    135135                                                       FIND_ANYWHERE ); 
     
    144144- (IBAction)next:(id)sender 
    145145{ 
    146     intf_thread_t * p_intf = [NSApp getIntf]
     146    intf_thread_t * p_intf = VLCIntf
    147147    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    148148                                                       FIND_ANYWHERE ); 
     
    157157- (IBAction)random:(id)sender 
    158158{ 
    159     intf_thread_t * p_intf = [NSApp getIntf]
     159    intf_thread_t * p_intf = VLCIntf
    160160    vlc_value_t val; 
    161161    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     
    185185- (IBAction)repeat:(id)sender 
    186186{ 
    187     intf_thread_t * p_intf = [NSApp getIntf]
     187    intf_thread_t * p_intf = VLCIntf
    188188    vlc_value_t val; 
    189189    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     
    217217- (IBAction)loop:(id)sender 
    218218{ 
    219     intf_thread_t * p_intf = [NSApp getIntf]
     219    intf_thread_t * p_intf = VLCIntf
    220220    vlc_value_t val; 
    221221    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     
    249249- (IBAction)forward:(id)sender 
    250250{ 
    251     intf_thread_t * p_intf = [NSApp getIntf]
     251    intf_thread_t * p_intf = VLCIntf
    252252    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    253253                                                       FIND_ANYWHERE ); 
     
    264264- (IBAction)backward:(id)sender 
    265265{ 
    266     intf_thread_t * p_intf = [NSApp getIntf]
     266    intf_thread_t * p_intf = VLCIntf
    267267    input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    268268                                                       FIND_ANYWHERE ); 
     
    280280- (IBAction)volumeUp:(id)sender 
    281281{ 
    282     intf_thread_t * p_intf = [NSApp getIntf]
     282    intf_thread_t * p_intf = VLCIntf
    283283 
    284284    if( p_intf->p_sys->b_mute ) 
     
    294294- (IBAction)volumeDown:(id)sender 
    295295{ 
    296     intf_thread_t * p_intf = [NSApp getIntf]
     296    intf_thread_t * p_intf = VLCIntf
    297297 
    298298    if( p_intf->p_sys->b_mute ) 
     
    308308- (IBAction)mute:(id)sender 
    309309{ 
    310     intf_thread_t * p_intf = [NSApp getIntf]
     310    intf_thread_t * p_intf = VLCIntf
    311311    audio_volume_t i_volume; 
    312312 
     
    319319- (IBAction)volumeSliderUpdated:(id)sender 
    320320{ 
    321     intf_thread_t * p_intf = [NSApp getIntf]
     321    intf_thread_t * p_intf = VLCIntf
    322322    audio_volume_t i_volume = (audio_volume_t)[sender intValue]; 
    323323 
     
    327327- (void)updateVolumeSlider 
    328328{ 
    329     intf_thread_t * p_intf = [NSApp getIntf]
     329    intf_thread_t * p_intf = VLCIntf
    330330    audio_volume_t i_volume; 
    331331 
     
    344344    NSArray *o_windows = [NSApp orderedWindows]; 
    345345    NSEnumerator *o_enumerator = [o_windows objectEnumerator]; 
    346     vout_thread_t   *p_vout = vlc_object_find( [NSApp getIntf], VLC_OBJECT_VOUT, 
     346    vout_thread_t   *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, 
    347347                                              FIND_ANYWHERE ); 
    348348 
     
    409409    /* Get the descriptive name of the variable */ 
    410410    var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL ); 
    411     [o_mi setTitle: [NSApp localizedString: text.psz_string ? 
     411    [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ? 
    412412                                        text.psz_string : strdup( psz_variable ) ]]; 
    413413 
     
    524524                strdup(val_list.p_list->p_values[i].psz_string); 
    525525 
    526             o_title = [NSApp localizedString: text_list.p_list->p_values[i].psz_string ? 
     526            o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ? 
    527527                text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ]; 
    528528 
     
    541541 
    542542             o_title = text_list.p_list->p_values[i].psz_string ? 
    543                                  [NSApp localizedString: strdup( text_list.p_list->p_values[i].psz_string )] : 
     543                                 [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] : 
    544544                                 [NSString stringWithFormat: @"%d", 
    545545                                 val_list.p_list->p_values[i].i_int]; 
     
    581581    VLCMenuExt *o_data = (VLCMenuExt *)_o_data; 
    582582 
    583     vlc_thread_set_priority( [NSApp getIntf] , VLC_THREAD_PRIORITY_LOW ); 
    584  
    585     p_object = (vlc_object_t *)vlc_object_get( [NSApp getIntf]
     583    vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW ); 
     584 
     585    p_object = (vlc_object_t *)vlc_object_get( VLCIntf
    586586                                    [o_data objectID] ); 
    587587 
     
    605605    BOOL bEnabled = TRUE; 
    606606    vlc_value_t val; 
    607     intf_thread_t * p_intf = [NSApp getIntf]
     607    intf_thread_t * p_intf = VLCIntf
    608608    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    609609                                                       FIND_ANYWHERE ); 
  • modules/gui/macosx/intf.h

    r5f6c3bf rbf680e8  
    3232 
    3333/***************************************************************************** 
    34  * VLCApplication interface 
    35  *****************************************************************************/ 
    36 @interface VLCApplication : NSApplication 
    37 
    38     intf_thread_t *p_intf; 
    39 
    40  
    41 - (NSString *)localizedString:(char *)psz; 
    42 - (char *)delocalizeString:(NSString *)psz; 
    43 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width; 
    44  
    45 - (void)setIntf:(intf_thread_t *)p_intf; 
    46 - (intf_thread_t *)getIntf; 
    47 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event; 
    48  
    49 @end 
    50  
    51 #define _NS(s) [NSApp localizedString: _(s)] 
     34 * Local prototypes. 
     35 *****************************************************************************/ 
     36int ExecuteOnMainThread( id target, SEL sel, void * p_arg ); 
     37unsigned int CocoaKeyToVLC( unichar i_key ); 
     38 
     39#define VLCIntf [[VLCMain sharedInstance] getIntf] 
     40 
     41#define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)] 
    5242/* Get an alternate version of the string. 
    5343 * This string is stored as '1:string' but when displayed it only displays 
    5444 * the translated string. the translation should be '1:translatedstring' though */ 
    55 #define _ANS(s) [[NSApp localizedString: _(s)] substringFromIndex:2] 
    56  
    57 int ExecuteOnMainThread( id target, SEL sel, void * p_arg ); 
    58 int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable, 
    59                      vlc_value_t old_val, vlc_value_t new_val, void *param ); 
    60 unsigned int CocoaKeyToVLC( unichar i_key ); 
     45#define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2] 
    6146 
    6247/***************************************************************************** 
     
    9378@interface VLCMain : NSObject 
    9479{ 
     80    intf_thread_t *p_intf;      /* The main intf object */ 
    9581    id o_prefs;                 /* VLCPrefs       */ 
    9682 
     
    239225} 
    240226 
     227+ (VLCMain *)sharedInstance; 
     228 
     229- (intf_thread_t *)getIntf; 
     230- (void)setIntf:(intf_thread_t *)p_mainintf; 
     231 
    241232- (id)getControls; 
    242233- (id)getPlaylist; 
    243234- (id)getInfo; 
    244235- (void)terminate; 
     236- (NSString *)localizedString:(char *)psz; 
     237- (char *)delocalizeString:(NSString *)psz; 
     238- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width; 
     239- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event; 
    245240 
    246241- (void)initStrings; 
  • modules/gui/macosx/intf.m

    r103019a rbf680e8  
    7171    p_intf->pf_run = Run; 
    7272     
    73     [VLCApplication sharedApplication]; 
    74     [NSApp setIntf: p_intf]; 
    75  
    76     [NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; 
     73    [[VLCMain sharedInstance] setIntf: p_intf]; 
    7774 
    7875    return( 0 ); 
     
    103100     * (???) --Meuuh */ 
    104101    vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 
    105  
    106     [NSApp run]; 
    107 
    108  
    109 /***************************************************************************** 
    110  * VLCApplication implementation  
    111  *****************************************************************************/ 
    112 @implementation VLCApplication 
    113  
    114 - (NSString *)localizedString:(char *)psz 
    115 
    116     NSString * o_str = nil; 
    117  
    118     if( psz != NULL ) 
    119     { 
    120         o_str = [[[NSString alloc] initWithUTF8String: psz] autorelease]; 
    121     } 
    122     if ( o_str == NULL ) 
    123     { 
    124         msg_Err( p_intf, "could not translate: %s", psz ); 
    125     } 
    126  
    127     return( o_str ); 
    128 
    129  
    130 - (char *)delocalizeString:(NSString *)id 
    131 
    132     NSData * o_data = [id dataUsingEncoding: NSUTF8StringEncoding 
    133                           allowLossyConversion: NO]; 
    134     char * psz_string; 
    135  
    136     if ( o_data == nil ) 
    137     { 
    138         o_data = [id dataUsingEncoding: NSUTF8StringEncoding 
    139                      allowLossyConversion: YES]; 
    140         psz_string = malloc( [o_data length] + 1 );  
    141         [o_data getBytes: psz_string]; 
    142         psz_string[ [o_data length] ] = '\0'; 
    143         msg_Err( p_intf, "cannot convert to wanted encoding: %s", 
    144                  psz_string ); 
    145     } 
    146     else 
    147     { 
    148         psz_string = malloc( [o_data length] + 1 );  
    149         [o_data getBytes: psz_string]; 
    150         psz_string[ [o_data length] ] = '\0'; 
    151     } 
    152  
    153     return psz_string; 
    154 
    155  
    156 /* i_width is in pixels */ 
    157 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width 
    158 
    159     NSMutableString *o_wrapped; 
    160     NSString *o_out_string; 
    161     NSRange glyphRange, effectiveRange, charRange; 
    162     NSRect lineFragmentRect; 
    163     unsigned glyphIndex, breaksInserted = 0; 
    164  
    165     NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string 
    166         attributes: [NSDictionary dictionaryWithObjectsAndKeys: 
    167         [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]]; 
    168     NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init]; 
    169     NSTextContainer *o_container = [[NSTextContainer alloc] 
    170         initWithContainerSize: NSMakeSize(i_width, 2000)]; 
    171      
    172     [o_layout_manager addTextContainer: o_container]; 
    173     [o_container release]; 
    174     [o_storage addLayoutManager: o_layout_manager]; 
    175     [o_layout_manager release]; 
    176          
    177     o_wrapped = [o_in_string mutableCopy]; 
    178     glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container]; 
    179      
    180     for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ; 
    181             glyphIndex += effectiveRange.length) { 
    182         lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex 
    183                                             effectiveRange: &effectiveRange]; 
    184         charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange 
    185                                     actualGlyphRange: &effectiveRange]; 
    186         if ([o_wrapped lineRangeForRange: 
    187                 NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) { 
    188             [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted]; 
    189             breaksInserted++; 
    190         } 
    191     } 
    192     o_out_string = [NSString stringWithString: o_wrapped]; 
    193     [o_wrapped release]; 
    194     [o_storage release]; 
    195      
    196     return o_out_string; 
    197 
    198  
    199 - (void)setIntf:(intf_thread_t *)_p_intf 
    200 
    201     p_intf = _p_intf; 
    202 
    203  
    204 - (intf_thread_t *)getIntf 
    205 
    206     return( p_intf ); 
    207 
    208  
    209 - (void)terminate:(id)sender 
    210 
    211     p_intf->p_vlc->b_die = VLC_TRUE; 
    212     [super terminate:sender]; 
    213 
    214  
    215  
    216 /***************************************************************************** 
    217  * hasDefinedShortcutKey: Check to see if the key press is a defined VLC 
    218  * shortcut key.  If it is, pass it off to VLC for handling and return YES, 
    219  * otherwise ignore it and return NO (where it will get handled by Cocoa). 
    220  *****************************************************************************/ 
    221 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event 
    222 
    223     unichar key = 0; 
    224     vlc_value_t val; 
    225     unsigned int i_pressed_modifiers = 0; 
    226     struct hotkey *p_hotkeys; 
    227     int i; 
    228  
    229     val.i_int = 0; 
    230     p_hotkeys = p_intf->p_vlc->p_hotkeys; 
    231  
    232     i_pressed_modifiers = [o_event modifierFlags]; 
    233  
    234     if( i_pressed_modifiers & NSShiftKeyMask ) 
    235         val.i_int |= KEY_MODIFIER_SHIFT; 
    236     if( i_pressed_modifiers & NSControlKeyMask ) 
    237         val.i_int |= KEY_MODIFIER_CTRL; 
    238     if( i_pressed_modifiers & NSAlternateKeyMask ) 
    239         val.i_int |= KEY_MODIFIER_ALT; 
    240     if( i_pressed_modifiers & NSCommandKeyMask ) 
    241         val.i_int |= KEY_MODIFIER_COMMAND; 
    242  
    243     key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0]; 
    244  
    245     val.i_int |= CocoaKeyToVLC( key ); 
    246  
    247     for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) 
    248     { 
    249         if( p_hotkeys[i].i_key == val.i_int ) 
    250         { 
    251             var_Set( p_intf->p_vlc, "key-pressed", val ); 
    252             return YES; 
    253         } 
    254     } 
    255  
    256     return NO; 
    257 
    258  
    259 @end 
     102    [NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; 
     103
    260104 
    261105int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) 
     
    272116                waitUntilDone: YES]; 
    273117    } 
    274     else if( NSApp != nil && [NSApp respondsToSelector: @selector(getIntf)] )  
     118    else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )  
    275119    { 
    276120        NSValue * o_v1; 
     
    286130        id * val[] = { &o_lock, &o_v2 }; 
    287131 
    288         p_intf = (intf_thread_t *)[NSApp getIntf]
     132        p_intf = (intf_thread_t *)VLCIntf
    289133 
    290134        o_recv_port = [[NSPort port] retain]; 
     
    330174                     vlc_value_t old_val, vlc_value_t new_val, void *param ) 
    331175{ 
    332     intf_thread_t * p_intf = [NSApp getIntf]
     176    intf_thread_t * p_intf = VLCIntf
    333177    p_intf->p_sys->b_playlist_update = TRUE; 
    334178    p_intf->p_sys->b_intf_update = TRUE; 
     
    418262@implementation VLCMain 
    419263 
     264static VLCMain *_o_sharedMainInstance = nil; 
     265 
     266+ (VLCMain *)sharedInstance 
     267{ 
     268    return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init]; 
     269} 
     270 
     271- (id)init  
     272{ 
     273    if (_o_sharedMainInstance) { 
     274        [self dealloc]; 
     275    } else { 
     276        _o_sharedMainInstance = [super init]; 
     277    } 
     278     
     279    return _o_sharedMainInstance; 
     280} 
     281 
     282- (void)setIntf: (intf_thread_t *)p_mainintf { 
     283    p_intf = p_mainintf; 
     284} 
     285 
     286- (intf_thread_t *)getIntf { 
     287    return p_intf; 
     288} 
     289 
    420290- (void)awakeFromNib 
    421291{ 
    422292    unsigned int i_key = 0; 
    423     intf_thread_t * p_intf = [NSApp getIntf]
     293    intf_thread_t * p_intf = VLCIntf
    424294    playlist_t *p_playlist; 
    425295    vlc_value_t val; 
     
    633503- (void)applicationWillFinishLaunching:(NSNotification *)o_notification 
    634504{ 
    635     intf_thread_t * p_intf = [NSApp getIntf]; 
    636  
    637505    o_msg_lock = [[NSLock alloc] init]; 
    638506    o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain]; 
     
    660528    vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); 
    661529} 
    662  
     530/* 
    663531- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename 
    664532{ 
     
    669537    return( TRUE ); 
    670538} 
     539*/ 
     540- (NSString *)localizedString:(char *)psz 
     541{ 
     542    NSString * o_str = nil; 
     543 
     544    if( psz != NULL ) 
     545    { 
     546        o_str = [[[NSString alloc] initWithUTF8String: psz] autorelease]; 
     547    } 
     548    if ( o_str == NULL ) 
     549    { 
     550        msg_Err( VLCIntf, "could not translate: %s", psz ); 
     551    } 
     552 
     553    return( o_str ); 
     554} 
     555 
     556- (char *)delocalizeString:(NSString *)id 
     557{ 
     558    NSData * o_data = [id dataUsingEncoding: NSUTF8StringEncoding 
     559                          allowLossyConversion: NO]; 
     560    char * psz_string; 
     561 
     562    if ( o_data == nil ) 
     563    { 
     564        o_data = [id dataUsingEncoding: NSUTF8StringEncoding 
     565                     allowLossyConversion: YES]; 
     566        psz_string = malloc( [o_data length] + 1 );  
     567        [o_data getBytes: psz_string]; 
     568        psz_string[ [o_data length] ] = '\0'; 
     569        msg_Err( VLCIntf, "cannot convert to wanted encoding: %s", 
     570                 psz_string ); 
     571    } 
     572    else 
     573    { 
     574        psz_string = malloc( [o_data length] + 1 );  
     575        [o_data getBytes: psz_string]; 
     576        psz_string[ [o_data length] ] = '\0'; 
     577    } 
     578 
     579    return psz_string; 
     580} 
     581 
     582/* i_width is in pixels */ 
     583- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width 
     584{ 
     585    NSMutableString *o_wrapped; 
     586    NSString *o_out_string; 
     587    NSRange glyphRange, effectiveRange, charRange; 
     588    NSRect lineFragmentRect; 
     589    unsigned glyphIndex, breaksInserted = 0; 
     590 
     591    NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string 
     592        attributes: [NSDictionary dictionaryWithObjectsAndKeys: 
     593        [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]]; 
     594    NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init]; 
     595    NSTextContainer *o_container = [[NSTextContainer alloc] 
     596        initWithContainerSize: NSMakeSize(i_width, 2000)]; 
     597     
     598    [o_layout_manager addTextContainer: o_container]; 
     599    [o_container release]; 
     600    [o_storage addLayoutManager: o_layout_manager]; 
     601    [o_layout_manager release]; 
     602         
     603    o_wrapped = [o_in_string mutableCopy]; 
     604    glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container]; 
     605     
     606    for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ; 
     607            glyphIndex += effectiveRange.length) { 
     608        lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex 
     609                                            effectiveRange: &effectiveRange]; 
     610        charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange 
     611                                    actualGlyphRange: &effectiveRange]; 
     612        if ([o_wrapped lineRangeForRange: 
     613                NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) { 
     614            [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted]; 
     615            breaksInserted++; 
     616        } 
     617    } 
     618    o_out_string = [NSString stringWithString: o_wrapped]; 
     619    [o_wrapped release]; 
     620    [o_storage release]; 
     621     
     622    return o_out_string; 
     623} 
     624 
     625 
     626/***************************************************************************** 
     627 * hasDefinedShortcutKey: Check to see if the key press is a defined VLC 
     628 * shortcut key.  If it is, pass it off to VLC for handling and return YES, 
     629 * otherwise ignore it and return NO (where it will get handled by Cocoa). 
     630 *****************************************************************************/ 
     631- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event 
     632{ 
     633    unichar key = 0; 
     634    vlc_value_t val; 
     635    unsigned int i_pressed_modifiers = 0; 
     636    struct hotkey *p_hotkeys; 
     637    int i; 
     638 
     639    val.i_int = 0; 
     640    p_hotkeys = VLCIntf->p_vlc->p_hotkeys; 
     641 
     642    i_pressed_modifiers = [o_event modifierFlags]; 
     643 
     644    if( i_pressed_modifiers & NSShiftKeyMask ) 
     645        val.i_int |= KEY_MODIFIER_SHIFT; 
     646    if( i_pressed_modifiers & NSControlKeyMask ) 
     647        val.i_int |= KEY_MODIFIER_CTRL; 
     648    if( i_pressed_modifiers & NSAlternateKeyMask ) 
     649        val.i_int |= KEY_MODIFIER_ALT; 
     650    if( i_pressed_modifiers & NSCommandKeyMask ) 
     651        val.i_int |= KEY_MODIFIER_COMMAND; 
     652 
     653    key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0]; 
     654 
     655    val.i_int |= CocoaKeyToVLC( key ); 
     656 
     657    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) 
     658    { 
     659        if( p_hotkeys[i].i_key == val.i_int ) 
     660        { 
     661            var_Set( VLCIntf->p_vlc, "key-pressed", val ); 
     662            return YES; 
     663        } 
     664    } 
     665 
     666    return NO; 
     667} 
    671668 
    672669- (id)getControls 
     
    700697{ 
    701698    NSDate * o_sleep_date; 
    702     intf_thread_t * p_intf = [NSApp getIntf]; 
    703699    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; 
    704700 
     
    770766- (void)manageIntf:(NSTimer *)o_timer 
    771767{ 
    772     intf_thread_t * p_intf = [NSApp getIntf]; 
    773  
    774768    if( p_intf->p_vlc->b_die == VLC_TRUE ) 
    775769    { 
     
    951945- (void)setupMenus 
    952946{ 
    953     intf_thread_t * p_intf = [NSApp getIntf]; 
    954947    playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,  
    955948                                                FIND_ANYWHERE ); 
     
    10141007{ 
    10151008    int i_start, i_stop; 
    1016     intf_thread_t * p_intf = [NSApp getIntf]; 
    10171009    vlc_value_t quiet; 
    10181010 
     
    11321124{ 
    11331125    audio_volume_t i_volume; 
    1134     intf_thread_t * p_intf = [NSApp getIntf]; 
    11351126 
    11361127    aout_VolumeGet( p_intf, &i_volume ); 
     
    11601151    } 
    11611152 
    1162     p_intf = [NSApp getIntf]; 
    11631153    p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, 
    11641154                                            FIND_ANYWHERE ); 
     
    11951185- (void)terminate 
    11961186{ 
    1197     NSEvent * o_event; 
    11981187    playlist_t * p_playlist; 
    11991188    vout_thread_t * p_vout; 
    1200     intf_thread_t * p_intf = [NSApp getIntf]; 
    12011189 
    12021190    /* Stop playback */ 
     
    12581246    } 
    12591247 
    1260     [NSApp stop: nil]; 
    1261     [NSApp terminate: nil]; 
    1262  
    12631248    /* write cached user defaults to disk */ 
    12641249    [[NSUserDefaults standardUserDefaults] synchronize]; 
    1265  
    1266     /* send a dummy event to break out of the event loop */ 
    1267     o_event = [NSEvent mouseEventWithType: NSLeftMouseDown 
    1268                 location: NSMakePoint( 1, 1 ) modifierFlags: 0 
    1269                 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber] 
    1270                 context: [NSGraphicsContext currentContext] eventNumber: 1 
    1271                 clickCount: 1 pressure: 0.0]; 
    1272     [NSApp postEvent: o_event atStart: YES]; 
     1250     
     1251    p_intf->b_die = VLC_TRUE; 
     1252    [NSApp stop:NULL]; 
    12731253} 
    12741254 
     
    12921272{ 
    12931273    vlc_value_t val; 
    1294     intf_thread_t * p_intf = [NSApp getIntf]; 
    1295      
     1274 
    12961275    if( [o_err_ckbk_surpress state] == NSOnState ) 
    12971276    { 
  • modules/gui/macosx/misc.m

    rae157fb rbf680e8  
    4545- (BOOL)performKeyEquivalent:(NSEvent *)o_event 
    4646{ 
    47     return [( (VLCApplication *) [VLCApplication sharedApplication] ) 
    48             hasDefinedShortcutKey:o_event]; 
     47    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event]; 
    4948} 
    5049 
     
    111110                o_array = [o_array arrayByAddingObject: o_dic]; 
    112111            } 
    113             [(VLCPlaylist *)[[NSApp delegate] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO]; 
     112            [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO]; 
    114113            return YES; 
    115114        } 
     
    189188                o_array = [o_array arrayByAddingObject: o_dic]; 
    190189            } 
    191             [(VLCPlaylist *)[[NSApp delegate] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO]; 
     190            [[[VLCMain sharedInstance] getPlaylist] appendArray: o_array atPos: -1 enqueue:NO]; 
    192191            return YES; 
    193192        } 
  • modules/gui/macosx/open.m

    r136957e rbf680e8  
    131131- (void)awakeFromNib 
    132132{ 
    133     intf_thread_t * p_intf = [NSApp getIntf]
     133    intf_thread_t * p_intf = VLCIntf
    134134 
    135135    [o_panel setTitle: _NS("Open Source")]; 
     
    574574    NSString *o_mode; 
    575575    NSString *o_mrl_string = [NSString string]; 
    576     intf_thread_t * p_intf = [NSApp getIntf]
     576    intf_thread_t * p_intf = VLCIntf
    577577 
    578578    o_mode = [[o_net_mode selectedCell] title]; 
  • modules/gui/macosx/output.m

    rd6d2450 rbf680e8  
    398398- (void)TTLChanged:(NSNotification *)o_notification 
    399399{ 
    400     intf_thread_t * p_intf = [NSApp getIntf]
     400    intf_thread_t * p_intf = VLCIntf
    401401    config_PutInt( p_intf, "ttl", [o_stream_ttl intValue] ); 
    402402} 
  • modules/gui/macosx/playlist.m

    r11e8ae9 rbf680e8  
    5757 
    5858    playlist_t * p_playlist; 
    59     intf_thread_t * p_intf = [NSApp getIntf]
     59    intf_thread_t * p_intf = VLCIntf
    6060 
    6161    if( [[o_event characters] length] ) 
     
    192192                  didClickTableColumn:(NSTableColumn *)o_tc 
    193193{ 
    194     intf_thread_t * p_intf = [NSApp getIntf]
     194    intf_thread_t * p_intf = VLCIntf
    195195    playlist_t *p_playlist = 
    196196        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     
    265265- (NSMenu *)menuForEvent:(NSEvent *)o_event 
    266266{ 
    267     intf_thread_t * p_intf = [NSApp getIntf]
     267    intf_thread_t * p_intf = VLCIntf
    268268    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    269269                                            FIND_ANYWHERE ); 
     
    317317- (IBAction)savePlaylist:(id)sender 
    318318{ 
    319     intf_thread_t * p_intf = [NSApp getIntf]
     319    intf_thread_t * p_intf = VLCIntf
    320320    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    321321                                                       FIND_ANYWHERE ); 
     
    336336- (IBAction)playItem:(id)sender 
    337337{ 
    338     intf_thread_t * p_intf = [NSApp getIntf]
     338    intf_thread_t * p_intf = VLCIntf
    339339    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    340340                                                       FIND_ANYWHERE ); 
     
    353353    NSNumber *o_number; 
    354354 
    355     intf_thread_t * p_intf = [NSApp getIntf]
     355    intf_thread_t * p_intf = VLCIntf
    356356    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    357357                                                       FIND_ANYWHERE ); 
     
    393393    NSNumber *o_number; 
    394394 
    395     intf_thread_t * p_intf = [NSApp getIntf]
     395    intf_thread_t * p_intf = VLCIntf
    396396    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    397397                                                       FIND_ANYWHERE ); 
     
    435435- (IBAction)enableGroup:(id)sender 
    436436{ 
    437     intf_thread_t * p_intf = [NSApp getIntf]
     437    intf_thread_t * p_intf = VLCIntf
    438438    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    439439                                                       FIND_ANYWHERE ); 
     
    449449- (IBAction)disableGroup:(id)sender 
    450450{ 
    451     intf_thread_t * p_intf = [NSApp getIntf]
     451    intf_thread_t * p_intf = VLCIntf
    452452    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    453453                                                       FIND_ANYWHERE ); 
     
    473473    NSString *o_current_author; 
    474474 
    475     intf_thread_t * p_intf = [NSApp getIntf]
     475    intf_thread_t * p_intf = VLCIntf
    476476    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    477477                                               FIND_ANYWHERE ); 
     
    529529 
    530530{ 
    531              intf_thread_t * p_intf = [NSApp getIntf]
     531             intf_thread_t * p_intf = VLCIntf
    532532             vlc_value_t val1,val2; 
    533533             playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     
    577577{ 
    578