mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
improve menu loading
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29076 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
28e25fe2db
commit
0a106c8679
3 changed files with 57 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-11-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSNibLoading.m: Fix/improve handling of main menu to be
|
||||
more intelligent about moving the 'quit' item and 'info' submenu.
|
||||
|
||||
2009-11-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSplitView.m: Correct the storing of the splitter locations
|
||||
|
|
|
@ -147,22 +147,61 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
[[self window] setLevel: NSMainMenuWindowLevel];
|
||||
|
||||
// if it's a standard menu, transform it to be more NeXT'ish/GNUstep-like
|
||||
if(_menu.horizontal == NO)
|
||||
if (_menu.horizontal == NO)
|
||||
{
|
||||
NSString *infoString = NSLocalizedString (@"Info", @"Info");
|
||||
NSString *quitString = [NSString stringWithFormat: @"%@ %@",
|
||||
NSLocalizedString (@"Quit", @"Quit"), processName];
|
||||
NSMenuItem *quitItem = [[NSMenuItem alloc] initWithTitle: quitString
|
||||
action: @selector(terminate:)
|
||||
keyEquivalent: @"q"];
|
||||
NSMenuItem *appItem;
|
||||
SEL sel = @selector(terminate:);
|
||||
|
||||
appItem = (NSMenuItem*)[self itemAtIndex: 0]; // Info item.
|
||||
|
||||
[self addItem: quitItem];
|
||||
/* The title of the main menu should be the process name.
|
||||
*/
|
||||
[self setTitle: processName];
|
||||
[appItem setTitle: infoString];
|
||||
[[appItem submenu] setTitle: infoString];
|
||||
|
||||
/* If there is no 'quite' item (one which sends a -terminate:
|
||||
* actions) we add one.
|
||||
*/
|
||||
if ([self indexOfItemWithTarget: nil andAction: sel] < 0
|
||||
&& [self indexOfItemWithTarget: NSApp andAction: sel] < 0)
|
||||
{
|
||||
NSString *quitString;
|
||||
NSMenuItem *quitItem;
|
||||
|
||||
quitString = [NSString stringWithFormat: @"%@ %@",
|
||||
NSLocalizedString (@"Quit", @"Quit"), processName];
|
||||
quitItem = [[NSMenuItem alloc] initWithTitle: quitString
|
||||
action: @selector(terminate:)
|
||||
keyEquivalent: @"q"];
|
||||
[self addItem: quitItem];
|
||||
}
|
||||
|
||||
/* An OSX main menu has the first item named with the process name
|
||||
* and this item points to a submenu whose contents are much the
|
||||
* same as a GNUstep info menu.
|
||||
*/
|
||||
appItem = (NSMenuItem*)[self itemAtIndex: 0]; // Info item.
|
||||
if (YES == [[appItem title] isEqualToString: processName]
|
||||
&& [appItem submenu] != nil)
|
||||
{
|
||||
NSString *infoString;
|
||||
NSMenu *sub;
|
||||
NSInteger index;
|
||||
|
||||
infoString = NSLocalizedString (@"Info", @"Info");
|
||||
[appItem setTitle: infoString];
|
||||
sub = [appItem submenu];
|
||||
[sub setTitle: infoString];
|
||||
/* The submenu may contain a 'quit' item ... if so we need to
|
||||
* remove it as we already added one to the main menu.
|
||||
*/
|
||||
index = [sub indexOfItemWithTarget: nil andAction: sel];
|
||||
if (index < 0)
|
||||
{
|
||||
index = [sub indexOfItemWithTarget: NSApp andAction: sel];
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
[sub removeItemAtIndex: index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self _setGeometry];
|
||||
|
|
|
@ -892,7 +892,7 @@ static BOOL menuBarVisible = YES;
|
|||
if (actionSelector == 0 || sel_eq([menuItem action], actionSelector))
|
||||
{
|
||||
// There are different possibilities to implement the check here
|
||||
if ([menuItem target] == anObject)
|
||||
if ([menuItem target] == anObject)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue