diff --git a/Classes/SBItemViewController.h b/Classes/SBItemViewController.h index b793574..e392fcc 100644 --- a/Classes/SBItemViewController.h +++ b/Classes/SBItemViewController.h @@ -14,8 +14,6 @@ @private SBQueueItem *_item; - NSTextField *_actionsLabel; - NSButton *_editButton; NSProgressIndicator *_spinner; diff --git a/Classes/SBItemViewController.m b/Classes/SBItemViewController.m index 89bd8c6..f041e89 100644 --- a/Classes/SBItemViewController.m +++ b/Classes/SBItemViewController.m @@ -13,14 +13,14 @@ static void *SBItemViewContex = &SBItemViewContex; +#define TABLE_ROW_HEIGHT 14 + @interface SBItemViewController () -@property SBQueueItem *item; +@property (nonatomic) SBQueueItem *item; -@property (assign) IBOutlet NSTextField *actionsLabel; - -@property (assign) IBOutlet NSButton *editButton; -@property (assign) IBOutlet NSProgressIndicator *spinner; +@property (nonatomic, assign) IBOutlet NSButton *editButton; +@property (nonatomic, assign) IBOutlet NSProgressIndicator *spinner; @end @@ -29,8 +29,6 @@ static void *SBItemViewContex = &SBItemViewContex; @synthesize item = _item; @synthesize delegate = _delegate; -@synthesize actionsLabel = _actionsLabel; - @synthesize editButton = _editButton; @synthesize spinner = _spinner; @@ -50,23 +48,11 @@ static void *SBItemViewContex = &SBItemViewContex; - (void)loadView { [super loadView]; - NSMutableString *actions = [[[NSMutableString alloc] init] autorelease]; - for (id action in self.item.actions) { - [actions appendString:[NSString stringWithFormat:@"%@\n", [action description]]]; - } - - if ([actions length]) { - [self.actionsLabel setStringValue:actions]; - } else { - [self.actionsLabel setStringValue:@"None"]; - } - - NSSize frameSize = self.view.frame.size; - frameSize.height += [self.item.actions count] ? self.actionsLabel.frame.size.height * ([self.item.actions count] - 1) : 0; - [self.view setFrameSize:frameSize]; - // Observe the item status - [self addObserver:self forKeyPath:@"item.status" options:NSKeyValueObservingOptionInitial context:SBItemViewContex]; + [self addObserver:self forKeyPath:@"item.status" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:SBItemViewContex]; + + // Observe the item actions + [self addObserver:self forKeyPath:@"item.actions" options:NSKeyValueObservingOptionInitial context:SBItemViewContex]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { @@ -74,11 +60,16 @@ static void *SBItemViewContex = &SBItemViewContex; // Disable the edit button if the item status // is different from ready if ([keyPath isEqualToString:@"item.status"]) { - if (self.item.status != SBQueueItemStatusReady && self.item.status != SBQueueItemStatusEditing) { + SBQueueItemStatus newStatus = [[change valueForKey:NSKeyValueChangeNewKey] integerValue]; + if (newStatus != SBQueueItemStatusReady && newStatus != SBQueueItemStatusEditing) { [self.editButton setEnabled:NO]; } else { [self.editButton setEnabled:YES]; } + } else if ([keyPath isEqualToString:@"item.actions"]) { + NSSize frameSize = self.view.frame.size; + frameSize.height += [self.item.actions count] ? TABLE_ROW_HEIGHT * ([self.item.actions count] - 1) : 0; + [self.view setFrameSize:frameSize]; } } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; @@ -98,6 +89,7 @@ static void *SBItemViewContex = &SBItemViewContex; @try { [self removeObserver:self forKeyPath:@"item.status"]; + [self removeObserver:self forKeyPath:@"item.actions"]; } @catch (NSException * __unused exception) {} [super dealloc]; diff --git a/Classes/SBOptionsViewController.m b/Classes/SBOptionsViewController.m index 9a5510f..2eaa622 100644 --- a/Classes/SBOptionsViewController.m +++ b/Classes/SBOptionsViewController.m @@ -115,13 +115,13 @@ [self.options setValue:[panel URL] forKey:@"SBQueueDestination"]; [[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"SBQueueDestinationSelected"]; - } - else + } else { [_destButton selectItemAtIndex:2]; + } }]; } -- (NSMenuItem *)prepareDestPopupItem:(NSURL*) dest { +- (NSMenuItem *)prepareDestPopupItem:(NSURL *)dest { NSMenuItem *folderItem = [[NSMenuItem alloc] initWithTitle:[dest lastPathComponent] action:@selector(destination:) keyEquivalent:@""]; NSImage *menuItemIcon = [[NSWorkspace sharedWorkspace] iconForFile:[dest path]]; diff --git a/Classes/SBQueueController.m b/Classes/SBQueueController.m index 6cb9d3d..3ac9776 100755 --- a/Classes/SBQueueController.m +++ b/Classes/SBQueueController.m @@ -224,7 +224,7 @@ static void *SBQueueContex = &SBQueueContex; * and removes it from the queue. */ - (void)editItem:(SBQueueItem *)item { - item.status = SBQueueItemStatusEditing; + item.status = SBQueueItemStatusWorking; [self updateUI]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ diff --git a/English.lproj/QueueItem.xib b/English.lproj/QueueItem.xib index 90b4203..e15dc22 100644 --- a/English.lproj/QueueItem.xib +++ b/English.lproj/QueueItem.xib @@ -7,7 +7,6 @@ - @@ -23,7 +22,7 @@ - + @@ -53,7 +52,7 @@ - + @@ -74,7 +73,7 @@ - + @@ -85,15 +84,6 @@ - - - - - - - - -