]> git.sesse.net Git - vlc/commitdiff
macosx: replaced various deprecated methods with their modern counterparts
authorFelix Paul Kühne <fkuehne@videolan.org>
Tue, 5 Apr 2011 23:36:49 +0000 (01:36 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Tue, 5 Apr 2011 23:37:22 +0000 (01:37 +0200)
No functional changes. Some more can't be replaced yet, as we still support 10.5

modules/gui/macosx/controls.m
modules/gui/macosx/intf.m
modules/gui/macosx/open.m
modules/gui/macosx/output.m
modules/gui/macosx/playlist.m
modules/gui/macosx/prefs_widgets.m
modules/gui/macosx/simple_prefs.m
modules/gui/macosx/wizard.m

index 9396667ca884209e8a5f3e662143eaec2f86669c..0cf50cee154c6a3fad206e813d0b971c6ac2cd08 100644 (file)
     [openPanel setCanChooseFiles: YES];
     [openPanel setCanChooseDirectories: NO];
     [openPanel setAllowsMultipleSelection: YES];
-    i_returnValue = [openPanel runModalForDirectory: [NSString stringWithUTF8String: path] file: nil types: [NSArray arrayWithObjects: @"cdg",@"@idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil", nil]];
+    [openPanel setAllowedFileTypes: [NSArray arrayWithObjects: @"cdg",@"@idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil", nil]];
+    [openPanel setDirectoryURL:[NSURL fileURLWithPath:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]]];
+    i_returnValue = [openPanel runModal];
     free( path );
 
     if( i_returnValue == NSOKButton )
         NSUInteger c = 0;
         if( !p_input ) return;
 
-        c = [[openPanel filenames] count];
+        c = [[openPanel URLs] count];
 
-        for (int i = 0; i < [[openPanel filenames] count] ; i++)
+        for (int i = 0; i < c ; i++)
         {
-            msg_Dbg( VLCIntf, "loading subs from %s", [[[openPanel filenames] objectAtIndex: i] UTF8String] );
-            if( input_AddSubtitle( p_input, [[[openPanel filenames] objectAtIndex: i] UTF8String], TRUE ) )
+            msg_Dbg( VLCIntf, "loading subs from %s", [[[[openPanel URLs] objectAtIndex: i] path] UTF8String] );
+            if( input_AddSubtitle( p_input, [[[[openPanel URLs] objectAtIndex: i] path] UTF8String], TRUE ) )
                 msg_Warn( VLCIntf, "unable to load subtitles from '%s'",
-                         [[[openPanel filenames] objectAtIndex: i] UTF8String] );
+                         [[[[openPanel URLs] objectAtIndex: i] path] UTF8String] );
         }
     }
 }
index 686ae73358895dbb67ae0eb2df6e7a322f12019b..a0e753b84fd303c7f5c6e1c87cbe31d34db0be5c 100644 (file)
@@ -66,8 +66,6 @@ static void Run ( intf_thread_t *p_intf );
 
 static void * ManageThread( void *user_data );
 
-static unsigned int VLCModifiersToCocoa( unsigned int i_key );
-
 static void updateProgressPanel (void *, const char *, float);
 static bool checkProgressPanel (void *);
 static void destroyProgressPanel (void *);
@@ -1405,7 +1403,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 
     if( [o_usedHotkeys indexOfObject: tempString] != NSNotFound || [o_usedHotkeys indexOfObject: tempStringPlus] != NSNotFound )
     {
-        var_Set( p_intf->p_libvlc, "key-pressed", val );
+        var_SetInteger( p_intf->p_libvlc, "key-pressed", val.i_int );
         return YES;
     }
 
@@ -2637,7 +2635,7 @@ end:
     [saveFolderPanel setCanChooseFiles: YES];
     [saveFolderPanel setCanSelectHiddenExtension: NO];
     [saveFolderPanel setCanCreateDirectories: YES];
-    [saveFolderPanel setRequiredFileType: @"rtfd"];
+    [saveFolderPanel setAllowedFileTypes: [NSArray arrayWithObject:@"rtfd"]];
     [saveFolderPanel beginSheetForDirectory:nil file: [NSString stringWithFormat: _NS("VLC Debug Log (%s).rtfd"), VERSION_MESSAGE] modalForWindow: o_msgs_panel modalDelegate:self didEndSelector:@selector(saveDebugLogAsRTF:returnCode:contextInfo:) contextInfo:nil];
 }
 
@@ -2646,7 +2644,7 @@ end:
     BOOL b_returned;
     if( returnCode == NSOKButton )
     {
-        b_returned = [o_messages writeRTFDToFile: [sheet filename] atomically: YES];
+        b_returned = [o_messages writeRTFDToFile: [[sheet URL] path] atomically: YES];
         if(! b_returned )
             msg_Warn( p_intf, "Error while saving the debug log" );
     }
index 030742625d8361700ca31708f51b12750bd3ae05..7cf84ddd4cd6db9e271b3beb3cab3f306024c4b7 100644 (file)
@@ -508,11 +508,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
         o_open_panel = [NSOpenPanel openPanel];
         [o_open_panel setCanChooseFiles: YES];
         [o_open_panel setCanChooseDirectories: NO];
-        if( [o_open_panel runModalForDirectory: nil file: nil types: nil] == NSOKButton )
+        if( [o_open_panel runModal] == NSOKButton )
         {
             if( o_file_slave_path )
                 [o_file_slave_path release];
-            o_file_slave_path = [[o_open_panel filenames] objectAtIndex: 0];
+            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
             [o_file_slave_path retain];
         }
         else
@@ -602,7 +602,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     if (returnCode == NSFileHandlingPanelOKButton)
     {
-        NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
+        NSString *o_filename = [[[sheet URLs] objectAtIndex: 0] path];
         [o_file_path setStringValue: o_filename];
         [self openFilePathChanged: nil];
     }
@@ -778,10 +778,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
     [o_open_panel setPrompt: _NS("Open")];
 
-    if( [o_open_panel runModalForDirectory: nil
-            file: nil types: nil] == NSOKButton )
+    if( [o_open_panel runModal] == NSOKButton )
     {
-        NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
+        NSString *o_dirname = [[[o_open_panel URLs] objectAtIndex: 0] path];
         [o_disc_videots_folder setStringValue: o_dirname];
         [self openDiscInfoChanged: nil];
     }
@@ -953,17 +952,16 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_open_panel setTitle: _NS("Open File")];
     [o_open_panel setPrompt: _NS("Open")];
  
-    if( [o_open_panel runModalForDirectory: nil
-            file: nil types: nil] == NSOKButton )
+    if( [o_open_panel runModal] == NSOKButton )
     {
         NSArray *o_array = [NSArray array];
-        NSArray *o_values = [[o_open_panel filenames]
+        NSArray *o_values = [[o_open_panel URLs]
                 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
 
         for( i = 0; i < (int)[o_values count]; i++)
         {
             NSDictionary *o_dic;
-            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], "file");
+            char *psz_uri = make_URI([[[o_values objectAtIndex:i] path] UTF8String], "file");
             if( !psz_uri )
                 continue;
 
@@ -1196,10 +1194,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_open_panel setTitle: _NS("Open File")];
     [o_open_panel setPrompt: _NS("Open")];
 
-    if( [o_open_panel runModalForDirectory: nil
-            file: nil types: nil] == NSOKButton )
+    if( [o_open_panel runModal] == NSOKButton )
     {
-        NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
+        NSString *o_filename = [[[o_open_panel URLs] objectAtIndex: 0] path];
         [o_file_sub_path setStringValue: o_filename];
     }
 }
index 14ff97b768d3136a167695b04c08b2967d5afc90..51b2bcf2007f40158d5073d053004a2ed32afc45 100644 (file)
     if( [o_save_panel runModalForDirectory: nil
             file: o_name] == NSOKButton )
     {
-        NSString *o_filename = [o_save_panel filename];
+        NSString *o_filename = [[o_save_panel URL] path];
         [o_file_field setStringValue: o_filename];
         [self outputInfoChanged: nil];
     }
index 01197cf0f57ec0dad2606e80aac8a90446135446..6fe433829770bb963f6255b4e13d418cfabd8dbe 100644 (file)
     if( [o_save_panel runModalForDirectory: nil
             file: o_name] == NSOKButton )
     {
-        NSString *o_filename = [o_save_panel filename];
+        NSString *o_filename = [[o_save_panel URL] path];
 
         if( [o_save_accessory_popup indexOfSelectedItem] == 0 )
         {
index 186adf154d3987204d2b464caf6a64cc1e84111a..b0ef90ae904c3010f82d493b8cb2bd173d013bca 100644 (file)
@@ -1255,7 +1255,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
 {
     if( i_return_code == NSOKButton )
     {
-        NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
+        NSString *o_path = [[[o_sheet URLs] objectAtIndex: 0] path];
         [o_textfield setStringValue: o_path];
     }
 }
index 10cc5b22139079aea36e25662edd67400c002afd..912188d548bbd091d36527a1cdec56a64d2edb38 100644 (file)
@@ -1145,7 +1145,7 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
     {
         if( contextInfo == o_video_snap_folder_btn )
         {
-            [o_video_snap_folder_fld setStringValue: [o_selectFolderPanel filename]];
+            [o_video_snap_folder_fld setStringValue: [[o_selectFolderPanel URL] path]];
             b_videoSettingChanged = YES;
         }
     }
index 3c40a070e1a7f16d1794f97fcf5a5901de48cbfe..7f746bfdb3b20437d4936371f385a8b1490843b1 100644 (file)
@@ -1150,9 +1150,9 @@ static VLCWizard *_o_sharedInstance = nil;
                     /* check whether the extension is hidden or not.
                      * if not, remove it
                      * we need the casting to make GCC4 happy */
-                    if( [[[NSFileManager defaultManager] fileAttributesAtPath:
+                    if( [[[NSFileManager defaultManager] attributesOfItemAtPath:
                         [[o_userSelections objectForKey:@"pathToStrm"]
-                        objectAtIndex: x] traverseLink: NO] objectForKey:
+                         objectAtIndex: x] error:nil] objectForKey:
                         NSFileExtensionHidden] )
                         fileNameToUse = [NSString stringWithString:
                             [[NSFileManager defaultManager] displayNameAtPath:
@@ -1679,8 +1679,7 @@ static VLCWizard *_o_sharedInstance = nil;
 {
     if (returnCode == NSOKButton)
     {
-        [o_t2_fld_pathToNewStrm setStringValue: [@"file://"
-            stringByAppendingString: [sheet filename]]];
+        [o_t2_fld_pathToNewStrm setStringValue: [[sheet URL] absoluteString]];
     }
 }
 
@@ -1898,9 +1897,9 @@ static VLCWizard *_o_sharedInstance = nil;
         [[o_userSelections objectForKey:@"encapFormat"] intValue]]
         objectAtIndex:0];
         if( theEncapFormat != @"ps" )
-            [saveFilePanel setRequiredFileType: theEncapFormat];
+            [saveFilePanel setAllowedFileTypes: [NSArray arrayWithObject:theEncapFormat]];
         else
-            [saveFilePanel setRequiredFileType: @"mpg"];
+            [saveFilePanel setAllowedFileTypes: [NSArray arrayWithObject:@"mpg"]];
 
         [saveFilePanel setCanSelectHiddenExtension: YES];
         [saveFilePanel setCanCreateDirectories: YES];
@@ -1918,9 +1917,9 @@ static VLCWizard *_o_sharedInstance = nil;
          * selected a folder */
         if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
             [o_t7_fld_filePath setStringValue: [NSString stringWithFormat:
-                @"%@/", [sheet filename]]];
+                @"%@/", [[sheet URL] path]]];
         else
-            [o_t7_fld_filePath setStringValue:[sheet filename]];
+            [o_t7_fld_filePath setStringValue:[[sheet URL] path]];
     }
     [sheet release];
 }