mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 10:01:14 +00:00
Create an undo manager for a window when necessary.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27621 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
12ffaa698c
commit
b1496f3b3e
2 changed files with 33 additions and 18 deletions
|
@ -3,6 +3,9 @@
|
|||
* Source/NSDocument.m (-windowForSheet): Return nil if the
|
||||
document has no window controllers.
|
||||
|
||||
* Source/NSWindow.m (-undoManager, -dealloc): Create an undo
|
||||
manager for a window when necessary.
|
||||
|
||||
2009-01-16 12:04-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSMenuItem.m: Retain the GSMenuSeparator instance if
|
||||
|
|
|
@ -597,7 +597,8 @@ static IMP ctImp;
|
|||
static Class responderClass;
|
||||
static Class viewClass;
|
||||
static NSMutableSet *autosaveNames;
|
||||
static NSMapTable* windowmaps = NULL;
|
||||
static NSMapTable *windowmaps = NULL;
|
||||
static NSMapTable *windowUndoManagers = NULL;
|
||||
static NSNotificationCenter *nc = nil;
|
||||
|
||||
/*
|
||||
|
@ -738,6 +739,9 @@ many times.
|
|||
NSAssert([NSApp keyWindow] != self, @"window being deallocated is key");
|
||||
NSAssert([NSApp mainWindow] != self, @"window being deallocated is main");
|
||||
|
||||
if (windowUndoManagers != NULL)
|
||||
NSMapRemove(windowUndoManagers, self);
|
||||
|
||||
if (_autosaveName != nil)
|
||||
{
|
||||
[autosaveNames removeObject: _autosaveName];
|
||||
|
@ -2939,33 +2943,41 @@ resetCursorRectsForView(NSView *theView)
|
|||
}
|
||||
|
||||
/**
|
||||
Get a undo manager from the delegate or create one.
|
||||
Get an undo manager from the delegate or create one.
|
||||
*/
|
||||
- (NSUndoManager*) undoManager
|
||||
{
|
||||
NSUndoManager *undo;
|
||||
NSUndoManager *undo = nil;
|
||||
|
||||
if ([_delegate respondsToSelector: @selector(windowWillReturnUndoManager:)])
|
||||
{
|
||||
return [_delegate windowWillReturnUndoManager: self];
|
||||
undo = [_delegate windowWillReturnUndoManager: self];
|
||||
}
|
||||
else
|
||||
else if (_windowController)
|
||||
{
|
||||
// FIXME: This is more a hack to get an undo manager.
|
||||
if (_windowController)
|
||||
{
|
||||
NSDocument *document = [_windowController document];
|
||||
NSDocument *document = [_windowController document];
|
||||
|
||||
if (document && (undo = [document undoManager]) != nil)
|
||||
{
|
||||
return undo;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: We should reuse the same undo manager all the time!!!
|
||||
//return AUTORELEASE([[NSUndoManager alloc] init]);
|
||||
return nil;
|
||||
if (document)
|
||||
undo = [document undoManager];
|
||||
}
|
||||
|
||||
if (undo == nil)
|
||||
{
|
||||
if (windowUndoManagers == NULL)
|
||||
windowUndoManagers =
|
||||
NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
else
|
||||
undo = NSMapGet(windowUndoManagers, self);
|
||||
|
||||
if (undo == nil)
|
||||
{
|
||||
undo = [[NSUndoManager alloc] init];
|
||||
NSMapInsertKnownAbsent(windowUndoManagers, self, undo);
|
||||
[undo release];
|
||||
}
|
||||
}
|
||||
return undo;
|
||||
}
|
||||
|
||||
- (void) undo: (id)sender
|
||||
|
|
Loading…
Reference in a new issue