Skip to content

Commit

Permalink
Improve the indexing UI greatly.
Browse files Browse the repository at this point in the history
  • Loading branch information
beelsebob committed Dec 24, 2012
1 parent 3fd5035 commit 8719915
Show file tree
Hide file tree
Showing 8 changed files with 688 additions and 162 deletions.
Binary file added Images/Tick.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Tick@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Stash.xcodeproj/project.pbxproj
Expand Up @@ -48,6 +48,8 @@
1F50A3DE157BAAA400CF6068 /* Union@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C6157BAAA400CF6068 /* Union@2x.png */; }; 1F50A3DE157BAAA400CF6068 /* Union@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C6157BAAA400CF6068 /* Union@2x.png */; };
1F50A3DF157BAAA400CF6068 /* Value.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C7157BAAA400CF6068 /* Value.png */; }; 1F50A3DF157BAAA400CF6068 /* Value.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C7157BAAA400CF6068 /* Value.png */; };
1F50A3E0157BAAA400CF6068 /* Value@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C8157BAAA400CF6068 /* Value@2x.png */; }; 1F50A3E0157BAAA400CF6068 /* Value@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C8157BAAA400CF6068 /* Value@2x.png */; };
1F747C1C1687D3B6006D2DFB /* Tick.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F747C1A1687D3B6006D2DFB /* Tick.png */; };
1F747C1D1687D3B6006D2DFB /* Tick@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F747C1B1687D3B6006D2DFB /* Tick@2x.png */; };
1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */; }; 1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */; };
1FBF3DE2157CAFD4007B8D97 /* STAPreferencesController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */; }; 1FBF3DE2157CAFD4007B8D97 /* STAPreferencesController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */; };
1FBF3DE6157CAFEC007B8D97 /* STAPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE5157CAFEC007B8D97 /* STAPreferencesController.m */; }; 1FBF3DE6157CAFEC007B8D97 /* STAPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE5157CAFEC007B8D97 /* STAPreferencesController.m */; };
Expand Down Expand Up @@ -123,6 +125,8 @@
1F50A3C6157BAAA400CF6068 /* Union@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Union@2x.png"; sourceTree = "<group>"; }; 1F50A3C6157BAAA400CF6068 /* Union@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Union@2x.png"; sourceTree = "<group>"; };
1F50A3C7157BAAA400CF6068 /* Value.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Value.png; sourceTree = "<group>"; }; 1F50A3C7157BAAA400CF6068 /* Value.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Value.png; sourceTree = "<group>"; };
1F50A3C8157BAAA400CF6068 /* Value@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Value@2x.png"; sourceTree = "<group>"; }; 1F50A3C8157BAAA400CF6068 /* Value@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Value@2x.png"; sourceTree = "<group>"; };
1F747C1A1687D3B6006D2DFB /* Tick.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Tick.png; sourceTree = "<group>"; };
1F747C1B1687D3B6006D2DFB /* Tick@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Tick@2x.png"; sourceTree = "<group>"; };
1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HorizontalSeparator.png; sourceTree = "<group>"; }; 1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HorizontalSeparator.png; sourceTree = "<group>"; };
1F879AD81658F3CC004ABD2C /* Stash.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Stash.entitlements; sourceTree = "<group>"; }; 1F879AD81658F3CC004ABD2C /* Stash.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Stash.entitlements; sourceTree = "<group>"; };
1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = STAPreferencesController.xib; sourceTree = "<group>"; }; 1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = STAPreferencesController.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -266,6 +270,8 @@
1F50A3B0157BAAA400CF6068 /* Images */ = { 1F50A3B0157BAAA400CF6068 /* Images */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1F747C1A1687D3B6006D2DFB /* Tick.png */,
1F747C1B1687D3B6006D2DFB /* Tick@2x.png */,
1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */, 1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */,
1FBF3DE9157E3F22007B8D97 /* iOS.png */, 1FBF3DE9157E3F22007B8D97 /* iOS.png */,
1FBF3DEA157E3F22007B8D97 /* iOS@2x.png */, 1FBF3DEA157E3F22007B8D97 /* iOS@2x.png */,
Expand Down Expand Up @@ -404,6 +410,8 @@
1FBF3DEF157E3F22007B8D97 /* MacOS.png in Resources */, 1FBF3DEF157E3F22007B8D97 /* MacOS.png in Resources */,
1FBF3DF0157E3F22007B8D97 /* MacOS@2x.png in Resources */, 1FBF3DF0157E3F22007B8D97 /* MacOS@2x.png in Resources */,
1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */, 1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */,
1F747C1C1687D3B6006D2DFB /* Tick.png in Resources */,
1F747C1D1687D3B6006D2DFB /* Tick@2x.png in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
2 changes: 2 additions & 0 deletions Stash/STAAppDelegate.h
Expand Up @@ -24,6 +24,8 @@
@property (strong) STAPreferencesController *preferencesController; @property (strong) STAPreferencesController *preferencesController;
@property (weak) IBOutlet NSMatrix *searchMethodSelector; @property (weak) IBOutlet NSMatrix *searchMethodSelector;
@property (weak) IBOutlet NSSearchField *inPageSearchField; @property (weak) IBOutlet NSSearchField *inPageSearchField;
@property (weak) IBOutlet NSTableView *indexingDocsetsView;
@property (weak) IBOutlet NSScrollView *indexingDocsetsContainer;


- (IBAction)toggleStashWindow:(id)sender; - (IBAction)toggleStashWindow:(id)sender;
- (IBAction)search:(id)sender; - (IBAction)search:(id)sender;
Expand Down
164 changes: 114 additions & 50 deletions Stash/STAAppDelegate.m
Expand Up @@ -17,6 +17,7 @@


@interface STAAppDelegate () <NSWindowDelegate> @interface STAAppDelegate () <NSWindowDelegate>


@property (copy) NSArray *indexingDocsets;
@property (copy) NSArray *docsets; @property (copy) NSArray *docsets;
@property (copy) NSString *currentSearchString; @property (copy) NSString *currentSearchString;
@property (strong) NSMutableArray *results; @property (strong) NSMutableArray *results;
Expand All @@ -32,25 +33,23 @@ - (void)searchAgain:(BOOL)backwards;


@implementation STAAppDelegate @implementation STAAppDelegate
{ {
NSMutableArray *_indexingDocsets;
NSMutableArray *_docsets; NSMutableArray *_docsets;
dispatch_queue_t _docsetArrayEditingQueue;
} }


@synthesize window = _window; - (NSArray *)indexingDocsets
@synthesize statusMenu = _statusMenu; {
@synthesize openStashMenuItem = _openStashMenuItem; return [_indexingDocsets copy];
@synthesize statusItem = _statusItem; }
@synthesize resultsTable = _resultsTable;
@synthesize resultWebView = _resultWebView;
@synthesize titleView = _titleView;
@synthesize searchField = _searchField;
@synthesize preferencesController = _preferencesController;

@synthesize docsets = _docsets;
@synthesize currentSearchString = _currentSearchString;
@synthesize results = _results;
@synthesize sortedResults = _sortedResults;


@synthesize findUIShowing = _findUIShowing; - (void)setIndexingDocsets:(NSArray *)indexingDocsets
{
if (indexingDocsets != _indexingDocsets)
{
_indexingDocsets = [indexingDocsets mutableCopy];
}
}


- (NSArray *)docsets - (NSArray *)docsets
{ {
Expand All @@ -67,9 +66,11 @@ - (void)setDocsets:(NSArray *)docsets


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
_docsetArrayEditingQueue = dispatch_queue_create("org.beelsebob.Stash.docsetArrayEditing", DISPATCH_QUEUE_SERIAL);

[self setPreferencesController:[[STAPreferencesController alloc] initWithNibNamed:@"STAPreferencesController" bundle:nil]]; [self setPreferencesController:[[STAPreferencesController alloc] initWithNibNamed:@"STAPreferencesController" bundle:nil]];
[[self preferencesController] setDelegate:self]; [[self preferencesController] setDelegate:self];

STAIconShowingMode mode = [[self preferencesController] iconMode]; STAIconShowingMode mode = [[self preferencesController] iconMode];


if (mode == STAIconShowingModeBoth || mode == STAIconShowingModeMenuBar) if (mode == STAIconShowingModeBoth || mode == STAIconShowingModeMenuBar)
Expand Down Expand Up @@ -157,12 +158,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
[[self searchField] setEnabled:YES]; [[self searchField] setEnabled:YES];
[[self searchField] selectText:self]; [[self searchField] selectText:self];
[[self indexingDocsetsContainer] setHidden:YES];
[[self titleView] setStringValue:@""]; [[self titleView] setStringValue:@""];
}); });
}]; }];
}); });
} }


- (void)dealloc
{
dispatch_release(_docsetArrayEditingQueue);
}

- (void)showFindUI - (void)showFindUI
{ {
[[self window] makeFirstResponder:[self inPageSearchField]]; [[self window] makeFirstResponder:[self inPageSearchField]];
Expand Down Expand Up @@ -220,11 +227,14 @@ - (void)searchAgain:(BOOL)backwards
- (void)readDocsetsWithContinuation:(void(^)(void))cont - (void)readDocsetsWithContinuation:(void(^)(void))cont
{ {
[self setDocsets:@[]]; [self setDocsets:@[]];
[self setIndexingDocsets:@[]];


[self readExistingIndexes]; [self readExistingIndexes];
dispatch_async(dispatch_get_main_queue(), ^() dispatch_async(dispatch_get_main_queue(), ^()
{ {
[[self titleView] setStringValue:@"Stash is Indexing, Please Wait..."]; [[self titleView] setStringValue:@"Stash is Indexing, Please Wait..."];
[[self indexingDocsetsContainer] setHidden:NO];
[[self indexingDocsetsView] reloadData];
}); });
[self refreshExistingBookmarksWithContinuation:^() [self refreshExistingBookmarksWithContinuation:^()
{ {
Expand Down Expand Up @@ -341,8 +351,6 @@ - (void)indexDocsetsWithPermissionInRoots:(NSArray *)roots withContinuation:(voi
{ {
NSError *err; NSError *err;
BOOL isDir; BOOL isDir;
__block NSUInteger numDocsetsIndexing = 0;
__block NSUInteger numDocsetsIndexed = 0;
__block BOOL finishedSearchingForDocsets = NO; __block BOOL finishedSearchingForDocsets = NO;
for (NSURL *root in roots) for (NSURL *root in roots)
{ {
Expand All @@ -355,35 +363,56 @@ - (void)indexDocsetsWithPermissionInRoots:(NSArray *)roots withContinuation:(voi
if (docsetExists && isDir) if (docsetExists && isDir)
{ {
NSString *docsetCachePath = [[[self pathForArchive] stringByAppendingPathComponent:[docsetURL lastPathComponent]] stringByAppendingPathExtension:@"stashidx"]; NSString *docsetCachePath = [[[self pathForArchive] stringByAppendingPathComponent:[docsetURL lastPathComponent]] stringByAppendingPathExtension:@"stashidx"];
numDocsetsIndexing++;
STADocSet *indexedDocset = [STADocSet docSetWithURL:docsetURL STADocSet *docset = [STADocSet docSetWithURL:docsetURL
cachePath:docsetCachePath cachePath:docsetCachePath
onceIndexed:^(STADocSet *idx) onceIndexed:^(STADocSet *idx)
{ {
[NSKeyedArchiver archiveRootObject:idx toFile:docsetCachePath]; [NSKeyedArchiver archiveRootObject:idx toFile:docsetCachePath];
numDocsetsIndexed++; dispatch_sync(_docsetArrayEditingQueue, ^()
if (numDocsetsIndexed == numDocsetsIndexing && finishedSearchingForDocsets) {
{ [_indexingDocsets removeObjectIdenticalTo:idx];
cont(); [_docsets addObject:idx];
} dispatch_async(dispatch_get_main_queue(), ^()
}]; {
if (nil != indexedDocset) [[self indexingDocsetsView] reloadData];
});
if (finishedSearchingForDocsets && [_indexingDocsets count] == 0)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), cont);
}
});
}];
dispatch_sync(_docsetArrayEditingQueue, ^()
{
if ([_docsets indexOfObjectIdenticalTo:docset] == NSNotFound)
{
[_indexingDocsets addObject:docset];
}
});
if (nil != docset)
{ {
[[self preferencesController] registerDocset:indexedDocset]; [[self preferencesController] registerDocset:docset];
[_docsets addObject:indexedDocset]; if (![[[self preferencesController] enabledDocsets] containsObject:docset])
if (![[[self preferencesController] enabledDocsets] containsObject:indexedDocset])
{ {
[indexedDocset unload]; [docset unload];
} }
} }
} }
} }
} }
dispatch_async(dispatch_get_main_queue(), ^()
{
[[self indexingDocsetsView] reloadData];
});
finishedSearchingForDocsets = YES; finishedSearchingForDocsets = YES;
if (numDocsetsIndexed == numDocsetsIndexing) dispatch_sync(_docsetArrayEditingQueue, ^()
{ {
cont(); if (finishedSearchingForDocsets && [_indexingDocsets count] == 0)
} {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), cont);
}
});
} }


- (NSString *)pathForArchive - (NSString *)pathForArchive
Expand Down Expand Up @@ -525,12 +554,7 @@ - (IBAction)setSearchMethod:(id)sender
#pragma mark - Table View Data Source #pragma mark - Table View Data Source
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{ {
return [[self sortedResults] count]; return tableView == [self indexingDocsetsView] ? [[self docsets] count] + [[self indexingDocsets] count] : [[self sortedResults] count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
return row < [[self sortedResults] count] ? [[[self sortedResults] objectAtIndex:row] symbolName] : @"";
} }


- (void)tableViewSelectionDidChange:(NSNotification *)notification - (void)tableViewSelectionDidChange:(NSNotification *)notification
Expand All @@ -544,15 +568,55 @@ - (void)tableViewSelectionDidChange:(NSNotification *)notification
} }
} }


- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{ {
return [[STASymbolTableViewCell alloc] init]; if (tableView == [self resultsTable])
{
STASymbolTableViewCell *view = [[STASymbolTableViewCell alloc] initWithFrame:NSZeroRect];
[view setSymbolName:row < [[self sortedResults] count] ? [[[self sortedResults] objectAtIndex:row] symbolName] : @""];
[view setSymbolTypeImage:NSImageFromSTASymbolType([[[self sortedResults] objectAtIndex:row] symbolType])];
[view setPlatformImage:NSImageFromSTAPlatform([[[[self sortedResults] objectAtIndex:row] docSet] platform])];
return view;
}
else
{
NSArray *allDocsets = [[[self docsets] arrayByAddingObjectsFromArray:[self indexingDocsets]] sortedArrayUsingComparator:^ NSComparisonResult (STADocSet *d1, STADocSet *d2)
{
return [[d1 name] compare:[d2 name]];
}];
if ([[tableColumn identifier] isEqualToString:@"docset"])
{
NSTextField *textField = [[NSTextField alloc] initWithFrame:NSZeroRect];
[textField setEditable:NO];
[textField setSelectable:NO];
[textField setBordered:NO];
[textField setDrawsBackground:NO];
[textField setBezeled:NO];
[[textField cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[textField setStringValue:[[allDocsets objectAtIndex:row] name] ? : @""];
return textField;
}
else if ([[tableColumn identifier] isEqualToString:@"progress"] && [[self indexingDocsets] containsObject:[allDocsets objectAtIndex:row]])
{
NSProgressIndicator *twirler = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 16.0f, 16.0f)];
[twirler setStyle:NSProgressIndicatorSpinningStyle];
[twirler setControlSize:NSSmallControlSize];
[twirler startAnimation:self];
return twirler;
}
else
{
NSImageView *tick = [[NSImageView alloc] initWithFrame:NSZeroRect];
[tick setImage:[NSImage imageNamed:@"Tick"]];
return tick;
}
}
return nil;
} }


- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
{ {
[cell setSymbolTypeImage:NSImageFromSTASymbolType([[[self sortedResults] objectAtIndex:row] symbolType])]; return tableView == [self resultsTable];
[cell setPlatformImage:NSImageFromSTAPlatform([[[[self sortedResults] objectAtIndex:row] docSet] platform])];
} }


#pragma mark - Prefs Delegate #pragma mark - Prefs Delegate
Expand Down
7 changes: 4 additions & 3 deletions Stash/STASymbolTableViewCell.h
Expand Up @@ -8,9 +8,10 @@


#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>


@interface STASymbolTableViewCell : NSTextFieldCell @interface STASymbolTableViewCell : NSView


@property (strong) NSImage *symbolTypeImage; @property (strong,nonatomic) NSImage *symbolTypeImage;
@property (strong) NSImage *platformImage; @property (strong,nonatomic) NSImage *platformImage;
@property (copy ,nonatomic) NSString *symbolName;


@end @end

0 comments on commit 8719915

Please sign in to comment.