From 84ad50a43431ac44d2ede1e76daba19f81346490 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 24 Oct 2014 09:07:58 +0200 Subject: [PATCH] Added a log window to show the mp4v2 log messages. --- Classes/SBAppDelegate.h | 2 + Classes/SBAppDelegate.m | 14 ++++++ Classes/SBDebugLogController.h | 17 +++++++ Classes/SBDebugLogController.m | 44 ++++++++++++++++++ English.lproj/MainMenu.xib | 14 ++++-- English.lproj/SBDebugLogWindow.xib | 73 ++++++++++++++++++++++++++++++ Subler.xcodeproj/project.pbxproj | 18 ++++++++ 7 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 Classes/SBDebugLogController.h create mode 100644 Classes/SBDebugLogController.m create mode 100644 English.lproj/SBDebugLogWindow.xib diff --git a/Classes/SBAppDelegate.h b/Classes/SBAppDelegate.h index 451513f..42b89e1 100755 --- a/Classes/SBAppDelegate.h +++ b/Classes/SBAppDelegate.h @@ -9,6 +9,7 @@ #import @class SBPrefsController; +@class SBDebugLogController; @interface SBDocumentController : NSDocumentController @@ -16,6 +17,7 @@ @interface SBAppDelegate : NSObject { SBPrefsController *prefController; + SBDebugLogController *debugLogController; SBDocumentController *documentController; } diff --git a/Classes/SBAppDelegate.m b/Classes/SBAppDelegate.m index 534b739..7757abe 100755 --- a/Classes/SBAppDelegate.m +++ b/Classes/SBAppDelegate.m @@ -11,6 +11,9 @@ #import "SBPresetManager.h" #import "SBQueueController.h" #import "SBPrefsController.h" +#import "SBDebugLogController.h" + +#import #define DONATE_NAG_TIME (60 * 60 * 24 * 7) @@ -22,6 +25,12 @@ [SBPrefsController registerUserDefaults]; + debugLogController = [[SBDebugLogController alloc] init]; + + [MP42File redirectLogUsingBlock:^(NSString *text) { + [debugLogController log:text]; + }]; + if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBShowQueueWindow"]) [[SBQueueController sharedManager] showWindow:self]; } @@ -127,6 +136,11 @@ [prefController showWindow:self]; } +- (IBAction) showDebugLog:(id)sender +{ + [debugLogController showWindow:self]; +} + - (IBAction) donate:(id)sender { [self linkDonate:sender]; diff --git a/Classes/SBDebugLogController.h b/Classes/SBDebugLogController.h new file mode 100644 index 0000000..2f8d3ba --- /dev/null +++ b/Classes/SBDebugLogController.h @@ -0,0 +1,17 @@ +// +// SBDebugLogController.h +// Subler +// +// Created by Damiano Galassi on 24/10/14. +// +// + +#import + +@interface SBDebugLogController : NSWindowController { + NSTextView *logView; +} + +- (void)log:(NSString *)string; + +@end diff --git a/Classes/SBDebugLogController.m b/Classes/SBDebugLogController.m new file mode 100644 index 0000000..465d5d2 --- /dev/null +++ b/Classes/SBDebugLogController.m @@ -0,0 +1,44 @@ +// +// SBDebugLogController.m +// Subler +// +// Created by Damiano Galassi on 24/10/14. +// +// + +#import "SBDebugLogController.h" + +@interface SBDebugLogController () + +@property (assign) IBOutlet NSTextView *logView; + +@end + +@implementation SBDebugLogController +@synthesize logView; + +- (instancetype)init +{ + if ((self = [super initWithWindowNibName:@"SBDebugLogWindow"])) { + [self window]; + } + + return self; +} + + +- (void)windowDidLoad { + [super windowDidLoad]; +} + +- (void)log:(NSString *)string { + NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string]; + [[self.logView textStorage] appendAttributedString:attributedString]; + [attributedString release]; +} + +- (IBAction)clearLog:(id)sender { + [[self.logView textStorage] deleteCharactersInRange:NSMakeRange(0, [[self.logView textStorage] length])]; +} + +@end diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 7d97244..ab6bf27 100755 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - - + + @@ -11,7 +11,7 @@ - + @@ -438,6 +438,12 @@ + + + + + + diff --git a/English.lproj/SBDebugLogWindow.xib b/English.lproj/SBDebugLogWindow.xib new file mode 100644 index 0000000..028d504 --- /dev/null +++ b/English.lproj/SBDebugLogWindow.xib @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Subler.xcodeproj/project.pbxproj b/Subler.xcodeproj/project.pbxproj index e062b42..dfaa86a 100755 --- a/Subler.xcodeproj/project.pbxproj +++ b/Subler.xcodeproj/project.pbxproj @@ -57,6 +57,8 @@ A9BC410818D9ABC000F8C92C /* QueueItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9BC410618D9ABC000F8C92C /* QueueItem.xib */; }; A9C055370F6D395B00AF15B5 /* FileImport.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9C055360F6D395B00AF15B5 /* FileImport.xib */; }; A9C4259318DB6D1F00E99DB8 /* stopTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = A9C4259218DB6D1F00E99DB8 /* stopTemplate.pdf */; }; + A9C5FA6E19FA22590051F3FF /* SBDebugLogController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C5FA6C19FA22590051F3FF /* SBDebugLogController.m */; }; + A9C5FA7419FA2FEC0051F3FF /* SBDebugLogWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9C5FA7219FA2FEC0051F3FF /* SBDebugLogWindow.xib */; }; A9C828F5195950C3004C4718 /* SBQueuePreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C828F4195950C3004C4718 /* SBQueuePreferences.m */; }; A9C9E34413FBC1EB00CA3B4E /* EncodeWorking.png in Resources */ = {isa = PBXBuildFile; fileRef = A9C9E34113FBC1EB00CA3B4E /* EncodeWorking.png */; }; A9D47B5817B239E200900BCA /* EncodeCanceled.png in Resources */ = {isa = PBXBuildFile; fileRef = A9D47B5417B239E200900BCA /* EncodeCanceled.png */; }; @@ -217,6 +219,9 @@ A9C0603F168315C500FE3D98 /* libbz2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbz2.dylib; path = usr/lib/libbz2.dylib; sourceTree = SDKROOT; }; A9C0957F0F7B6C8C00170CAF /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; A9C4259218DB6D1F00E99DB8 /* stopTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = stopTemplate.pdf; path = images/stopTemplate.pdf; sourceTree = ""; }; + A9C5FA6B19FA22590051F3FF /* SBDebugLogController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBDebugLogController.h; path = Classes/SBDebugLogController.h; sourceTree = ""; }; + A9C5FA6C19FA22590051F3FF /* SBDebugLogController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBDebugLogController.m; path = Classes/SBDebugLogController.m; sourceTree = ""; }; + A9C5FA7319FA2FEC0051F3FF /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/SBDebugLogWindow.xib; sourceTree = ""; }; A9C8182C0F74D6E300019BFF /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = ""; }; A9C828F3195950C3004C4718 /* SBQueuePreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBQueuePreferences.h; path = Classes/SBQueuePreferences.h; sourceTree = ""; }; A9C828F4195950C3004C4718 /* SBQueuePreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBQueuePreferences.m; path = Classes/SBQueuePreferences.m; sourceTree = ""; }; @@ -347,6 +352,8 @@ A9AB484817F0AEA2000AA72E /* SBAppDelegate.m */, CD71FF1A12F1C46900F0A98D /* MetadataImporters */, A9FD5D150F3C692400817716 /* PropertyView */, + A9C5FA6B19FA22590051F3FF /* SBDebugLogController.h */, + A9C5FA6C19FA22590051F3FF /* SBDebugLogController.m */, ); name = Classes; sourceTree = ""; @@ -433,6 +440,7 @@ A9EEA5F618D654B9008B54B4 /* QueueOptions.xib */, A9BC410618D9ABC000F8C92C /* QueueItem.xib */, A90B023910F3290A000416F3 /* Prefs.xib */, + A9C5FA7219FA2FEC0051F3FF /* SBDebugLogWindow.xib */, ); name = NIBs; sourceTree = ""; @@ -638,6 +646,7 @@ 1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */, A9D47B5917B239E200900BCA /* EncodeCanceled@2x.png in Resources */, A984DB740F52DD4B001A20B2 /* dsa_pub.pem in Resources */, + A9C5FA7419FA2FEC0051F3FF /* SBDebugLogWindow.xib in Resources */, A9C055370F6D395B00AF15B5 /* FileImport.xib in Resources */, A95C881D0F827BFB00F51A22 /* ToolbarRemoveTemplate.png in Resources */, A90B023B10F3290A000416F3 /* Prefs.xib in Resources */, @@ -704,6 +713,7 @@ A9B46ABF12B79D1C0040517A /* SBDocument.m in Sources */, CD71FEA312F1B5AF00F0A98D /* SBMetadataSearchController.m in Sources */, CD71FF1D12F1C4A900F0A98D /* TheTVDB.m in Sources */, + A9C5FA6E19FA22590051F3FF /* SBDebugLogController.m in Sources */, A9D73C5218BF3F1100C6FFA6 /* SBQueue.m in Sources */, A9AB485717F0AEAC000AA72E /* SBSoundViewController.m in Sources */, A9C828F5195950C3004C4718 /* SBQueuePreferences.m in Sources */, @@ -837,6 +847,14 @@ name = FileImport.xib; sourceTree = ""; }; + A9C5FA7219FA2FEC0051F3FF /* SBDebugLogWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + A9C5FA7319FA2FEC0051F3FF /* English */, + ); + name = SBDebugLogWindow.xib; + sourceTree = ""; + }; A9EEA5F618D654B9008B54B4 /* QueueOptions.xib */ = { isa = PBXVariantGroup; children = (