Audit more code.
This commit is contained in:
1 parent
8c3802ae53
commit
221c2748ba
23 files changed
+190
-96
No files matched your search
@@ -166,8 +166,9 @@
|
||||
NSError *outError = nil;
|
||||
NSData *r = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:&outError];
|
||||
|
||||
if (r)
|
||||
if (r) {
|
||||
[r writeToFile:filename atomically:NO];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#import <MP42Foundation/MP42File.h>
|
||||
#import <MP42Foundation/MP42ChapterTrack.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SBTableView;
|
||||
|
||||
@interface SBChapterViewController : NSViewController {
|
||||
@@ -27,3 +29,5 @@
|
||||
- (IBAction) renameChapters: (id) sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -13,12 +13,14 @@
|
||||
|
||||
@implementation SBChapterViewController
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
NSMutableParagraphStyle * ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
[ps setHeadIndent: -10.0];
|
||||
[ps setAlignment:NSRightTextAlignment];
|
||||
|
||||
|
||||
detailBoldAttr = [[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSFont boldSystemFontOfSize:11.0], NSFontAttributeName,
|
||||
ps, NSParagraphStyleAttributeName,
|
||||
@@ -47,12 +49,15 @@
|
||||
objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
MP42TextSample * chapter = [track chapterAtIndex:rowIndex];
|
||||
if ([tableColumn.identifier isEqualToString:@"time"])
|
||||
return [self boldString:StringFromTime(chapter.timestamp, 1000)];
|
||||
MP42TextSample *chapter = [track chapterAtIndex:rowIndex];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"title"])
|
||||
if ([tableColumn.identifier isEqualToString:@"time"]) {
|
||||
return [self boldString:StringFromTime(chapter.timestamp, 1000)];
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"title"]) {
|
||||
return chapter.title;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
@@ -84,10 +89,12 @@
|
||||
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
if ([chapterTableView selectedRow] != -1)
|
||||
if ([chapterTableView selectedRow] != -1) {
|
||||
[removeChapter setEnabled:YES];
|
||||
else
|
||||
}
|
||||
else {
|
||||
[removeChapter setEnabled:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)removeChapter:(id)sender {
|
||||
@@ -96,7 +103,7 @@
|
||||
[track removeChapterAtIndex:current_index];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +111,7 @@
|
||||
[track addChapter:@"Chapter" duration:0];
|
||||
|
||||
[chapterTableView reloadData];
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
}
|
||||
|
||||
- (IBAction)renameChapters:(id)sender {
|
||||
@@ -120,8 +127,8 @@
|
||||
- (void)dealloc
|
||||
{
|
||||
[track release];
|
||||
|
||||
[detailBoldAttr release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,5 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface SBEmptyViewController : NSViewController {
|
||||
}
|
||||
|
||||
@interface SBEmptyViewController : NSViewController
|
||||
@end
|
||||
@@ -11,5 +11,4 @@
|
||||
|
||||
@implementation SBEmptyViewController
|
||||
|
||||
|
||||
@end
|
||||
@@ -9,6 +9,8 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Quartz/Quartz.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42File;
|
||||
@class MP42Metadata;
|
||||
@class SBTableView;
|
||||
@@ -36,9 +38,9 @@
|
||||
NSPopUpButtonCell *ratingCell;
|
||||
NSComboBoxCell *genreCell;
|
||||
|
||||
NSDictionary *tags;
|
||||
NSArray *_tagsArray;
|
||||
NSArray *tagsMenu;
|
||||
NSDictionary<NSString *, id> *tags;
|
||||
NSArray<NSString *> *_tagsArray;
|
||||
NSArray<NSString *> *tagsMenu;
|
||||
NSDictionary *detailBoldAttr;
|
||||
|
||||
NSMutableDictionary *dct;
|
||||
@@ -75,3 +77,5 @@
|
||||
- (IBAction) removeArtwork: (id) sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright 2009 Damiano Galassi. All rights reserved.
|
||||
//
|
||||
|
||||
NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
NSString *MetadataPBoardType = @"SublerMetadataPBoardType";
|
||||
|
||||
#import "SBMovieViewController.h"
|
||||
#import "SBTableView.h"
|
||||
@@ -20,7 +20,7 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
|
||||
@interface SBMovieViewController () <SBTableViewDelegate, SBImageBrowserViewDelegate>
|
||||
|
||||
@property (nonatomic, retain) NSArray *tagsArray;
|
||||
@property (nonatomic, retain) NSArray<NSString *> *tagsArray;
|
||||
|
||||
- (void) updateSetsMenu: (id)sender;
|
||||
|
||||
@@ -30,8 +30,10 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
|
||||
@synthesize tagsArray = _tagsArray;
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
[self updateSetsMenu:self];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
@@ -39,8 +41,9 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
name:@"SBPresetManagerUpdatedNotification" object:nil];
|
||||
|
||||
tagsMenu = [[metadata writableMetadata] retain];
|
||||
for (id tag in tagsMenu)
|
||||
for (id tag in tagsMenu) {
|
||||
[tagList addItemWithTitle:tag];
|
||||
}
|
||||
|
||||
ratingCell = [[NSPopUpButtonCell alloc] init];
|
||||
[ratingCell setAutoenablesItems:NO];
|
||||
@@ -105,7 +108,7 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
|
||||
- (void) updateTagsArray
|
||||
{
|
||||
NSArray *context = [metadata availableMetadata];
|
||||
NSArray<NSString *> *context = [metadata availableMetadata];
|
||||
self.tagsArray = [[tags allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
|
||||
NSInteger right = [context indexOfObject:obj2];
|
||||
NSInteger left = [context indexOfObject:obj1];
|
||||
@@ -215,8 +218,9 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
- (IBAction) addMetadataSet: (id)sender
|
||||
{
|
||||
NSArray *metadataKeys = nil;
|
||||
if ([sender tag] == 0)
|
||||
if ([sender tag] == 0) {
|
||||
metadataKeys = [self allSet];
|
||||
}
|
||||
else if ([sender tag] == 1) {
|
||||
metadataKeys = [self movieSet];
|
||||
metadata.mediaKind = 9;
|
||||
@@ -278,8 +282,9 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
SBPresetManager *presetManager = [SBPresetManager sharedManager];
|
||||
NSMenu * setListMenu = [setList menu];
|
||||
|
||||
while ([setListMenu numberOfItems] > 1)
|
||||
while ([setListMenu numberOfItems] > 1) {
|
||||
[setListMenu removeItemAtIndex: 1];
|
||||
}
|
||||
|
||||
NSMenuItem *newItem = [[[NSMenuItem alloc] initWithTitle:@"Save Set" action:@selector(showSaveSet:) keyEquivalent:@""] autorelease];
|
||||
[newItem setTarget:self];
|
||||
@@ -302,15 +307,16 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
[newItem setTag: 2];
|
||||
[setListMenu addItem:newItem];
|
||||
|
||||
if ([[presetManager presets] count])
|
||||
if (presetManager.presets.count) {
|
||||
[setListMenu addItem:[NSMenuItem separatorItem]];
|
||||
}
|
||||
|
||||
NSUInteger i = 0;
|
||||
|
||||
for (MP42Metadata *set in [presetManager presets]) {
|
||||
for (MP42Metadata *set in presetManager.presets) {
|
||||
newItem = [[NSMenuItem alloc] initWithTitle:[set presetName] action:@selector(applySet:) keyEquivalent:@""];
|
||||
if (i < 9)
|
||||
if (i < 9) {
|
||||
[newItem setKeyEquivalent:[NSString stringWithFormat:@"%lu", (unsigned long)i+1]];
|
||||
}
|
||||
|
||||
[newItem setTarget:self];
|
||||
[newItem setTag:i++];
|
||||
@@ -381,8 +387,7 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
current_index = [rowIndexes indexLessThanIndex: current_index];
|
||||
}
|
||||
|
||||
NSArray *types = [NSArray arrayWithObjects:
|
||||
MetadataPBoardType, NSStringPboardType, nil];
|
||||
NSArray *types = @[MetadataPBoardType, NSStringPboardType];
|
||||
[pb declareTypes:types owner:nil];
|
||||
[pb setString:string forType: NSStringPboardType];
|
||||
[pb setData:[NSArchiver archivedDataWithRootObject:data] forType:MetadataPBoardType];
|
||||
@@ -414,8 +419,9 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
NSArray *copiedItems = [pasteboard readObjectsForClasses:classes options:options];
|
||||
|
||||
if (copiedItems != nil) {
|
||||
for (id item in copiedItems)
|
||||
for (id item in copiedItems) {
|
||||
[self addArtwork:item];
|
||||
}
|
||||
|
||||
metadata.isArtworkEdited = YES;
|
||||
metadata.isEdited = YES;
|
||||
@@ -435,6 +441,7 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
{
|
||||
NSCell *cell = nil;
|
||||
NSString *tagName = nil;
|
||||
|
||||
if (tableColumn != nil)
|
||||
tagName = [self.tagsArray objectAtIndex:row];
|
||||
|
||||
@@ -448,11 +455,13 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
else if ([tagName isEqualToString:@"Genre"]) {
|
||||
cell = genreCell;
|
||||
}
|
||||
else
|
||||
else {
|
||||
cell = [tableColumn dataCell];
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
cell = nil;
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
@@ -461,11 +470,13 @@ NSString *MetadataPBoardType = @"MetadataPBoardType";
|
||||
objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)rowIndex
|
||||
{
|
||||
if ([tableColumn.identifier isEqualToString:@"name"])
|
||||
return [self.tagsArray objectAtIndex:rowIndex];
|
||||
if ([tableColumn.identifier isEqualToString:@"name"]) {
|
||||
return self.tagsArray[rowIndex];
|
||||
}
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"value"])
|
||||
return [tags objectForKey:[self.tagsArray objectAtIndex:rowIndex]];
|
||||
if ([tableColumn.identifier isEqualToString:@"value"]) {
|
||||
return tags[self.tagsArray[rowIndex]];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
@@ -498,13 +509,15 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
[dct setObject:@(height) forKey:key];
|
||||
}
|
||||
|
||||
if (height < 14.0)
|
||||
if (height < 14.0) {
|
||||
return 14.0;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) tableView: (NSTableView *) aTableView
|
||||
- (NSString *) tableView: (NSTableView *) aTableView
|
||||
toolTipForCell: (NSCell *) aCell
|
||||
rect: (NSRectPointer) rect
|
||||
tableColumn: (NSTableColumn *) aTableColumn
|
||||
@@ -568,8 +581,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
- (IBAction) changeGapless: (id) sender
|
||||
{
|
||||
uint8_t newValue;
|
||||
if (sender == gapless)
|
||||
if (sender == gapless) {
|
||||
newValue = (uint8_t)[gapless state];
|
||||
}
|
||||
else {
|
||||
newValue = ![gapless state];
|
||||
[gapless setState:newValue];
|
||||
@@ -642,8 +656,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
NSArray *objects = [metadata.artworks objectsAtIndexes:indexes];
|
||||
[metadata.artworks removeObjectsAtIndexes:indexes];
|
||||
|
||||
for (id object in [objects reverseObjectEnumerator])
|
||||
for (id object in objects.reverseObjectEnumerator) {
|
||||
[metadata.artworks insertObject:object atIndex:destinationIndex];
|
||||
}
|
||||
|
||||
metadata.isEdited = YES;
|
||||
metadata.isArtworkEdited = YES;
|
||||
@@ -655,7 +670,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
- (NSUInteger)imageBrowser:(IKImageBrowserView *) aBrowser writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
NSInteger index;
|
||||
[pasteboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
|
||||
[pasteboard declareTypes:@[NSTIFFPboardType] owner:nil];
|
||||
|
||||
for (index = [itemIndexes lastIndex]; index != NSNotFound; index = [itemIndexes indexLessThanIndex:index]) {
|
||||
NSArray *representations = [[[metadata.artworks objectAtIndex:index] image] representations];
|
||||
@@ -686,10 +701,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
{
|
||||
NSIndexSet *rowIndexes = [aBrowser selectionIndexes];
|
||||
|
||||
if ([rowIndexes count])
|
||||
if (rowIndexes.count) {
|
||||
[removeArtwork setEnabled:YES];
|
||||
else
|
||||
}
|
||||
else {
|
||||
[removeArtwork setEnabled:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)zoomSliderDidChange:(id)sender {
|
||||
@@ -740,17 +757,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
panel.allowsMultipleSelection = YES;
|
||||
panel.canChooseFiles = YES;
|
||||
panel.canChooseDirectories = NO;
|
||||
[panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.image"]];
|
||||
panel.allowedFileTypes = @[@"public.image"];
|
||||
|
||||
[panel beginSheetModalForWindow: [[self view] window] completionHandler:^(NSInteger result) {
|
||||
[panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) {
|
||||
if (result == NSFileHandlingPanelOKButton) {
|
||||
|
||||
for (NSURL *url in [panel URLs])
|
||||
|
||||
for (NSURL *url in panel.URLs) {
|
||||
[self addArtwork:url];
|
||||
}
|
||||
|
||||
metadata.isArtworkEdited = YES;
|
||||
metadata.isEdited = YES;
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[imageBrowser reloadData];
|
||||
}
|
||||
}];
|
||||
@@ -771,19 +789,19 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
BOOL edited = NO;
|
||||
NSPasteboard *pasteboard = [sender draggingPasteboard];
|
||||
|
||||
NSArray *classes = [NSArray arrayWithObjects:[NSURL class], [NSImage class], nil];
|
||||
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSImage imageTypes]
|
||||
forKey:NSPasteboardURLReadingContentsConformToTypesKey];
|
||||
NSArray *classes = @[[NSURL class], [NSImage class]];
|
||||
NSDictionary *options = @{NSPasteboardURLReadingContentsConformToTypesKey: [NSImage imageTypes]};
|
||||
NSArray *draggedItems = [pasteboard readObjectsForClasses:classes options:options];
|
||||
|
||||
if (draggedItems) {
|
||||
for (id dragItem in draggedItems)
|
||||
for (id dragItem in draggedItems) {
|
||||
edited = [self addArtwork:dragItem];
|
||||
}
|
||||
|
||||
if (edited) {
|
||||
metadata.isArtworkEdited = YES;
|
||||
metadata.isEdited = YES;
|
||||
[[[[[self view]window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[[[[[self view] window] windowController] document] updateChangeCount:NSChangeDone];
|
||||
[imageBrowser reloadData];
|
||||
|
||||
return YES;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42Track;
|
||||
@class MP42AudioTrack;
|
||||
@class MP42File;
|
||||
|
||||
@@ -15,8 +18,8 @@
|
||||
MP42AudioTrack *track;
|
||||
MP42File *mp4file;
|
||||
|
||||
NSMutableArray *_fallbacks;
|
||||
NSMutableArray *_follows;
|
||||
NSMutableArray<MP42AudioTrack *> *_fallbacks;
|
||||
NSMutableArray<__kindof MP42Track *> *_follows;
|
||||
|
||||
IBOutlet NSSlider *volume;
|
||||
IBOutlet NSPopUpButton *alternateGroup;
|
||||
@@ -33,3 +36,5 @@
|
||||
- (IBAction)setFollowsTrack:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -11,8 +11,10 @@
|
||||
|
||||
@implementation SBSoundViewController
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
[alternateGroup selectItemAtIndex:(NSInteger)track.alternate_group];
|
||||
|
||||
_fallbacks = [[NSMutableArray alloc] init];
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42File;
|
||||
@class MP42VideoTrack;
|
||||
@class MP42SubtitleTrack;
|
||||
@@ -60,3 +62,5 @@
|
||||
- (IBAction)setForcedTrack:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -56,8 +56,10 @@ static NSString *getLevelName(uint8_t level) {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
[sampleWidth setStringValue: [NSString stringWithFormat:@"%lld", track.width]];
|
||||
[sampleHeight setStringValue: [NSString stringWithFormat:@"%lld", track.height]];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SBArtworkSelectorDelegate <NSObject>
|
||||
- (void)selectArtworkDone:(NSURL *)url;
|
||||
- (void)selectArtworkDone:(NSIndexSet *)indexes;
|
||||
@end
|
||||
|
||||
@interface SBArtworkSelector : NSWindowController {
|
||||
|
||||
@@ -135,9 +135,10 @@
|
||||
|
||||
#pragma mark Load images
|
||||
|
||||
- (void)awakeFromNib {
|
||||
images = [[NSMutableArray alloc] initWithCapacity:[imageURLsUnloaded count]];
|
||||
for (int i = 0; (i < 10) && ([imageURLsUnloaded count] > 0); i++) {
|
||||
- (void)windowDidLoad {
|
||||
images = [[NSMutableArray alloc] initWithCapacity:imageURLsUnloaded.count];
|
||||
|
||||
for (NSUInteger i = 0; (i < 10) && (imageURLsUnloaded.count > 0); i++) {
|
||||
SBArtworkImageObject *m = [[SBArtworkImageObject alloc] initWithURL:[imageURLsUnloaded objectAtIndex:0]
|
||||
artworkProviderName:[artworkProviderNames objectAtIndex:[images count]]
|
||||
delegate:self];
|
||||
@@ -145,13 +146,14 @@
|
||||
[images addObject:m];
|
||||
[m release];
|
||||
}
|
||||
|
||||
[loadMoreArtworkButton setEnabled:([imageURLsUnloaded count] > 0)];
|
||||
[imageBrowser reloadData];
|
||||
[imageBrowser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
|
||||
}
|
||||
|
||||
- (IBAction) loadMoreArtwork:(id)sender {
|
||||
for (int i = 0; (i < 10) && ([imageURLsUnloaded count] > 0); i++) {
|
||||
for (NSUInteger i = 0; (i < 10) && (imageURLsUnloaded.count > 0); i++) {
|
||||
SBArtworkImageObject *m = [[SBArtworkImageObject alloc] initWithURL:[imageURLsUnloaded objectAtIndex:0]
|
||||
artworkProviderName:[artworkProviderNames objectAtIndex:[images count]]
|
||||
delegate:self];
|
||||
@@ -177,11 +179,11 @@
|
||||
#pragma mark Finishing up
|
||||
|
||||
- (IBAction) addArtwork:(id)sender {
|
||||
[delegate performSelector:@selector(selectArtworkDone:) withObject:[[[imageBrowser selectionIndexes] retain] autorelease]];
|
||||
[delegate selectArtworkDone:imageBrowser.selectionIndexes];
|
||||
}
|
||||
|
||||
- (IBAction) addNoArtwork:(id)sender {
|
||||
[delegate performSelector:@selector(selectArtworkDone:) withObject:nil];
|
||||
[delegate selectArtworkDone:[NSIndexSet indexSet]];
|
||||
}
|
||||
|
||||
- (void) dealloc {
|
||||
|
||||
+26
-18
@@ -697,8 +697,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
|
||||
- (IBAction)deleteTrack:(id)sender
|
||||
{
|
||||
if ([fileTracksTable selectedRow] == -1 || [fileTracksTable editedRow] != -1)
|
||||
if ([fileTracksTable selectedRow] == -1 || [fileTracksTable editedRow] != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.mp4 removeTrackAtIndex:[fileTracksTable selectedRow]];
|
||||
|
||||
@@ -738,25 +739,29 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
panel.allowsMultipleSelection = NO;
|
||||
panel.canChooseFiles = YES;
|
||||
panel.canChooseDirectories = NO;
|
||||
MP42ChapterTrack *chapters = [self.mp4 chapters];
|
||||
if (nil != chapters) {
|
||||
[panel setAllowedFileTypes:[supportedFileFormat() arrayByAddingObject:@"csv"]];
|
||||
|
||||
MP42ChapterTrack *chapters = self.mp4.chapters;
|
||||
if (chapters) {
|
||||
panel.allowedFileTypes = [supportedFileFormat() arrayByAddingObject:@"csv"];
|
||||
}
|
||||
else {
|
||||
[panel setAllowedFileTypes:supportedFileFormat()];
|
||||
panel.allowedFileTypes = supportedFileFormat();
|
||||
}
|
||||
|
||||
[panel beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger result) {
|
||||
if (result == NSFileHandlingPanelOKButton) {
|
||||
NSString *fileExtension = [[panel.URLs objectAtIndex: 0] pathExtension];
|
||||
NSString *fileExtension = panel.URLs.firstObject.pathExtension;
|
||||
|
||||
if ([fileExtension caseInsensitiveCompare: @"txt"] == NSOrderedSame)
|
||||
if ([fileExtension caseInsensitiveCompare: @"txt"] == NSOrderedSame) {
|
||||
[self addChapterTrack:[panel.URLs objectAtIndex: 0]];
|
||||
else if ([fileExtension caseInsensitiveCompare: @"csv"] == NSOrderedSame)
|
||||
[self updateChapters:chapters fromCSVFile:[panel.URLs objectAtIndex: 0]];
|
||||
else
|
||||
}
|
||||
else if ([fileExtension caseInsensitiveCompare: @"csv"] == NSOrderedSame) {
|
||||
[self updateChapters:chapters fromCSVFile:panel.URLs.firstObject];
|
||||
}
|
||||
else {
|
||||
[self performSelectorOnMainThread:@selector(showImportSheet:)
|
||||
withObject:panel.URLs waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
@@ -768,14 +773,16 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
importWindow = [[SBFileImport alloc] initWithURLs:fileURLs delegate:self error:&error];
|
||||
|
||||
if (importWindow) {
|
||||
if ([importWindow onlyContainsSubtitleTracks]) { //execute always. Maybe we should do this only for subtitle
|
||||
if ([importWindow onlyContainsSubtitleTracks]) {
|
||||
[importWindow addTracks:self];
|
||||
[self didEndSheet:nil returnCode:NSOKButton contextInfo:nil];
|
||||
} else { // show the dialog
|
||||
}
|
||||
else { // show the dialog
|
||||
[NSApp beginSheet:[importWindow window] modalForWindow:documentWindow
|
||||
modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:NULL];
|
||||
}
|
||||
} else if (error) {
|
||||
}
|
||||
else if (error) {
|
||||
[self presentError:error modalForWindow:documentWindow delegate:nil didPresentSelector:NULL contextInfo:nil];
|
||||
}
|
||||
}
|
||||
@@ -875,9 +882,8 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
|
||||
- (IBAction)addChaptersEvery:(id)sender
|
||||
{
|
||||
MP42ChapterTrack *chapterTrack = [self.mp4 chapters];
|
||||
MP42ChapterTrack *chapterTrack = self.mp4.chapters;
|
||||
NSInteger minutes = [sender tag] * 60 * 1000;
|
||||
NSInteger i, y = 1;
|
||||
|
||||
if (!chapterTrack) {
|
||||
chapterTrack = [[MP42ChapterTrack alloc] init];
|
||||
@@ -886,14 +892,16 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
[chapterTrack release];
|
||||
}
|
||||
|
||||
if (minutes)
|
||||
for (i = 0, y = 1; i < self.mp4.duration; i += minutes, y++) {
|
||||
if (minutes) {
|
||||
for (NSInteger i = 0, y = 1; i < self.mp4.duration; i += minutes, y++) {
|
||||
[chapterTrack addChapter:[NSString stringWithFormat:@"Chapter %ld", (long)y]
|
||||
duration:i];
|
||||
}
|
||||
else
|
||||
}
|
||||
else {
|
||||
[chapterTrack addChapter:@"Chapter 1"
|
||||
duration:self.mp4.duration];
|
||||
}
|
||||
|
||||
[fileTracksTable reloadData];
|
||||
[self reloadPropertyView];
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Quartz/Quartz.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SBImageBrowserViewDelegate
|
||||
@optional
|
||||
- (void)_pasteToImageBrowserView:(IKImageBrowserView *)ImageBrowserView;
|
||||
@@ -16,5 +18,7 @@
|
||||
@interface SBImageBrowserView : IKImageBrowserView {
|
||||
NSArray *_pasteboardTypes;
|
||||
}
|
||||
@property(nonatomic, readwrite, retain) NSArray *pasteboardTypes;
|
||||
@property(nonatomic, readwrite, retain) NSArray<NSString *> *pasteboardTypes;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -12,6 +12,24 @@
|
||||
|
||||
@synthesize pasteboardTypes = _pasteboardTypes;
|
||||
|
||||
- (instancetype)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_pasteboardTypes = @[];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
_pasteboardTypes = @[];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
id delegate = [self delegate];
|
||||
|
||||
@@ -87,7 +87,7 @@ static void *SBItemViewContex = &SBItemViewContex;
|
||||
[self.spinner setHidden:NO];
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(editItem:)]) {
|
||||
[self.delegate performSelector:@selector(editItem:) withObject:self.item];
|
||||
[self.delegate editItem:self.item];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
#pragma mark Load artwork
|
||||
|
||||
- (void) loadArtworks:(NSIndexSet *)indexes {
|
||||
if (indexes) {
|
||||
if (indexes.count) {
|
||||
[progress startAnimation:self];
|
||||
[progress setHidden:NO];
|
||||
[progressText setStringValue:@"Downloading artwork…"];
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"] autorelease];
|
||||
[toolbar setDelegate:self];
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SBTableViewDelegate
|
||||
@optional
|
||||
- (void)_deleteSelectionFromTableView:(NSTableView *)tableView;
|
||||
@@ -21,9 +23,11 @@
|
||||
@end
|
||||
|
||||
@interface SBTableView : NSTableView {
|
||||
NSArray *_pasteboardTypes;
|
||||
NSArray<NSString *> *_pasteboardTypes;
|
||||
NSInteger _defaultEditingColumn;
|
||||
}
|
||||
@property(nonatomic, readwrite, retain) NSArray *pasteboardTypes;
|
||||
@property(nonatomic, readwrite, retain) NSArray<NSString *> *pasteboardTypes;
|
||||
@property(nonatomic, readwrite) NSInteger defaultEditingColumn;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -14,6 +14,24 @@
|
||||
@synthesize defaultEditingColumn = _defaultEditingColumn;
|
||||
@synthesize pasteboardTypes = _pasteboardTypes;
|
||||
|
||||
- (instancetype)initWithFrame:(NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
_pasteboardTypes = @[];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (self) {
|
||||
_pasteboardTypes = @[];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{
|
||||
id delegate = [self delegate];
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface SBView : NSView {
|
||||
IBOutlet NSViewController *viewController;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#import "SBView.h"
|
||||
|
||||
|
||||
@implementation SBView
|
||||
|
||||
- (void)setViewController:(NSViewController *)newController
|
||||
|
||||
Reference in new issue
Block a user