mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-03 21:31:00 +00:00
OSX compatibility fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27974 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8b5ee69ee1
commit
41f06e267c
2 changed files with 69 additions and 41 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2009-02-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSUndoManager.m: Revert last change (to match OSX 10.5)
|
||||||
|
Also rework a little to recreate undocumented OSX behavior of
|
||||||
|
implicitly creating a top-level undo group if -beginUndoGroup
|
||||||
|
is called for a manager configured with groupByEvent.
|
||||||
|
|
||||||
2009-02-23 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-02-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSIndexPath.m:
|
* Source/NSIndexPath.m:
|
||||||
|
|
|
@ -156,10 +156,45 @@
|
||||||
* Private category for the method used to handle default grouping
|
* Private category for the method used to handle default grouping
|
||||||
*/
|
*/
|
||||||
@interface NSUndoManager (Private)
|
@interface NSUndoManager (Private)
|
||||||
|
- (void) _begin;
|
||||||
- (void) _loop: (id)arg;
|
- (void) _loop: (id)arg;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSUndoManager (Private)
|
@implementation NSUndoManager (Private)
|
||||||
|
/* This method is used to begin undo grouping internally.
|
||||||
|
* It's necessary to have a different mechanism from the -beginUndoGroup
|
||||||
|
* because it seems that in MacOS-X 10.5 a call to -beginUndoGroup when
|
||||||
|
* at the top level will actually create two undo groups.
|
||||||
|
*/
|
||||||
|
- (void) _begin
|
||||||
|
{
|
||||||
|
PrivateUndoGroup *parent;
|
||||||
|
|
||||||
|
parent = (PrivateUndoGroup*)_group;
|
||||||
|
_group = [[PrivateUndoGroup alloc] initWithParent: parent];
|
||||||
|
if (_group == nil)
|
||||||
|
{
|
||||||
|
_group = parent;
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"beginUndoGrouping failed to greate group"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RELEASE(parent);
|
||||||
|
|
||||||
|
if (_isUndoing == NO && _isRedoing == NO)
|
||||||
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
postNotificationName: NSUndoManagerDidOpenUndoGroupNotification
|
||||||
|
object: self];
|
||||||
|
}
|
||||||
|
if (_isUndoing == NO)
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
postNotificationName: NSUndoManagerCheckpointNotification
|
||||||
|
object: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) _loop: (id)arg
|
- (void) _loop: (id)arg
|
||||||
{
|
{
|
||||||
if (_groupsByEvent && _group != nil)
|
if (_groupsByEvent && _group != nil)
|
||||||
|
@ -187,39 +222,25 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new grouping of undo actions which can be
|
* Starts a new grouping of undo actions which can be
|
||||||
* atomically undone by an [-undo] invocation.
|
* atomically undone by an [-undo] invocation.<br />
|
||||||
* This method posts an NSUndoManagerCheckpointNotification
|
* This method posts an NSUndoManagerDidOpenUndoGroupNotification
|
||||||
* unless an undo is currently in progress or this is begiinng a
|
* upon creating the grouping.<br />
|
||||||
* top level group. It posts an
|
* It then posts an NSUndoManagerCheckpointNotification
|
||||||
* NSUndoManagerDidOpenUndoGroupNotification upon creating the grouping.
|
* unless an undo is currently in progress.<br />
|
||||||
|
* The order of these notifications is undefined, but the GNUstep
|
||||||
|
* implementation currently mimics the observed order in MacOS-X 10.5
|
||||||
*/
|
*/
|
||||||
- (void) beginUndoGrouping
|
- (void) beginUndoGrouping
|
||||||
{
|
{
|
||||||
PrivateUndoGroup *parent;
|
/* It seems that MacOS-X 10.5 implicitly creates a top-level group
|
||||||
|
* if this method is called when groupsbyEvent is set and there is
|
||||||
if (_isUndoing == NO && _group != nil)
|
* no existing top level group.
|
||||||
|
*/
|
||||||
|
if (_group == nil && [self groupsByEvent])
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter]
|
[self _begin]; // Start top level group
|
||||||
postNotificationName: NSUndoManagerCheckpointNotification
|
|
||||||
object: self];
|
|
||||||
}
|
|
||||||
parent = (PrivateUndoGroup*)_group;
|
|
||||||
_group = [[PrivateUndoGroup alloc] initWithParent: parent];
|
|
||||||
if (_group == nil)
|
|
||||||
{
|
|
||||||
_group = parent;
|
|
||||||
[NSException raise: NSInternalInconsistencyException
|
|
||||||
format: @"beginUndoGrouping failed to greate group"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RELEASE(parent);
|
|
||||||
|
|
||||||
if (_isUndoing == NO && _isRedoing == NO)
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
postNotificationName: NSUndoManagerDidOpenUndoGroupNotification
|
|
||||||
object: self];
|
|
||||||
}
|
}
|
||||||
|
[self _begin]; // Start a new group
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -421,7 +442,7 @@
|
||||||
{
|
{
|
||||||
if ([self groupsByEvent])
|
if ([self groupsByEvent])
|
||||||
{
|
{
|
||||||
[self beginUndoGrouping];
|
[self _begin];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -720,7 +741,7 @@
|
||||||
{
|
{
|
||||||
if ([self groupsByEvent])
|
if ([self groupsByEvent])
|
||||||
{
|
{
|
||||||
[self beginUndoGrouping];
|
[self _begin];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -882,17 +903,17 @@
|
||||||
{
|
{
|
||||||
ASSIGN(_modes, newModes);
|
ASSIGN(_modes, newModes);
|
||||||
if (_runLoopGroupingPending)
|
if (_runLoopGroupingPending)
|
||||||
{
|
{
|
||||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||||
[runLoop cancelPerformSelector: @selector(_loop:)
|
[runLoop cancelPerformSelector: @selector(_loop:)
|
||||||
target: self
|
target: self
|
||||||
argument: nil];
|
argument: nil];
|
||||||
[runLoop performSelector: @selector(_loop:)
|
[runLoop performSelector: @selector(_loop:)
|
||||||
target: self
|
target: self
|
||||||
argument: nil
|
argument: nil
|
||||||
order: NSUndoCloseGroupingRunLoopOrdering
|
order: NSUndoCloseGroupingRunLoopOrdering
|
||||||
modes: _modes];
|
modes: _modes];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue