Used Xcode's "Convert to Modern Objective-C syntax"
This commit is contained in:
parent
566470bb29
commit
d861a1abec
|
@ -43,6 +43,6 @@
|
||||||
@property (nonatomic, strong, readonly) NSUserDefaults *userDefaults;
|
@property (nonatomic, strong, readonly) NSUserDefaults *userDefaults;
|
||||||
|
|
||||||
+ (instancetype)sharedInstance;
|
+ (instancetype)sharedInstance;
|
||||||
- (instancetype)initWithSuiteName:(NSString *)suiteName;
|
- (instancetype)initWithSuiteName:(NSString *)suiteName NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -41,6 +41,6 @@ enum
|
||||||
- (BOOL) shouldFileBeReplaced:(NSString *) filename;
|
- (BOOL) shouldFileBeReplaced:(NSString *) filename;
|
||||||
- (void) alertUserOfMissing:(const char *) volume;
|
- (void) alertUserOfMissing:(const char *) volume;
|
||||||
- (void) hideDockIcon: (BOOL) hide;
|
- (void) hideDockIcon: (BOOL) hide;
|
||||||
- (NSString *) requestArchivePassword;
|
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *requestArchivePassword;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -139,7 +139,7 @@ BOOL appRunning = NO;
|
||||||
|
|
||||||
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
||||||
//no use, if app is already running when I try and openfile it is my apps bundle id
|
//no use, if app is already running when I try and openfile it is my apps bundle id
|
||||||
NSLog(@"%@", [[NSWorkspace sharedWorkspace] frontmostApplication].bundleIdentifier);
|
NSLog(@"%@", [NSWorkspace sharedWorkspace].frontmostApplication.bundleIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename {
|
- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename {
|
||||||
|
@ -168,10 +168,10 @@ BOOL appRunning = NO;
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert addButtonWithTitle:@"Overwrite"];
|
[alert addButtonWithTitle:@"Overwrite"];
|
||||||
NSButton * skipButton = [alert addButtonWithTitle:@"Skip"];
|
NSButton * skipButton = [alert addButtonWithTitle:@"Skip"];
|
||||||
[skipButton setKeyEquivalent:@"\e"];
|
skipButton.keyEquivalent = @"\e";
|
||||||
[alert setMessageText:[NSString stringWithFormat:@"Overwrite %@?", filename]];
|
alert.messageText = [NSString stringWithFormat:@"Overwrite %@?", filename];
|
||||||
[alert setInformativeText:[NSString stringWithFormat:@"The file %@ already exists. Do you wish to extract it again, overwriting the original file?", filename]];
|
alert.informativeText = [NSString stringWithFormat:@"The file %@ already exists. Do you wish to extract it again, overwriting the original file?", filename];
|
||||||
[alert setAlertStyle:NSAlertStyleWarning];
|
alert.alertStyle = NSAlertStyleWarning;
|
||||||
|
|
||||||
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
||||||
result = YES;
|
result = YES;
|
||||||
|
@ -185,9 +185,9 @@ BOOL appRunning = NO;
|
||||||
- (void) alertUserOfMissing:(const char *) volume {
|
- (void) alertUserOfMissing:(const char *) volume {
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert addButtonWithTitle:@"OK"];
|
[alert addButtonWithTitle:@"OK"];
|
||||||
[alert setMessageText:[NSString stringWithFormat:@"Archive part %s is missing.", volume]];
|
alert.messageText = [NSString stringWithFormat:@"Archive part %s is missing.", volume];
|
||||||
[alert setInformativeText:@"Unable to extract all files from RAR archive as part of it is missing"];
|
alert.informativeText = @"Unable to extract all files from RAR archive as part of it is missing";
|
||||||
[alert setAlertStyle:NSAlertStyleCritical];
|
alert.alertStyle = NSAlertStyleCritical;
|
||||||
|
|
||||||
[alert runModal];
|
[alert runModal];
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ BOOL appRunning = NO;
|
||||||
|
|
||||||
[bundle loadNibNamed:@"PasswordView" owner:self topLevelObjects: nil];
|
[bundle loadNibNamed:@"PasswordView" owner:self topLevelObjects: nil];
|
||||||
} else {
|
} else {
|
||||||
[passwordField setStringValue:@""];
|
passwordField.stringValue = @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString * password = nil;
|
NSString * password = nil;
|
||||||
|
@ -210,13 +210,13 @@ BOOL appRunning = NO;
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert addButtonWithTitle:@"OK"];
|
[alert addButtonWithTitle:@"OK"];
|
||||||
[alert addButtonWithTitle:@"Cancel"];
|
[alert addButtonWithTitle:@"Cancel"];
|
||||||
[alert setMessageText:@"Archive Requires a password"];
|
alert.messageText = @"Archive Requires a password";
|
||||||
[alert setInformativeText:@"To extract the contents of this archive a password is required."];
|
alert.informativeText = @"To extract the contents of this archive a password is required.";
|
||||||
[alert setAccessoryView:passwordView];
|
alert.accessoryView = passwordView;
|
||||||
[alert setAlertStyle:NSAlertStyleWarning];
|
alert.alertStyle = NSAlertStyleWarning;
|
||||||
|
|
||||||
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
||||||
password = [passwordField stringValue];
|
password = passwordField.stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return password;
|
return password;
|
||||||
|
@ -241,7 +241,7 @@ BOOL appRunning = NO;
|
||||||
if (show) {
|
if (show) {
|
||||||
statusBarItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
|
statusBarItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
|
||||||
statusBarItem.button.title = @"🎫"; //RMCG change to something more appropriate
|
statusBarItem.button.title = @"🎫"; //RMCG change to something more appropriate
|
||||||
[statusBarItem setMenu:[self makeStatusBarMenu]];
|
statusBarItem.menu = [self makeStatusBarMenu];
|
||||||
} else {
|
} else {
|
||||||
[NSStatusBar.systemStatusBar removeStatusItem:statusBarItem];
|
[NSStatusBar.systemStatusBar removeStatusItem:statusBarItem];
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ BOOL appRunning = NO;
|
||||||
|
|
||||||
- (NSMenu *) makeStatusBarMenu {
|
- (NSMenu *) makeStatusBarMenu {
|
||||||
NSMenu * statusBarMenu = [[NSMenu alloc] init];
|
NSMenu * statusBarMenu = [[NSMenu alloc] init];
|
||||||
[statusBarMenu setTitle:@"QuietUnarchiver Menu"];
|
statusBarMenu.title = @"QuietUnarchiver Menu";
|
||||||
|
|
||||||
NSMenuItem * preferencesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Show Preferences" action:@selector(showPreferencesWindow) keyEquivalent:@""];
|
NSMenuItem * preferencesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Show Preferences" action:@selector(showPreferencesWindow) keyEquivalent:@""];
|
||||||
[statusBarMenu addItem:preferencesMenuItem];
|
[statusBarMenu addItem:preferencesMenuItem];
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
@synthesize userDefaults, showNotificationsSwitch, playSoundSwitch, hideDockIconSwitch;
|
@synthesize userDefaults, showNotificationsSwitch, playSoundSwitch, hideDockIconSwitch;
|
||||||
@synthesize quietUnrar;
|
@synthesize quietUnrar;
|
||||||
|
|
||||||
- (id) init {
|
- (instancetype) init {
|
||||||
return [super initWithWindowNibName:@"PreferencesWindow"];
|
return [super initWithWindowNibName:@"PreferencesWindow"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,31 +34,31 @@
|
||||||
userDefaults = [TDNUserDefaults sharedInstance];
|
userDefaults = [TDNUserDefaults sharedInstance];
|
||||||
|
|
||||||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||||
[self.window setTitle:@"QuietUnarchiver Preferences"];
|
(self.window).title = @"QuietUnarchiver Preferences";
|
||||||
|
|
||||||
if (userDefaults.hideDock) {
|
if (userDefaults.hideDock) {
|
||||||
[hideDockIconSwitch setState:NSControlStateValueOn];
|
hideDockIconSwitch.state = NSControlStateValueOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userDefaults.showNotification) {
|
if (userDefaults.showNotification) {
|
||||||
[showNotificationsSwitch setState:NSControlStateValueOn];
|
showNotificationsSwitch.state = NSControlStateValueOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userDefaults.playSounds) {
|
if (userDefaults.playSounds) {
|
||||||
[playSoundSwitch setState:NSControlStateValueOn];
|
playSoundSwitch.state = NSControlStateValueOn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)showNotificationsSwitchToggled:(id)sender {
|
- (IBAction)showNotificationsSwitchToggled:(id)sender {
|
||||||
userDefaults.showNotification = [showNotificationsSwitch state];
|
userDefaults.showNotification = showNotificationsSwitch.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)playSoundSwitchToggled:(id)sender {
|
- (IBAction)playSoundSwitchToggled:(id)sender {
|
||||||
userDefaults.playSounds = [playSoundSwitch state];
|
userDefaults.playSounds = playSoundSwitch.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)hideDockIconSwitchToggled:(id)sender {
|
- (IBAction)hideDockIconSwitchToggled:(id)sender {
|
||||||
userDefaults.hideDock = [hideDockIconSwitch state];
|
userDefaults.hideDock = hideDockIconSwitch.state;
|
||||||
[quietUnrar hideDockIcon: userDefaults.hideDock];
|
[quietUnrar hideDockIcon: userDefaults.hideDock];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ int CALLBACK generalCallbackFunction(UINT message, LPARAM userData, LPARAM param
|
||||||
|
|
||||||
//Determine the folder we should extract the archive to. This by default
|
//Determine the folder we should extract the archive to. This by default
|
||||||
//is the <folderContainingTheArchive>/<archiveNameWithPathExtension>
|
//is the <folderContainingTheArchive>/<archiveNameWithPathExtension>
|
||||||
NSString * folderToExtractTo = [filename stringByDeletingPathExtension];
|
NSString * folderToExtractTo = filename.stringByDeletingPathExtension;
|
||||||
|
|
||||||
// Open the Archive for extraction, we set the open result to 3 so we can see it has changed
|
// Open the Archive for extraction, we set the open result to 3 so we can see it has changed
|
||||||
char * filenameCString = (char *)[filename cStringUsingEncoding:NSISOLatin1StringEncoding];
|
char * filenameCString = (char *)[filename cStringUsingEncoding:NSISOLatin1StringEncoding];
|
||||||
|
@ -202,7 +202,7 @@ int CALLBACK generalCallbackFunction(UINT message, LPARAM userData, LPARAM param
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString * folderToExtractTo = [filename stringByDeletingPathExtension];
|
NSString * folderToExtractTo = filename.stringByDeletingPathExtension;
|
||||||
|
|
||||||
BOOL extractFilesSuccessful = [archive extractFilesTo: folderToExtractTo
|
BOOL extractFilesSuccessful = [archive extractFilesTo: folderToExtractTo
|
||||||
overwrite:NO
|
overwrite:NO
|
||||||
|
|
Loading…
Reference in New Issue