Created
September 25, 2011 00:23
-
-
Save vade/1240039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)filemenu_addToLibrary:(id)sender{ | |
NSOpenPanel* openPanel = [NSOpenPanel openPanel]; | |
[openPanel setAllowsMultipleSelection:YES]; | |
[openPanel setCanChooseFiles:YES]; | |
[openPanel setCanCreateDirectories:NO]; | |
[openPanel setCanChooseDirectories:YES]; | |
NSInteger result = [openPanel runModal]; | |
if(result != NSOKButton){ | |
return; | |
} | |
double max = [[openPanel URLs] count]; | |
[importProgress setMaxValue:max]; | |
[[NSApplication sharedApplication] beginSheet:importSheet | |
modalForWindow:libraryWindow | |
modalDelegate:self | |
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) | |
contextInfo:nil]; | |
for(NSURL* aURL in [openPanel URLs]) | |
{ | |
NSString* aPath = [aURL path]; | |
[aPath retain]; | |
DLog(@"importing: %@", aPath); | |
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
[self.database addGamesFromPath:aPath toCollection:nil searchSubfolders:YES]; | |
}); | |
[importCurrentItem setStringValue:aPath]; | |
[importProgress incrementBy:1.0]; | |
[importSheet display]; | |
[aPath release]; | |
} | |
DLog(@"Finished Importing"); | |
} | |
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo | |
{ | |
[importSheet close]; | |
NSLog(@"Finished Importing"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment