From 0898dd7e4da0becb043f3ae3d37ccc4c0c13c44e Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 25 Nov 2010 23:02:27 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20method=20'rot13'=20to=20NSString=20?= =?UTF-8?q?=E2=80=A2=20Bundle=20Editor=20-=20fixed=20several=20GUI=20issue?= =?UTF-8?q?s=20-=20added=20the=20chance=20to=20add=20meta=20data=20to=20ea?= =?UTF-8?q?ch=20bundle=20-=20each=20added/duplicated=20bundle=20will=20get?= =?UTF-8?q?=20an=20unique=20UUID=20in=20order=20to=20be=20able=20to=20iden?= =?UTF-8?q?tify=20a=20Bundle=20for=20future=20purposes=20like=20an=20updat?= =?UTF-8?q?e=20detection=20for=20installed=20bundles=20-=20changed=20init?= =?UTF-8?q?=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPBundleEditorController.h | 32 ++-- Source/SPBundleEditorController.m | 327 ++++++++++++++++++++++---------------- Source/SPConstants.h | 4 + Source/SPConstants.m | 4 + Source/SPStringAdditions.h | 2 + Source/SPStringAdditions.m | 35 ++++ 6 files changed, 254 insertions(+), 150 deletions(-) (limited to 'Source') diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h index 84255fda..0d38b586 100644 --- a/Source/SPBundleEditorController.h +++ b/Source/SPBundleEditorController.h @@ -31,27 +31,36 @@ @interface SPBundleEditorController : NSWindowController { - IBOutlet id commandTextView; - IBOutlet NSTableView* commandsTableView; - IBOutlet id commandsOutlineView; - IBOutlet NSTextField* nameTextField; - IBOutlet NSTextField* tootlipTextField; - IBOutlet NSTextField* categoryTextField; - IBOutlet NSTextField* fallbackLabelField; - IBOutlet NSPopUpButton* inputPopupButton; - IBOutlet NSPopUpButton* inputFallbackPopupButton; - IBOutlet NSPopUpButton* outputPopupButton; - IBOutlet NSPopUpButton* scopePopupButton; + IBOutlet SPBundleCommandTextView *commandTextView; + IBOutlet SPOutlineView *commandsOutlineView; + IBOutlet NSTextField *authorTextField; + IBOutlet NSTextField *contactTextField; + IBOutlet NSTextView *descriptionTextView; + IBOutlet NSTextField *nameTextField; + IBOutlet NSTextField *tooltipTextField; + IBOutlet NSTextField *categoryTextField; + IBOutlet NSTextField *fallbackLabelField; + IBOutlet NSTextField *commandLabelField; + IBOutlet NSTextField *authorLabelField; + IBOutlet NSTextField *contactLabelField; + IBOutlet NSTextField *descriptionLabelField; + IBOutlet NSPopUpButton *inputPopupButton; + IBOutlet NSPopUpButton *inputFallbackPopupButton; + IBOutlet NSPopUpButton *outputPopupButton; + IBOutlet NSPopUpButton *scopePopupButton; IBOutlet NSButton *removeButton; IBOutlet NSButton *addButton; IBOutlet NSButton *saveButton; IBOutlet NSButton *cancelButton; IBOutlet NSButton *helpButton; + IBOutlet NSButton *showHideMetaButton; IBOutlet NSMenuItem *duplicateMenuItem; IBOutlet NSMenuItem *revealInFinderMenuItem; IBOutlet SRRecorderControl *keyEquivalentField; IBOutlet NSButton *disabledCheckbox; IBOutlet NSView *bundleDataView; + IBOutlet NSScrollView *commandScrollView; + IBOutlet NSScrollView *descriptionScrollView; IBOutlet NSTreeController *commandBundleTreeController; NSMutableArray *touchedBundleArray; @@ -100,6 +109,7 @@ - (IBAction)showHelp:(id)sender; - (IBAction)saveAndCloseWindow:(id)sender; - (IBAction)reloadBundles:(id)sender; +- (IBAction)metaButtonChanged:(id)sender; - (BOOL)saveBundle:(NSDictionary*)bundle atPath:(NSString*)aPath; diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 01d74ddc..0a34e61b 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -38,6 +38,8 @@ - (id)_currentSelectedObject; - (id)_currentSelectedNode; - (void)_enableBundleDataInput:(BOOL)enabled; +- (void)_enableMetaDataInput:(BOOL)enabled; +- (void)_initTree; - (NSUInteger)_arrangedScopeIndexForScopeIndex:(NSUInteger)scopeIndex; - (NSUInteger)_scopeIndexForArrangedScopeIndex:(NSUInteger)scopeIndex; - (NSUInteger)_arrangedCategoryIndexForScopeIndex:(NSUInteger)scopeIndex andCategory:(NSString*)category; @@ -245,6 +247,8 @@ [commandBundleTreeController setSortDescriptors:[NSArray arrayWithObjects:sortDescriptor, nil]]; + [self _initTree]; + } #pragma mark - @@ -404,6 +408,8 @@ // Store pending changes in Query [[self window] makeFirstResponder:nameTextField]; + NSString *newUUID = [NSString stringWithNewUUID]; + NSIndexPath *currentIndexPath = nil; currentIndexPath = [commandBundleTreeController selectionIndexPath]; @@ -417,6 +423,8 @@ NSDictionary *currentDict = [self _currentSelectedObject]; bundle = [NSMutableDictionary dictionaryWithDictionary:currentDict]; + [bundle setObject:newUUID forKey:SPBundleFileUUIDKey]; + NSString *bundleFileName = [bundle objectForKey:kBundleNameKey]; NSString *newFileName = [NSString stringWithFormat:@"%@_Copy", [bundle objectForKey:kBundleNameKey]]; NSString *possibleExisitingBundleFilePath = [NSString stringWithFormat:@"%@/%@.%@", bundlePath, bundleFileName, SPUserBundleFileExtension]; @@ -519,8 +527,8 @@ } if(category == nil) category = @""; - bundle = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Bundle", @"New Name", @"", scope, category, nil] - forKeys:[NSArray arrayWithObjects:kBundleNameKey, SPBundleFileNameKey, SPBundleFileCommandKey, SPBundleFileScopeKey, SPBundleFileCategoryKey, nil]]; + bundle = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Bundle", @"New Name", @"", scope, category, newUUID, nil] + forKeys:[NSArray arrayWithObjects:kBundleNameKey, SPBundleFileNameKey, SPBundleFileCommandKey, SPBundleFileScopeKey, SPBundleFileCategoryKey, SPBundleFileUUIDKey, nil]]; } if(![touchedBundleArray containsObject:[bundle objectForKey:kBundleNameKey]]) @@ -609,7 +617,15 @@ */ - (IBAction)reloadBundles:(id)sender { - [self showWindow:self]; + [self _initTree]; +} + +/** + * Show/Hide meta data input fields + */ +- (IBAction)metaButtonChanged:(id)sender +{ + [self _enableMetaDataInput:([sender state] == NSOnState) ? YES : NO]; } /** @@ -618,138 +634,8 @@ - (IBAction)showWindow:(id)sender { - // Suppress parsing if window is already opened - if(sender != self && [[self window] isVisible]) { - [super showWindow:sender]; - return; - } - - // Order out window [super showWindow:sender]; - // Re-init commandBundleTree - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kInputFieldScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kDataTableScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kGeneralScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [commandsOutlineView reloadData]; - - // Load all installed bundle items - if(bundlePath) { - NSError *error = nil; - NSArray *foundBundles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePath error:&error]; - if (foundBundles && [foundBundles count]) { - for(NSString* bundle in foundBundles) { - if(![[[bundle pathExtension] lowercaseString] isEqualToString:[SPUserBundleFileExtension lowercaseString]]) continue; - - NSError *readError = nil; - NSString *convError = nil; - NSPropertyListFormat format; - NSDictionary *cmdData = nil; - NSString *infoPath = [NSString stringWithFormat:@"%@/%@/%@", bundlePath, bundle, SPBundleFileName]; - NSData *pData = [NSData dataWithContentsOfFile:infoPath options:NSUncachedRead error:&readError]; - - cmdData = [[NSPropertyListSerialization propertyListFromData:pData - mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain]; - - if(!cmdData || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) { - NSLog(@"“%@/%@” file couldn't be read.", bundle, SPBundleFileName); - NSBeep(); - if (cmdData) [cmdData release]; - } else { - if([cmdData objectForKey:SPBundleFileNameKey] && [[cmdData objectForKey:SPBundleFileNameKey] length] && [cmdData objectForKey:SPBundleFileScopeKey]) - { - NSMutableDictionary *bundleCommand = [NSMutableDictionary dictionary]; - [bundleCommand addEntriesFromDictionary:cmdData]; - [bundleCommand setObject:[bundle stringByDeletingPathExtension] forKey:kBundleNameKey]; - - if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeInputField]) { - if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { - BOOL catExists = NO; - id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kInputFieldScopeArrayIndex] objectForKey:kChildrenKey]; - for(id child in children) { - if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { - [[child objectForKey:kChildrenKey] addObject:bundleCommand]; - catExists = YES; - break; - } - } - if(!catExists) { - NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; - [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; - [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] objectForKey:kChildrenKey] addObject:aDict]; - } - } else { - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] objectForKey:kChildrenKey] addObject:bundleCommand]; - } - } - - else if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeDataTable]) { - if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { - BOOL catExists = NO; - id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kDataTableScopeArrayIndex] objectForKey:kChildrenKey]; - for(id child in children) { - if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { - [[child objectForKey:kChildrenKey] addObject:bundleCommand]; - catExists = YES; - break; - } - } - if(!catExists) { - NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; - [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; - [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] objectForKey:kChildrenKey] addObject:aDict]; - } - } else { - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] objectForKey:kChildrenKey] addObject:bundleCommand]; - } - } - - else if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeGeneral]) { - if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { - BOOL catExists = NO; - id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kGeneralScopeArrayIndex] objectForKey:kChildrenKey]; - for(id child in children) { - if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { - [[child objectForKey:kChildrenKey] addObject:bundleCommand]; - catExists = YES; - break; - } - } - if(!catExists) { - NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; - [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; - [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] objectForKey:kChildrenKey] addObject:aDict]; - } - } else { - [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] objectForKey:kChildrenKey] addObject:bundleCommand]; - } - } - - } - if (cmdData) [cmdData release]; - } - } - } - } - - [removeButton setEnabled:([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey])]; - [addButton setEnabled:([[commandBundleTreeController selectionIndexPath] length] > 1)]; - - [commandBundleTreeController setContent:commandBundleTree]; - [commandBundleTreeController rearrangeObjects]; - [commandsOutlineView reloadData]; - [commandsOutlineView expandItem:[commandsOutlineView itemAtRow:0] expandChildren:NO]; - NSUInteger *selPath[2]; - selPath[0] = 0; - selPath[1] = 0; - [commandBundleTreeController setSelectionIndexPath:[NSIndexPath indexPathWithIndexes:&selPath length:2]]; - } /** @@ -853,6 +739,10 @@ NSMutableDictionary *saveDict = [NSMutableDictionary dictionary]; [saveDict addEntriesFromDictionary:bundle]; + // ROT13 a contact - mainly a mail address + if([saveDict objectForKey:SPBundleFileContactKey] && [[saveDict objectForKey:SPBundleFileContactKey] length]) + [saveDict setObject:[[saveDict objectForKey:SPBundleFileContactKey] rot13] forKey:SPBundleFileContactKey]; + // Remove unnecessary keys [saveDict removeObjectsForKeys:[NSArray arrayWithObjects: kBundleNameKey, @@ -982,11 +872,11 @@ - (void)windowWillClose:(NSNotification *)notification { // Clear some stuff if window will close to save memory - [touchedBundleArray removeAllObjects]; - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] setObject:[NSMutableArray array] forKey:kChildrenKey]; - [commandsOutlineView reloadData]; + // [touchedBundleArray removeAllObjects]; + // [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] setObject:[NSMutableArray array] forKey:kChildrenKey]; + // [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] setObject:[NSMutableArray array] forKey:kChildrenKey]; + // [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] setObject:[NSMutableArray array] forKey:kChildrenKey]; + // [commandsOutlineView reloadData]; // Remove temporary drag file if any if(draggedFilePath) { @@ -1464,6 +1354,144 @@ @implementation SPBundleEditorController (PrivateAPI) +- (void)_initTree +{ + NSString *a=[[NSString stringWithString:@"bibiko@eva.mpg.de"] rot13]; + + [showHideMetaButton setState:NSOffState]; + [self _enableMetaDataInput:NO]; + + // Re-init commandBundleTree + [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kInputFieldScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; + [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kDataTableScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; + [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kGeneralScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey]; + [commandsOutlineView reloadData]; + + // Load all installed bundle items + if(bundlePath) { + NSError *error = nil; + NSArray *foundBundles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePath error:&error]; + if (foundBundles && [foundBundles count]) { + for(NSString* bundle in foundBundles) { + if(![[[bundle pathExtension] lowercaseString] isEqualToString:[SPUserBundleFileExtension lowercaseString]]) continue; + + NSError *readError = nil; + NSString *convError = nil; + NSPropertyListFormat format; + NSDictionary *cmdData = nil; + NSString *infoPath = [NSString stringWithFormat:@"%@/%@/%@", bundlePath, bundle, SPBundleFileName]; + NSData *pData = [NSData dataWithContentsOfFile:infoPath options:NSUncachedRead error:&readError]; + + cmdData = [[NSPropertyListSerialization propertyListFromData:pData + mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain]; + + if(!cmdData || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) { + NSLog(@"“%@/%@” file couldn't be read.", bundle, SPBundleFileName); + NSBeep(); + if (cmdData) [cmdData release]; + } else { + if([cmdData objectForKey:SPBundleFileNameKey] && [[cmdData objectForKey:SPBundleFileNameKey] length] && [cmdData objectForKey:SPBundleFileScopeKey]) + { + NSMutableDictionary *bundleCommand = [NSMutableDictionary dictionary]; + [bundleCommand addEntriesFromDictionary:cmdData]; + [bundleCommand setObject:[bundle stringByDeletingPathExtension] forKey:kBundleNameKey]; + + // ROT13 a contact - mainly a mail address + if([bundleCommand objectForKey:SPBundleFileContactKey] && [[bundleCommand objectForKey:SPBundleFileContactKey] length]) + [bundleCommand setObject:[[bundleCommand objectForKey:SPBundleFileContactKey] rot13] forKey:SPBundleFileContactKey]; + + if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeInputField]) { + if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { + BOOL catExists = NO; + id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kInputFieldScopeArrayIndex] objectForKey:kChildrenKey]; + for(id child in children) { + if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { + [[child objectForKey:kChildrenKey] addObject:bundleCommand]; + catExists = YES; + break; + } + } + if(!catExists) { + NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; + [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; + [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; + [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] objectForKey:kChildrenKey] addObject:aDict]; + } + } else { + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:0] objectForKey:kChildrenKey] addObject:bundleCommand]; + } + } + + else if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeDataTable]) { + if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { + BOOL catExists = NO; + id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kDataTableScopeArrayIndex] objectForKey:kChildrenKey]; + for(id child in children) { + if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { + [[child objectForKey:kChildrenKey] addObject:bundleCommand]; + catExists = YES; + break; + } + } + if(!catExists) { + NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; + [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; + [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; + [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] objectForKey:kChildrenKey] addObject:aDict]; + } + } else { + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:1] objectForKey:kChildrenKey] addObject:bundleCommand]; + } + } + + else if([[cmdData objectForKey:SPBundleFileScopeKey] isEqualToString:SPBundleScopeGeneral]) { + if([cmdData objectForKey:SPBundleFileCategoryKey] && [[cmdData objectForKey:SPBundleFileCategoryKey] length]) { + BOOL catExists = NO; + id children = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kGeneralScopeArrayIndex] objectForKey:kChildrenKey]; + for(id child in children) { + if([child isKindOfClass:[NSDictionary class]] && [child objectForKey:kChildrenKey] && [[child objectForKey:kBundleNameKey] isEqualToString:[cmdData objectForKey:SPBundleFileCategoryKey]]) { + [[child objectForKey:kChildrenKey] addObject:bundleCommand]; + catExists = YES; + break; + } + } + if(!catExists) { + NSMutableDictionary *aDict = [NSMutableDictionary dictionary]; + [aDict setObject:[cmdData objectForKey:SPBundleFileCategoryKey] forKey:kBundleNameKey]; + [aDict setObject:[NSMutableArray array] forKey:kChildrenKey]; + [[aDict objectForKey:kChildrenKey] addObject:bundleCommand]; + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] objectForKey:kChildrenKey] addObject:aDict]; + } + } else { + [[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:2] objectForKey:kChildrenKey] addObject:bundleCommand]; + } + } + + } + if (cmdData) [cmdData release]; + } + } + } + } + + [removeButton setEnabled:([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey])]; + [addButton setEnabled:([[commandBundleTreeController selectionIndexPath] length] > 1)]; + + [commandBundleTreeController setContent:commandBundleTree]; + NSUInteger *selPath[2]; + selPath[0] = 0; + selPath[1] = 0; + [commandBundleTreeController setSelectionIndexPath:[NSIndexPath indexPathWithIndexes:&selPath length:2]]; + [commandBundleTreeController rearrangeObjects]; + [commandsOutlineView reloadData]; + + [commandsOutlineView expandItem:[commandsOutlineView itemAtRow:0] expandChildren:NO]; + [self _updateBundleDataView]; + [self _enableBundleDataInput:NO]; +} + /** * Update various GUI elements due to scope or input changes */ @@ -1634,7 +1662,28 @@ [disabledCheckbox setEnabled:enabled]; [keyEquivalentField setEnabled:enabled]; [categoryTextField setEnabled:enabled]; - [tootlipTextField setEnabled:enabled]; + [tooltipTextField setEnabled:enabled]; + [authorTextField setEnabled:enabled]; + [contactTextField setEnabled:enabled]; + [descriptionTextView setEditable:enabled]; +} + +/** + * Enable / disable meta input + */ +- (void)_enableMetaDataInput:(BOOL)enabled +{ + [commandTextView setHidden:enabled]; + [disabledCheckbox setHidden:enabled]; + [commandLabelField setHidden:enabled]; + [commandScrollView setHidden:enabled]; + [authorLabelField setHidden:!enabled]; + [contactLabelField setHidden:!enabled]; + [descriptionLabelField setHidden:!enabled]; + [descriptionTextView setHidden:!enabled]; + [authorTextField setHidden:!enabled]; + [contactTextField setHidden:!enabled]; + [descriptionScrollView setHidden:!enabled]; } /** diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 8f164749..fadf8573 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -459,6 +459,10 @@ extern NSString *SPBundleFileKeyEquivalentKey; extern NSString *SPBundleFileInternalKeyEquivalentKey; extern NSString *SPBundleFileTooltipKey; extern NSString *SPBundleFileDisabledKey; +extern NSString *SPBundleFileAuthorKey; +extern NSString *SPBundleFileContactKey; +extern NSString *SPBundleFileUUIDKey; +extern NSString *SPBundleFileDescriptionKey; extern NSString *SPBundleInternLabelKey; extern NSString *SPBundleInternPathToFileKey; extern NSString *SPBundleInternKeyEquivalentKey; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 2c99a531..0c731abd 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -278,6 +278,10 @@ NSString *SPBundleFileKeyEquivalentKey = @"keyEquivalent"; NSString *SPBundleFileInternalKeyEquivalentKey = @"internalKeyEquivalent"; NSString *SPBundleFileTooltipKey = @"tooltip"; NSString *SPBundleFileDisabledKey = @"disabled"; +NSString *SPBundleFileAuthorKey = @"author"; +NSString *SPBundleFileContactKey = @"contact"; +NSString *SPBundleFileUUIDKey = @"uuid"; +NSString *SPBundleFileDescriptionKey = @"description"; NSString *SPBundleInternLabelKey = @"label"; NSString *SPBundleInternPathToFileKey = @"path"; NSString *SPBundleInternKeyEquivalentKey = @"keyEquivalent"; diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h index 15a3d9a9..e9e3784c 100644 --- a/Source/SPStringAdditions.h +++ b/Source/SPStringAdditions.h @@ -61,6 +61,8 @@ static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedS + (NSString *)stringForTimeInterval:(CGFloat)timeInterval; + (NSString*)stringWithNewUUID; + +- (NSString *)rot13; - (NSString *)HTMLEscapeString; - (NSString *)backtickQuotedString; - (NSString *)tickQuotedString; diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index 1f9f2738..1185756b 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -156,6 +156,41 @@ return [newUUID autorelease]; } +/** + * Returns ROT13 representation + */ +- (NSString *)rot13 +{ + NSMutableString *holder = [[NSMutableString alloc] init]; + unichar theChar; + int i; + + for(i = 0; i < [self length]; i++) { + theChar = [self characterAtIndex:i]; + if(theChar <= 122 && theChar >= 97) { + if(theChar + 13 > 122) + theChar -= 13; + else + theChar += 13; + [holder appendFormat:@"%C", (char)theChar]; + + + } else if(theChar <= 90 && theChar >= 65) { + if((int)theChar + 13 > 90) + theChar -= 13; + else + theChar += 13; + + [holder appendFormat:@"%C", theChar]; + + } else { + [holder appendFormat:@"%C", theChar]; + } + } + + return [NSString stringWithString:holder]; +} + /** * Escapes HTML special characters. */ -- cgit v1.2.3