From afda89c28347bf13bd8c69454a2261dd021c2f5f Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 27 Jun 2011 00:59:33 +0000 Subject: - Add a bundle meta summary to the top of the bundle editor - Rearrange the bundle editor interface further, building on Stuart's work in r3330; particularly focussing on logically grouping fields together. - Move the "Disable" checkbox to the bottom of the window, rename it to "Disable bundle" to make the intent clear, and update the interface when it is in NSOnState --- Source/SPBundleEditorController.h | 1 + Source/SPBundleEditorController.m | 77 ++++++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 18 deletions(-) (limited to 'Source') diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h index 96b85e26..7bcf84e2 100644 --- a/Source/SPBundleEditorController.h +++ b/Source/SPBundleEditorController.h @@ -53,6 +53,7 @@ IBOutlet NSButton *saveButton; IBOutlet NSButton *cancelButton; IBOutlet NSButton *helpButton; + IBOutlet NSTextField *metaInfoSummary; IBOutlet NSButton *displayMetaInfoButton; IBOutlet NSMenuItem *duplicateMenuItem; IBOutlet NSMenuItem *revealInFinderMenuItem; diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index ff88f246..f4863a55 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -43,13 +43,15 @@ @interface SPBundleEditorController () - (void)_updateBundleDataView; +- (void)_updateBundleMetaSummary; - (id)_currentSelectedObject; - (id)_currentSelectedNode; -- (void)_enableBundleDataInput:(BOOL)enabled; +- (void)_enableBundleDataInput:(BOOL)enabled bundleEnabled:(BOOL)bundleEnabled; - (void)_initTree; - (NSUInteger)_arrangedScopeIndexForScopeIndex:(NSUInteger)scopeIndex; - (NSUInteger)_scopeIndexForArrangedScopeIndex:(NSUInteger)scopeIndex; - (NSUInteger)_arrangedCategoryIndexForScopeIndex:(NSUInteger)scopeIndex andCategory:(NSString*)category; +- (void)_metaSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; @end @@ -835,7 +837,7 @@ [NSApp beginSheet:metaInfoSheet modalForWindow:[self window] modalDelegate:self - didEndSelector:nil + didEndSelector:@selector(_metaSheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; } @@ -1290,9 +1292,9 @@ if(oldBundleName) [oldBundleName release], oldBundleName = nil; if(![[self _currentSelectedObject] objectForKey:kChildrenKey]) { oldBundleName = [[[self _currentSelectedObject] objectForKey:kBundleNameKey] retain]; - [self _enableBundleDataInput:YES]; + [self _enableBundleDataInput:YES bundleEnabled:![[[self _currentSelectedObject] objectForKey:@"disabled"] boolValue]]; } else { - [self _enableBundleDataInput:NO]; + [self _enableBundleDataInput:NO bundleEnabled:NO]; if(oldBundleName) [oldBundleName release], oldBundleName = nil; } @@ -1802,7 +1804,7 @@ [commandsOutlineView expandItem:[commandsOutlineView itemAtRow:0] expandChildren:NO]; [self _updateBundleDataView]; - [self _enableBundleDataInput:NO]; + [self _enableBundleDataInput:NO bundleEnabled:NO]; } /** @@ -1950,12 +1952,38 @@ [fallbackLabelField setHidden:YES]; } + // Update the bundle summary text + [self _updateBundleMetaSummary]; + // Validate add and remove bundle button in left bar [removeButton setEnabled:([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey])]; [addButton setEnabled:([[commandBundleTreeController selectionIndexPath] length] > 1)]; } +/** + * Update the bundle meta summary text + */ +- (void)_updateBundleMetaSummary +{ + NSDictionary *currentDict = [self _currentSelectedObject]; + if (!currentDict) { + [metaInfoSummary setStringValue:@""]; + return; + } + + NSMutableString *metaString = [[[NSMutableString alloc] init] autorelease]; + if ([currentDict objectForKey:@"author"]) { + [metaString appendFormat:@"(%@) ", [currentDict objectForKey:@"author"]]; + } else if ([currentDict objectForKey:@"contact"]) { + [metaString appendFormat:@"(%@) ", [currentDict objectForKey:@"contact"]]; + } + + if ([currentDict objectForKey:@"description"]) [metaString appendString:[currentDict objectForKey:@"description"]]; + + [metaInfoSummary setStringValue:metaString]; +} + /** * Return the current selected object as NSDictionary */ @@ -2011,23 +2039,29 @@ /** * Enable / disable data input */ -- (void)_enableBundleDataInput:(BOOL)enabled -{ - [nameTextField setEnabled:enabled]; - [inputPopupButton setEnabled:enabled]; - [inputFallbackPopupButton setEnabled:enabled]; - [scopePopupButton setEnabled:enabled]; - [commandTextView setEditable:enabled]; - [outputPopupButton setEnabled:enabled]; - [triggerPopupButton setEnabled:enabled]; - [disabledCheckbox setEnabled:enabled]; - [keyEquivalentField setEnabled:enabled]; - [categoryTextField setEnabled:enabled]; - [tooltipTextField setEnabled:enabled]; +- (void)_enableBundleDataInput:(BOOL)enabled bundleEnabled:(BOOL)bundleEnabled +{ + + // Most of the interface requires both a bundle selected and enabled + BOOL enableInterface = enabled && bundleEnabled; + [nameTextField setEnabled:enableInterface]; + [inputPopupButton setEnabled:enableInterface]; + [inputFallbackPopupButton setEnabled:enableInterface]; + [scopePopupButton setEnabled:enableInterface]; + [commandTextView setEditable:enableInterface]; + [outputPopupButton setEnabled:enableInterface]; + [triggerPopupButton setEnabled:enableInterface]; + [keyEquivalentField setEnabled:enableInterface]; + [categoryTextField setEnabled:enableInterface]; + [tooltipTextField setEnabled:enableInterface]; + + // Always leave the meta fields enabled, and the disabled checkbox. [authorTextField setEnabled:enabled]; [contactTextField setEnabled:enabled]; [descriptionTextView setEditable:enabled]; [displayMetaInfoButton setEnabled:enabled]; + + [disabledCheckbox setEnabled:enabled]; } /** @@ -2084,5 +2118,12 @@ return returnIndex; } +- (void)_metaSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +{ + [sheet makeFirstResponder:nil]; + + [self _updateBundleMetaSummary]; +} + @end -- cgit v1.2.3