This commit is contained in:
galad87 committed 2015-08-29 13:12:26 +02:00
1 parent bb241f46b1
commit ee94900e33
10 files changed
+54 -65

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSArray+Subscripting.h
// Subler // Subler
// //
+2 -5
View File
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSArray+Subscripting.m
// Subler // Subler
// //
@@ -11,9 +11,7 @@
+ (void)load + (void)load
{ {
Class class = [self class]; Class class = [self class];
SEL swizzledSelector = @selector(dg_objectAtIndexedSubscript:); SEL swizzledSelector = @selector(dg_objectAtIndexedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
class_addMethod([NSArray class], class_addMethod([NSArray class],
@@ -23,8 +21,7 @@
); );
} }
- (id)dg_objectAtIndexedSubscript:(NSInteger)index - (id)dg_objectAtIndexedSubscript:(NSInteger)index {
{
return [self objectAtIndex:index]; return [self objectAtIndex:index];
} }
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSDictionary+Subscript.h
// Subler // Subler
// //
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSDictionary+Subscript.m
// Subler // Subler
// //
@@ -8,10 +8,8 @@
@implementation NSDictionary (Subscript) @implementation NSDictionary (Subscript)
+ (void)load + (void)load {
{
Class class = [self class]; Class class = [self class];
SEL swizzledSelector = @selector(dg_objectForKeyedSubscript:); SEL swizzledSelector = @selector(dg_objectForKeyedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,8 +20,7 @@
); );
} }
-(id)dg_objectForKeyedSubscript:(id)key -(id)dg_objectForKeyedSubscript:(id)key {
{
return [self objectForKey:key]; return [self objectForKey:key];
} }
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSMutableArray+Subscript.h
// Subler // Subler
// //
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSMutableArray+Subscript.m
// Subler // Subler
// //
@@ -11,7 +11,6 @@
+ (void)load + (void)load
{ {
Class class = [self class]; Class class = [self class];
SEL swizzledSelector = @selector(dg_setObject:atIndexedSubscript:); SEL swizzledSelector = @selector(dg_setObject:atIndexedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,22 +21,17 @@
); );
} }
- (void)dg_setObject:(id)anObject atIndexedSubscript:(NSUInteger)index - (void)dg_setObject:(id)anObject atIndexedSubscript:(NSUInteger)index {
{ if (anObject == nil) {
if(anObject == nil)
{
[NSException raise:NSInvalidArgumentException format:@"setObject:atIndexedSubscript does not allow objects to be nil"]; [NSException raise:NSInvalidArgumentException format:@"setObject:atIndexedSubscript does not allow objects to be nil"];
} }
if(index > self.count) if (index > self.count) {
{
[NSException raise:NSRangeException format:@"setObject:atIndexedSubscript does not allow the index to be out of array bounds"]; [NSException raise:NSRangeException format:@"setObject:atIndexedSubscript does not allow the index to be out of array bounds"];
} }
if(index == self.count) if (index == self.count) {
{
[self addObject:anObject]; [self addObject:anObject];
} }
else else {
{
[self replaceObjectAtIndex:index withObject:anObject]; [self replaceObjectAtIndex:index withObject:anObject];
} }
} }
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSMutableDictionary+Subscript.h
// Subler // Subler
// //
@@ -1,5 +1,5 @@
// //
// SBLogger.m // NSMutableDictionary+Subscript.m
// Subler // Subler
// //
@@ -8,10 +8,8 @@
@implementation NSMutableDictionary (Subscript) @implementation NSMutableDictionary (Subscript)
+ (void)load + (void)load {
{
Class class = [self class]; Class class = [self class];
SEL swizzledSelector = @selector(dg_setObject:forKeyedSubscript:); SEL swizzledSelector = @selector(dg_setObject:forKeyedSubscript:);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
@@ -22,8 +20,7 @@
); );
} }
- (void)dg_setObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey - (void)dg_setObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey {
{
[self setObject:object forKey:aKey]; [self setObject:object forKey:aKey];
} }
+13 -13
View File
@@ -88,20 +88,21 @@
#ifdef DONATION #ifdef DONATION
BOOL firstLaunch = YES; BOOL firstLaunch = YES;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
firstLaunch = NO; firstLaunch = NO;
}
if (![[NSUserDefaults standardUserDefaults] valueForKey:@"WarningDonate"]) { if (![[NSUserDefaults standardUserDefaults] valueForKey:@"WarningDonate"]) {
NSDate * lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"DonateAskDate"]; NSDate *lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"DonateAskDate"];
const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME; const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME;
if (!firstLaunch && timePassed) { if (!firstLaunch && timePassed) {
[[NSUserDefaults standardUserDefaults] setValue:[NSDate date] forKey:@"DonateAskDate"]; [[NSUserDefaults standardUserDefaults] setValue:[NSDate date] forKey:@"DonateAskDate"];
NSAlert * alert = [[NSAlert alloc] init]; NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText: NSLocalizedString(@"Support Subler", "Donation -> title")]; [alert setMessageText: NSLocalizedString(@"Support Subler", "Donation -> title")];
NSString * donateMessage = [NSString stringWithFormat: @"%@", NSString *donateMessage = [NSString stringWithFormat: @"%@",
NSLocalizedString(@" A lot of time and effort have gone into development, coding, and refinement." NSLocalizedString(@" A lot of time and effort have gone into development, coding, and refinement."
" If you enjoy using it, please consider showing your appreciation with a donation.", "Donation -> message")]; " If you enjoy using it, please consider showing your appreciation with a donation.", "Donation -> message")];
@@ -114,22 +115,26 @@
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
[alert setShowsSuppressionButton:allowNeverAgain]; [alert setShowsSuppressionButton:allowNeverAgain];
if (allowNeverAgain) if (allowNeverAgain) {
[[alert suppressionButton] setTitle:NSLocalizedString(@"Don't ask me about this ever again.", "Donation -> button")]; [[alert suppressionButton] setTitle:NSLocalizedString(@"Don't ask me about this ever again.", "Donation -> button")];
}
const NSInteger donateResult = [alert runModal]; const NSInteger donateResult = [alert runModal];
if (donateResult == NSAlertFirstButtonReturn) if (donateResult == NSAlertFirstButtonReturn) {
[self linkDonate:self]; [self linkDonate:self];
}
if (allowNeverAgain) if (allowNeverAgain) {
[[NSUserDefaults standardUserDefaults] setBool:([[alert suppressionButton] state] != NSOnState) forKey:@"WarningDonate"]; [[NSUserDefaults standardUserDefaults] setBool:([[alert suppressionButton] state] != NSOnState) forKey:@"WarningDonate"];
}
[alert release]; [alert release];
} }
} }
if (firstLaunch) if (firstLaunch) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
}
#endif #endif
[SBQueueController sharedManager]; [SBQueueController sharedManager];
@@ -184,11 +189,6 @@
@implementation SBDocumentController @implementation SBDocumentController
- (instancetype)init
{
return [super init];
}
- (void)openDocumentWithContentsOfURL:(NSURL * _Nonnull)url - (void)openDocumentWithContentsOfURL:(NSURL * _Nonnull)url
display:(BOOL)displayDocument display:(BOOL)displayDocument
completionHandler:(void (^ _Nonnull)(NSDocument * _Nullable document, completionHandler:(void (^ _Nonnull)(NSDocument * _Nullable document,
+23 -19
View File
@@ -167,8 +167,8 @@
case NSSaveAsOperation: case NSSaveAsOperation:
// movie does not exist, create a new one from scratch. // movie does not exist, create a new one from scratch.
if ([_64bit_data state]) { attributes[MP4264BitData] = @YES; } if (_64bit_data.state) { attributes[MP4264BitData] = @YES; }
if ([_64bit_time state]) { attributes[MP4264BitTime] = @YES; } if (_64bit_time.state) { attributes[MP4264BitTime] = @YES; }
result = [self.mp4 writeToUrl:url withAttributes:attributes error:outError]; result = [self.mp4 writeToUrl:url withAttributes:attributes error:outError];
break; break;
@@ -597,18 +597,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
[self close]; [self close];
} else { } else {
NSSavePanel *panel = [NSSavePanel savePanel]; NSSavePanel *panel = [NSSavePanel savePanel];
[self prepareSavePanel:panel]; panel.prompt = NSLocalizedString(@"Send To Queue", nil);
[panel setPrompt:@"Send To Queue"]; [self prepareSavePanel:panel];
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) { [panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) { if (result == NSFileHandlingPanelOKButton) {
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
if ([_64bit_data state]) [attributes setObject:@YES forKey:MP4264BitData]; if (_64bit_data.state) { attributes[MP4264BitData] = @YES; }
if ([_64bit_time state]) [attributes setObject:@YES forKey:MP4264BitTime]; if (_64bit_time.state) { attributes[MP4264BitTime] = @YES; }
if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"chaptersPreviewTrack"] boolValue]) { if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"chaptersPreviewTrack"] boolValue]) {
[attributes setObject:@YES forKey:MP42GenerateChaptersPreviewTrack]; attributes[MP42GenerateChaptersPreviewTrack] = @YES;
} }
SBQueueItem *item = [SBQueueItem itemWithMP4:self.mp4 destinationURL:panel.URL attributes:attributes]; SBQueueItem *item = [SBQueueItem itemWithMP4:self.mp4 destinationURL:panel.URL attributes:attributes];
@@ -626,7 +626,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
NSString *filename = nil; NSString *filename = nil;
for (MP42Track *track in self.mp4.tracks) { for (MP42Track *track in self.mp4.tracks) {
if (track.sourceURL) { if (track.sourceURL) {
filename = [track.sourceURL lastPathComponent]; filename = track.sourceURL.lastPathComponent;
break; break;
} }
} }
@@ -801,7 +801,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
- (void)addMetadata:(NSURL *)URL - (void)addMetadata:(NSURL *)URL
{ {
if ([[URL pathExtension] isEqualToString:@"xml"] || [[URL pathExtension] isEqualToString:@"nfo"]) { if ([URL.pathExtension isEqualToString:@"xml"] || [URL.pathExtension isEqualToString:@"nfo"]) {
MP42Metadata *xmlMetadata = [[MP42Metadata alloc] initWithFileURL:URL]; MP42Metadata *xmlMetadata = [[MP42Metadata alloc] initWithFileURL:URL];
[self.mp4.metadata mergeMetadata:xmlMetadata]; [self.mp4.metadata mergeMetadata:xmlMetadata];
[xmlMetadata release]; [xmlMetadata release];
@@ -835,9 +835,13 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
- (IBAction)export:(id)sender - (IBAction)export:(id)sender
{ {
NSInteger row = [fileTracksTable selectedRow]; NSString *filename = self.fileURL.URLByDeletingPathExtension.lastPathComponent;
NSSavePanel * panel = [NSSavePanel savePanel];
NSString *filename = [[[[self fileURL] path] stringByDeletingPathExtension] lastPathComponent]; NSSavePanel *panel = [NSSavePanel savePanel];
panel.canSelectHiddenExtension = YES;
panel.nameFieldStringValue = filename;
NSInteger row = fileTracksTable.selectedRow;
if (row != -1 && [[self.mp4 trackAtIndex:row] isKindOfClass:[MP42SubtitleTrack class]]) { if (row != -1 && [[self.mp4 trackAtIndex:row] isKindOfClass:[MP42SubtitleTrack class]]) {
panel.allowedFileTypes = @[@"srt"]; panel.allowedFileTypes = @[@"srt"];
@@ -848,20 +852,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
panel.allowedFileTypes = @[@"txt"]; panel.allowedFileTypes = @[@"txt"];
} }
[panel setCanSelectHiddenExtension: YES];
[panel setNameFieldStringValue:filename];
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) { [panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) { if (result == NSFileHandlingPanelOKButton) {
id track = [self.mp4 trackAtIndex:[fileTracksTable selectedRow]];
if (![track exportToURL: [panel URL] error: nil]) { NSError *error;
NSAlert * alert = [[NSAlert alloc] init]; id track = [self.mp4 trackAtIndex:row];
if (![track exportToURL:panel.URL error:&error]) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Export alert panel -> button")]; [alert addButtonWithTitle: NSLocalizedString(@"OK", "Export alert panel -> button")];
[alert setMessageText: NSLocalizedString(@"File Could Not Be Saved", "Export alert panel -> title")]; [alert setMessageText: NSLocalizedString(@"File Could Not Be Saved", "Export alert panel -> title")];
[alert setInformativeText: [NSString stringWithFormat: [alert setInformativeText: [NSString stringWithFormat:
NSLocalizedString(@"There was a problem creating the file \"%@\".", NSLocalizedString(@"There was a problem creating the file \"%@\".",
"Export alert panel -> message"), [[[panel URL] path] lastPathComponent]]]; "Export alert panel -> message"), panel.URL.lastPathComponent]];
[alert setAlertStyle: NSWarningAlertStyle]; [alert setAlertStyle: NSWarningAlertStyle];
[alert runModal]; [alert runModal];