Find in folder window’s title could switch to “Untitled”

This is because we are using an NSDocument to perform the folder searching (as that’s a decoupled way to have the window indicate “unsaved changes” and present a warning sheet).

The downside is that by using an NSDocument we get some undesired implicit behavior, like automatically changing the window title or trying to re-open the “document” after relaunch.
This commit is contained in:
Allan Odgaard
2014-03-08 10:08:36 +07:00
parent a4ad676c37
commit bf4e1d8cee

View File

@@ -182,7 +182,7 @@ static NSButton* OakCreateStopSearchButton ()
NSRect r = [[NSScreen mainScreen] visibleFrame];
if((self = [super initWithWindow:[[NSPanel alloc] initWithContentRect:NSMakeRect(NSMidX(r)-100, NSMidY(r)+100, 200, 200) styleMask:(NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask) backing:NSBackingStoreBuffered defer:NO]]))
{
self.window.title = @"Find";
self.window.title = [self windowTitleForDocumentDisplayName:nil];
self.window.frameAutosaveName = @"Find";
self.window.hidesOnDeactivate = NO;
self.window.collectionBehavior = NSWindowCollectionBehaviorMoveToActiveSpace|NSWindowCollectionBehaviorFullScreenAuxiliary;
@@ -499,6 +499,11 @@ static NSButton* OakCreateStopSearchButton ()
}
}
- (NSString*)windowTitleForDocumentDisplayName:(NSString*)aString
{
return self.searchFolder ? [NSString localizedStringWithFormat:MSG_FIND_IN_FOLDER_WINDOW_TITLE, [self.searchFolder stringByAbbreviatingWithTildeInPath]] : MSG_WINDOW_TITLE;
}
- (void)showWindow:(id)sender
{
if([self isWindowLoaded] && ![self.window isVisible])
@@ -817,7 +822,7 @@ static NSButton* OakCreateStopSearchButton ()
_searchIn = aString;
self.folderSearch = self.searchFolder != nil;
self.window.title = self.searchFolder ? [NSString localizedStringWithFormat:MSG_FIND_IN_FOLDER_WINDOW_TITLE, [self.searchFolder stringByAbbreviatingWithTildeInPath]] : MSG_WINDOW_TITLE;
self.window.title = [self windowTitleForDocumentDisplayName:nil];
if(NSString* folder = self.searchFolder)
[self.recentFolders addObject:folder];
[self updateSearchInPopUpMenu];