From 718c8b11386cfd4ea45c0c423a4b57d8adc9423e Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Thu, 20 Mar 2014 19:56:27 +0100 Subject: [PATCH] Added a toolbar to the queue window. --- Classes/SBQueueController.h | 5 +- Classes/SBQueueController.m | 60 +++++++++---- English.lproj/Queue.xib | 150 +++++++++++++++++-------------- Subler.xcodeproj/project.pbxproj | 4 + images/stopTemplate.pdf | Bin 0 -> 2406 bytes 5 files changed, 131 insertions(+), 88 deletions(-) create mode 100644 images/stopTemplate.pdf diff --git a/Classes/SBQueueController.h b/Classes/SBQueueController.h index 810962a..4c9835e 100755 --- a/Classes/SBQueueController.h +++ b/Classes/SBQueueController.h @@ -16,9 +16,6 @@ @interface SBQueueController : NSWindowController { @private - IBOutlet NSButton *_start; - IBOutlet NSButton *_open; - IBOutlet NSTextField *_countLabel; IBOutlet NSProgressIndicator *_progressIndicator; @@ -26,6 +23,8 @@ IBOutlet SBTableView *_tableView; IBOutlet NSWindow *_detachedWindow; + IBOutlet NSToolbarItem *_startItem; + NSPopover *_popover; NSPopover *_itemPopover; diff --git a/Classes/SBQueueController.m b/Classes/SBQueueController.m index 8328b9e..51c92b1 100755 --- a/Classes/SBQueueController.m +++ b/Classes/SBQueueController.m @@ -116,7 +116,7 @@ static void *SBQueueContex = &SBQueueContex; [_progressIndicator stopAnimation:self]; [_progressIndicator setDoubleValue:0]; [_progressIndicator setIndeterminate:YES]; - [_start setTitle:@"Start"]; + [_startItem setImage:[NSImage imageNamed:NSImageNameGoRightTemplate]]; [_countLabel setStringValue:@"Done"]; [self updateDockTile]; @@ -204,15 +204,25 @@ static void *SBQueueContex = &SBQueueContex; #pragma mark - Queue methods +/* + * The queue status + */ - (SBQueueStatus)status { return self.queue.status; } +/* + * Saves the queue and the user defaults. + */ - (BOOL)saveQueueToDisk { [self saveUserDefaults]; return [self.queue saveQueueToDisk]; } +/* + * Opens a SBQueueItem in a new document window + * and removes it from the queue. + */ - (void)editItem:(SBQueueItem *)item { item.status = SBQueueItemStatusEditing; [self updateUI]; @@ -231,14 +241,15 @@ static void *SBQueueContex = &SBQueueContex; [self removeItems:[NSArray arrayWithObject:item]]; [self updateUI]; }); - - [item release]; - }); } #pragma mark - Queue items creation +/** + * Creates a new SBQueueItem from an NSURL, + * and adds the current actions to it. + */ - (SBQueueItem *)createItemWithURL:(NSURL *)url { SBQueueItem *item = [SBQueueItem itemWithURL:url]; @@ -266,11 +277,18 @@ static void *SBQueueContex = &SBQueueContex; return item; } +/** + * Adds a SBQueueItem to the queue + */ - (void)addItem:(SBQueueItem *)item { [self addItems:[NSArray arrayWithObject:item] atIndexes:nil]; [self updateUI]; } +/** + * Adds an array of SBQueueItem to the queue. + * Implements the undo manager. + */ - (void)addItems:(NSArray *)items atIndexes:(NSIndexSet *)indexes; { NSMutableIndexSet *mutableIndexes = [indexes mutableCopy]; if ([indexes count] == [items count]) { @@ -303,6 +321,10 @@ static void *SBQueueContex = &SBQueueContex; [mutableIndexes release]; } +/** + * Removes an array of SBQueueItemfromto the queue. + * Implements the undo manager. + */ - (void)removeItems:(NSArray *)items { NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init]; @@ -319,12 +341,15 @@ static void *SBQueueContex = &SBQueueContex; } if ([undo isUndoing] || [undo isRedoing]) [self updateUI]; - + [indexes release]; } #pragma mark - NSPopover delegate +/* + * Creates a popover with the queue options. + */ - (void)createPopover { if (self.popover == nil) { // create and setup our popover @@ -345,11 +370,11 @@ static void *SBQueueContex = &SBQueueContex; } } +/* + * Creates a popover with a SBQueueItem + */ - (void)createItemPopover:(SBQueueItem *)item { - if (self.itemPopover) { - self.itemPopover = nil; - } - _itemPopover = [[NSPopover alloc] init]; + self.itemPopover = [[[NSPopover alloc] init] autorelease]; // the popover retains us and we retain the popover, // we drop the popover whenever it is closed to avoid a cycle @@ -389,6 +414,9 @@ static void *SBQueueContex = &SBQueueContex; #pragma mark - UI methods +/* + * Updates the count on the app dock icon. + */ - (void)updateDockTile { NSUInteger count = [self.queue readyCount]; @@ -410,7 +438,7 @@ static void *SBQueueContex = &SBQueueContex; if (self.queue.status == SBQueueStatusWorking) return; - [_start setTitle:@"Stop"]; + [_startItem setImage:[NSImage imageNamed:@"stopTemplate"]]; [_countLabel setStringValue:@"Working."]; [_progressIndicator setHidden:NO]; [_progressIndicator startAnimation:self]; @@ -418,13 +446,6 @@ static void *SBQueueContex = &SBQueueContex; [self.queue start]; } -- (void)progressStatus:(CGFloat)progress { - dispatch_async(dispatch_get_main_queue(), ^{ - [_progressIndicator setIndeterminate:NO]; - [_progressIndicator setDoubleValue:progress]; - }); -} - - (void)stop:(id)sender { [self.queue stop]; } @@ -559,6 +580,7 @@ static void *SBQueueContex = &SBQueueContex; - (IBAction)edit:(id)sender { SBQueueItem *item = [[self.queue itemAtIndex:[_tableView clickedRow]] retain]; [self editItem:item]; + [item release]; } - (IBAction)showInFinder:(id)sender { @@ -629,6 +651,10 @@ static void *SBQueueContex = &SBQueueContex; return NO; } +- (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem { + return YES; +} + #pragma mark Drag & Drop - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard { diff --git a/English.lproj/Queue.xib b/English.lproj/Queue.xib index 508d992..3d230c7 100755 --- a/English.lproj/Queue.xib +++ b/English.lproj/Queue.xib @@ -9,10 +9,7 @@ - - - @@ -30,7 +27,7 @@ - + @@ -40,22 +37,22 @@ - + - - + + - + - + @@ -102,66 +99,81 @@ - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -199,16 +211,18 @@ - + - + + + diff --git a/Subler.xcodeproj/project.pbxproj b/Subler.xcodeproj/project.pbxproj index 7c42ca0..d8d60cd 100755 --- a/Subler.xcodeproj/project.pbxproj +++ b/Subler.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ A9BC410318D9AB8700F8C92C /* SBItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BC410218D9AB8700F8C92C /* SBItemViewController.m */; }; 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 */; }; A9C9E34413FBC1EB00CA3B4E /* EncodeWorking.png in Resources */ = {isa = PBXBuildFile; fileRef = A9C9E34113FBC1EB00CA3B4E /* EncodeWorking.png */; }; A9D47B5817B239E200900BCA /* EncodeCanceled.png in Resources */ = {isa = PBXBuildFile; fileRef = A9D47B5417B239E200900BCA /* EncodeCanceled.png */; }; A9D47B5917B239E200900BCA /* EncodeCanceled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9D47B5517B239E200900BCA /* EncodeCanceled@2x.png */; }; @@ -212,6 +213,7 @@ A9C055330F6D394F00AF15B5 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/FileImport.xib; sourceTree = ""; }; 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 = ""; }; A9C8182C0F74D6E300019BFF /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = ""; }; A9C9E34113FBC1EB00CA3B4E /* EncodeWorking.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = EncodeWorking.png; path = images/EncodeWorking.png; sourceTree = ""; }; A9D47B5417B239E200900BCA /* EncodeCanceled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = EncodeCanceled.png; path = images/EncodeCanceled.png; sourceTree = ""; }; @@ -373,6 +375,7 @@ A975644B132A325C0051ED08 /* info-over.pdf */, A975644C132A325C0051ED08 /* info-pressed.pdf */, A9B46AA312B79BB10040517A /* Subler.icns */, + A9C4259218DB6D1F00E99DB8 /* stopTemplate.pdf */, A95C881C0F827BFB00F51A22 /* ToolbarRemoveTemplate.png */, A96371B7164695070083BB80 /* ToolbarRemoveTemplate@2x.png */, A98739FD13FBB09B00B795A7 /* ToolbarActionTemplate.png */, @@ -632,6 +635,7 @@ A90B023B10F3290A000416F3 /* Prefs.xib in Resources */, A9AB486417F0AEFD000AA72E /* ChapterView.xib in Resources */, A9AB486817F0AEFD000AA72E /* VideoView.xib in Resources */, + A9C4259318DB6D1F00E99DB8 /* stopTemplate.pdf in Resources */, A9B46AA412B79BB10040517A /* Subler.icns in Resources */, CD71FEA612F1B62600F0A98D /* MetadataSearch.xib in Resources */, CD4E6E5D12F744210095C84F /* ArtworkSelector.xib in Resources */, diff --git a/images/stopTemplate.pdf b/images/stopTemplate.pdf new file mode 100644 index 0000000000000000000000000000000000000000..84848c0e0e33dc79b0567adff251ca6d7fbc25d8 GIT binary patch literal 2406 zcmai03se)?8CEbsqbpsJx6~1cAQqCz`+=}Z9g+bfkU%nE1k=^CxGvBx zWl>vS*hP`oL10l4c?rt`1yMk(JQffNDg{<5;8Jjlk}UaP zt?;o_O7?;k$qNmav==L<9IYil;=!>p2`q5i_v=+Y?boO17HxG(R0yscIRl5>&LsU% z;3o_$H8;zz!+WGhIV&hV$z$iw&_6)&@?&j?g%WhvZ_5134-pwnI ztk0!o8J$h{Olm7`=j*oT4SU(AHZ^Z?s5boh;Yhzl()y;c)Su?P-dI(|CI8r(Xz6`l zZfKz~o!;d8pgsH!e`}TA%(Sco|Kr5A@yCpHI(a&O(Oll5ZmqZ3>2c|`hX_)g7{*z|MP^N zrsB^oJkYU9kyd3j51!OJ>3l1{JR8^C#$i%3j9&9U4VT}{+1qvVVu0_)Im!j@;gp75 zk!9y<&Tenod@uG}(b*;lYKhF=13;VdM16P)A-1Xptm}v$Ykj3`ZiRA>s7*O%Q15-L@s7=Qum%pY;iU z{LZ+-KEpSYTVD`W_4lGf&ce>Mv)e<8N6F@42G`_z(EL%^4nfvHxH+8h+YYkXx{8!->Ybl;9_BXAGNZhL479 z8OQEc)FfZCuKdFC>z8|bXDau{_H2s$DUf&OT@81{|43lAfoAMCQ&nbNUygg7cuvho z)|XSeFJ+k3(w=>P&-DH|^#g^}kTHy)jfHl$T z)%=MO4aQ#}na0%e5k^rMhVqz)i_1Pp1xo>pqXa;()&yfwE$uCntm^;MCdP*`C~%RO9Z~mo*=li!&ZeTqC{|H6s9}7w2^{Z zJ+SqJB!IUNI0S%X2etzh@Qs0#NF0Dt^#b>+k>x$w^lW83C3I{V*NUDkk3%7YG%^)^ zvuI2T_!*gOgZ`E+S7sqYB4A)4OjK7;k&wnnP<>no3b|w551Zr?H literal 0 HcmV?d00001