diff --git a/ChangeLog b/ChangeLog
index eea83ab24..4ca956df7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-10-03 Wolfgang Lux
See Also: -applicationIconImage
if (found == NO) { - NSString *t = [aWindow title]; - NSString *f = [aWindow representedFilename]; - - f = [NSString stringWithFormat: @"%@ -- %@", - [f lastPathComponent], - [f stringByDeletingLastPathComponent]]; [self changeWindowsItem: aWindow - title: t - filename: [t isEqual: f]]; + title: [aWindow title] + filename: [aWindow _hasTitleWithRepresentedFilename]]; } } } @@ -3201,15 +3199,9 @@ image.See Also: -applicationIconImage
if (([win isExcludedFromWindowsMenu] == NO) && ([win isVisible] || [win isMiniaturized])) { - NSString *t = [win title]; - NSString *f = [win representedFilename]; - - f = [NSString stringWithFormat: @"%@ -- %@", - [f lastPathComponent], - [f stringByDeletingLastPathComponent]]; [self changeWindowsItem: win - title: t - filename: [t isEqual: f]]; + title: [win title] + filename: [win _hasTitleWithRepresentedFilename]]; } } } @@ -3867,8 +3859,7 @@ struct _DelegateWrapper [_listener application: self openFile: filePath]; } -- (id) _targetForAction: (SEL)aSelector - window: (NSWindow *)window +- (id) _targetForAction: (SEL)aSelector window: (NSWindow *)window { id resp, delegate; NSDocumentController *sdc; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index a3beb3f91..01911c8e0 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1273,12 +1273,25 @@ many times. } } +static NSString * +titleWithRepresentedFilename(NSString *representedFilename) +{ + return [NSString stringWithFormat: @"%@ -- %@", + [representedFilename lastPathComponent], + [[representedFilename stringByDeletingLastPathComponent] + stringByAbbreviatingWithTildeInPath]]; +} + +- (BOOL) _hasTitleWithRepresentedFilename +{ + NSString *aString = titleWithRepresentedFilename (_representedFilename); + return [_windowTitle isEqualToString: aString]; +} + - (void) setTitleWithRepresentedFilename: (NSString*)aString { [self setRepresentedFilename: aString]; - aString = [NSString stringWithFormat: - @"%@ -- %@", [aString lastPathComponent], - [aString stringByDeletingLastPathComponent]]; + aString = titleWithRepresentedFilename(aString); if ([_windowTitle isEqual: aString] == NO) { ASSIGNCOPY(_windowTitle, aString); @@ -1836,17 +1849,9 @@ many times. _f.has_opened = YES; if (_f.menu_exclude == NO) { - BOOL isFileName; - NSString *aString; - - aString = [NSString stringWithFormat: @"%@ -- %@", - [_representedFilename lastPathComponent], - [_representedFilename stringByDeletingLastPathComponent]]; - isFileName = [_windowTitle isEqual: aString]; - [NSApp addWindowsItem: self title: _windowTitle - filename: isFileName]; + filename: [self _hasTitleWithRepresentedFilename]]; } } if ([self isKeyWindow] == YES) @@ -4556,17 +4561,9 @@ current key view.