diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-11 04:11:51 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-11 04:11:51 +0000 |
| commit | 5174e012aae4d340b373c2d7c5d028d6e849d9f8 (patch) | |
| tree | 56277e83cbce33072ed0dfe5ee7f3d3d8e32a3c0 /macosx/PcsxrPluginHandler.m | |
| parent | 287d77d5995567fcba738c97af558f36e51462ca (diff) | |
| download | pcsxr-5174e012aae4d340b373c2d7c5d028d6e849d9f8.tar.gz | |
Rewrote the file handling on Mac OS X.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@73141 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PcsxrPluginHandler.m')
| -rw-r--r-- | macosx/PcsxrPluginHandler.m | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/macosx/PcsxrPluginHandler.m b/macosx/PcsxrPluginHandler.m new file mode 100644 index 00000000..84919c56 --- /dev/null +++ b/macosx/PcsxrPluginHandler.m @@ -0,0 +1,80 @@ +// +// PcsxrPluginHandler.m +// Pcsxr +// +// Created by Charles Betts on 12/10/11. +// Copyright (c) 2011 __MyCompanyName__. All rights reserved. +// + +#import "PcsxrPluginHandler.h" + +@implementation PcsxrPluginHandler + +- (id)initWithWindow:(NSWindow *)window +{ + self = [super initWithWindow:window]; + if (self) { + // Initialization code here. + } + + return self; +} + +- (id)init +{ + if (self = [super initWithWindowNibName:@"AddPluginSheet"]) { + moveOK = NO; + } + return self; +} + +- (void)windowDidLoad +{ + [super windowDidLoad]; + + // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. +} + +- (IBAction)closeAddPluginSheet:(id)sender +{ + if ([[sender keyEquivalent] isEqualToString:@"\r"]) { + moveOK = YES; + } else { + moveOK = NO; + } + [NSApp stopModal]; +} + +- (BOOL)handleFile:(NSString *)theFile +{ + if (![self window]) + [NSBundle loadNibNamed:@"AddPluginSheet" owner:self]; + + [pluginName setObjectValue:[[NSURL fileURLWithPath:theFile] lastPathComponent]]; + + [NSApp runModalForWindow:[self window]]; + // Sheet is up here. + [NSApp endSheet:[self window]]; + [[self window] orderOut:self]; + if (moveOK == YES) { + NSFileWrapper *wrapper = [[NSFileWrapper alloc] initWithPath:theFile]; + NSString *dst = [NSString stringWithFormat:@"%@/%@", + [[NSBundle mainBundle] builtInPlugInsPath], + [wrapper filename]]; + if ([wrapper writeToFile:dst atomically:NO updateFilenames:NO]) { + [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[[NSBundle mainBundle] builtInPlugInsPath]]; + NSRunInformationalAlertPanel(NSLocalizedString(@"Installation Succesfull", nil), + NSLocalizedString(@"The installation of the specified plugin was succesfull. In order to use it, please restart the application.", nil), + nil, nil, nil); + } else { + NSRunAlertPanel(NSLocalizedString(@"Installation Failed!", nil), + NSLocalizedString(@"The installation of the specified plugin failed. Please try again, or make a manual install.", nil), + nil, nil, nil); + } + [wrapper release]; + } + return YES; +} + + +@end |
