mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add a private name attribute to menus to identify special purpose
menus. Fixes a bug where the services, windows, and recent documents menu were defunct when loading the menu from a .nib file. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30363 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e0d603b2ae
commit
14b0075299
3 changed files with 78 additions and 5 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,9 +1,18 @@
|
|||
2010-05-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSMenu.h:
|
||||
* Source/NSMenu.m (-_initWithCoder:, -dealloc, -_name,
|
||||
-_setName:, -awakeFromNib): Add a private name attribute to menus
|
||||
to identify special purpose menus. Fixes a bug where the services,
|
||||
windows, and recent documents menu were defunct when loading the
|
||||
menu from a .nib file.
|
||||
|
||||
2010-05-12 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSDocumentController.h:
|
||||
* Source/NSDocumentFrameworkPrivate.h:
|
||||
* Source/NSDocumentFrameworkPrivate.h:
|
||||
* Source/NSDocumentController.m (-_recentDocumentsMenu,
|
||||
-_setRecentDocumentsMenu:, -_updateRecentDocumentsMenu):
|
||||
-_setRecentDocumentsMenu:, -_updateRecentDocumentsMenu):
|
||||
Add an attribute to NSDocumentController to maintain the recent
|
||||
documents menu. Make the methods to access that menu available to
|
||||
other classes in -gui.
|
||||
|
|
|
@ -336,18 +336,18 @@
|
|||
NSMenu *_superMenu;
|
||||
NSMenu *_attachedMenu;
|
||||
NSMutableArray *_notifications;
|
||||
id _delegate;
|
||||
id _delegate;
|
||||
|
||||
// GNUstepExtra category
|
||||
NSPopUpButtonCell *_popUpButtonCell;
|
||||
struct GSMenuFlags {
|
||||
struct GSMenuFlags {
|
||||
unsigned int changedMessagesEnabled: 1;
|
||||
unsigned int autoenable: 1;
|
||||
unsigned int needsSizing: 1;
|
||||
unsigned int is_tornoff: 1;
|
||||
unsigned int transient: 1;
|
||||
unsigned int horizontal: 1;
|
||||
unsigned int mainMenuChanged: 1;
|
||||
unsigned int mainMenuChanged: 1;
|
||||
unsigned int unused: 25;
|
||||
} _menu;
|
||||
|
||||
|
@ -356,6 +356,7 @@
|
|||
NSWindow *_bWindow;
|
||||
NSMenu *_oldAttachedMenu;
|
||||
int _oldHiglightedIndex;
|
||||
NSString *_name;
|
||||
}
|
||||
|
||||
/** Returns the memory allocation zone used to create instances of this class.
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#import "AppKit/NSAttributedString.h"
|
||||
|
||||
#import "GSGuiPrivate.h"
|
||||
#import "NSDocumentFrameworkPrivate.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
|
||||
/*
|
||||
|
@ -132,6 +133,8 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
@interface NSMenu (GNUstepPrivate)
|
||||
|
||||
- (NSString *) _name;
|
||||
- (void) _setName: (NSString *)name;
|
||||
- (NSMenuPanel *) _createWindow;
|
||||
- (NSString *) _locationKey;
|
||||
- (void) _rightMouseDisplay: (NSEvent*)theEvent;
|
||||
|
@ -172,6 +175,16 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
@implementation NSMenu (GNUstepPrivate)
|
||||
|
||||
- (NSString *) _name;
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
- (void) _setName: (NSString *)aName
|
||||
{
|
||||
ASSIGNCOPY(_name, aName);
|
||||
}
|
||||
|
||||
- (NSString*) _locationKey
|
||||
{
|
||||
NSInterfaceStyle style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
|
||||
|
@ -608,6 +621,7 @@ static BOOL menuBarVisible = YES;
|
|||
RELEASE(_view);
|
||||
RELEASE(_aWindow);
|
||||
RELEASE(_bWindow);
|
||||
RELEASE(_name);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -1566,6 +1580,7 @@ static BOOL menuBarVisible = YES;
|
|||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
NSString *dTitle;
|
||||
NSString *dName;
|
||||
NSArray *dItems;
|
||||
BOOL dAuto;
|
||||
unsigned i;
|
||||
|
@ -1588,15 +1603,28 @@ static BOOL menuBarVisible = YES;
|
|||
}
|
||||
dTitle = [aDecoder decodeObjectForKey: @"NSTitle"];
|
||||
dItems = [aDecoder decodeObjectForKey: @"NSMenuItems"];
|
||||
if ([aDecoder containsValueForKey: @"NSName"])
|
||||
{
|
||||
dName = [aDecoder decodeObjectForKey: @"NSName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
dName = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dTitle = [aDecoder decodeObject];
|
||||
dItems = [aDecoder decodeObject];
|
||||
dName = nil;
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dAuto];
|
||||
}
|
||||
self = [self initWithTitle: dTitle];
|
||||
[self setAutoenablesItems: dAuto];
|
||||
if (dName)
|
||||
{
|
||||
ASSIGN(_name, dName);
|
||||
}
|
||||
|
||||
[self setMenuChangedMessagesEnabled: NO];
|
||||
/*
|
||||
|
@ -1612,6 +1640,41 @@ static BOOL menuBarVisible = YES;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
NSString *name = [self _name];
|
||||
|
||||
if (name)
|
||||
{
|
||||
if ([name isEqualToString: @"_NSMainMenu"])
|
||||
{
|
||||
// NB This is already handled by the nib loading code
|
||||
//[NSApp setMainMenu: self];
|
||||
}
|
||||
else if ([name isEqualToString: @"_NSAppleMenu"])
|
||||
{
|
||||
// GNUstep does not handle Apple's application menu specially
|
||||
}
|
||||
else if ([name isEqualToString: @"_NSWindowsMenu"])
|
||||
{
|
||||
[NSApp setWindowsMenu: self];
|
||||
}
|
||||
else if ([name isEqualToString: @"_NSServicesMenu"])
|
||||
{
|
||||
[NSApp setServicesMenu: self];
|
||||
}
|
||||
else if ([name isEqualToString: @"_NSRecentDocumentsMenu"])
|
||||
{
|
||||
[[NSDocumentController sharedDocumentController]
|
||||
_setRecentDocumentsMenu: self];
|
||||
}
|
||||
else if ([name isEqualToString: @"_NSFontMenu"])
|
||||
{
|
||||
[[NSFontManager sharedFontManager] setFontMenu: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* NSCopying Protocol
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue