diff --git a/ChangeLog b/ChangeLog index eea83ab24..4ca956df7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-10-03 Wolfgang Lux + + * Source/NSWindow.m (titleWithRepresentedFilename, + -_hasTitleWithRepresentedFilename, -setTitleWithRepresentedFilename, + -orderWindow:relativeTo:, -setExcludedFromWindowsMenu:): + * Source/NSApplication.m (-updateWindowsItem:, -setWindowsMenu:): + Abbreviate home directory in window titles. + 2012-09-21 Wolfgang Lux * Source/NSCursor.m (+initialize, +pop, -push, -set): Fix memory diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 15ce1b840..0a001e732 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -383,6 +383,10 @@ struct _NSModalSession { - (NSMenu *) _dockMenu; @end +@interface NSWindow (TitleWithRepresentedFilename) +- (BOOL) _hasTitleWithRepresentedFilename; +@end + @interface NSWindow (ApplicationPrivate) - (void) setAttachedSheet: (id) sheet; @end @@ -3141,15 +3145,9 @@ image.

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.
} else if (_f.has_opened == YES && flag == 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]]; } } }