Miniaturize all windows if the AppIcon is suppressed

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32740 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Germán Arias 2011-03-29 18:26:11 +00:00
parent cecdd28ed5
commit 2466b5cf58
2 changed files with 91 additions and 75 deletions

View file

@ -1,3 +1,8 @@
2011-03-29 German Arias <german@xelalug.org>
* Source/NSApplication.m (-hide:): Minimize all windows if
the AppIcon is suppressed.
2011-03-29 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTextStorage.m:

View file

@ -2429,89 +2429,100 @@ image.</p><p>See Also: -applicationIconImage</p>
#else
if (_app_is_hidden == NO)
{
NSArray *windows_list;
NSDictionary *info;
NSWindow *win;
NSEnumerator *iter;
[nc postNotificationName: NSApplicationWillHideNotification
object: self];
if ([self keyWindow] != nil)
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
// The main window is saved for when the app is activated again.
// This is necessary for menu in window.
if ([self mainWindow] != nil)
{
_hidden_main = [self mainWindow];
[_hidden_main resignMainWindow];
}
windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{
if ([win isVisible] == NO && ![win isMiniaturized])
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Not hideable */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
if (_app_is_active == YES && [win hidesOnDeactivate] == YES)
{
continue; /* Will be hidden by deactivation */
}
[_hidden addObject: win];
[win orderOut: self];
}
_app_is_hidden = YES;
if (YES == [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSSuppressAppIcon"])
if (![[NSUserDefaults standardUserDefaults]
boolForKey: @"GSSuppressAppIcon"])
{
#if MINI_ICON
NSRect f = [[[self mainMenu] window] frame];
NSPoint p = f.origin;
NSArray *windows_list;
NSDictionary *info;
NSWindow *win;
NSEnumerator *iter;
p.y += f.size.height;
[_app_icon_window setFrameTopLeftPoint: p];
[_app_icon_window orderFrontRegardless];
[_app_icon_window miniaturize: self];
[nc postNotificationName: NSApplicationWillHideNotification
object: self];
if ([self keyWindow] != nil)
{
_hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
}
// The main window is saved for when the app is activated again.
// This is necessary for menu in window.
if ([self mainWindow] != nil)
{
_hidden_main = [self mainWindow];
[_hidden_main resignMainWindow];
}
windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{
if ([win isVisible] == NO && ![win isMiniaturized])
{
continue; /* Already invisible */
}
if ([win canHide] == NO)
{
continue; /* Not hideable */
}
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
if (_app_is_active == YES && [win hidesOnDeactivate] == YES)
{
continue; /* Will be hidden by deactivation */
}
[_hidden addObject: win];
[win orderOut: self];
}
_app_is_hidden = YES;
if (YES == [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSSuppressAppIcon"])
{
#if MINI_ICON
NSRect f = [[[self mainMenu] window] frame];
NSPoint p = f.origin;
p.y += f.size.height;
[_app_icon_window setFrameTopLeftPoint: p];
[_app_icon_window orderFrontRegardless];
[_app_icon_window miniaturize: self];
#else
[_app_icon_window orderFrontRegardless];
[_app_icon_window orderFrontRegardless];
#endif
}
else
{
[[_app_icon_window contentView] setNeedsDisplay: YES];
}
/*
* On hiding we also deactivate the application which will make the menus
* go away too.
*/
[self deactivate];
_unhide_on_activation = YES;
info = [self _notificationUserInfo];
[nc postNotificationName: NSApplicationDidHideNotification
object: self
userInfo: info];
[[[NSWorkspace sharedWorkspace] notificationCenter]
postNotificationName: NSApplicationDidHideNotification
object: [NSWorkspace sharedWorkspace]
userInfo: info];
}
else
{
[[_app_icon_window contentView] setNeedsDisplay: YES];
/*Minimize all windows if there isn't an AppIcon. This isn't the
most elegant solution, but avoids to loss the app if the user
hide it. */
[self miniaturizeAll: sender];
}
/*
* On hiding we also deactivate the application which will make the menus
* go away too.
*/
[self deactivate];
_unhide_on_activation = YES;
info = [self _notificationUserInfo];
[nc postNotificationName: NSApplicationDidHideNotification
object: self
userInfo: info];
[[[NSWorkspace sharedWorkspace] notificationCenter]
postNotificationName: NSApplicationDidHideNotification
object: [NSWorkspace sharedWorkspace]
userInfo: info];
}
#endif
}