Abbreviate home directory in window titles.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35627 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2012-10-03 12:58:26 +00:00
parent 2f3297119b
commit 3e8bc54cd3
3 changed files with 35 additions and 39 deletions

View file

@ -1,3 +1,11 @@
2012-10-03 Wolfgang Lux <wolfgang.lux@gmail.com>
* 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 <wolfgang.lux@gmail.com>
* Source/NSCursor.m (+initialize, +pop, -push, -set): Fix memory

View file

@ -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.</p><p>See Also: -applicationIconImage</p>
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.</p><p>See Also: -applicationIconImage</p>
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;

View file

@ -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.<br />
}
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]];
}
}
}