mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 16:10:37 +00:00
Merge GUI with trunk revision 40072
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@40119 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3b3388e8ad
commit
a1d62943a6
15 changed files with 508 additions and 180 deletions
|
@ -505,14 +505,11 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
}
|
||||
|
||||
[self addDocument: document];
|
||||
if ([self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
if (display)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
@ -520,7 +517,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
/**
|
||||
* Creates an [NSDocument] object from the data at the absolute path
|
||||
* given in fileName. Causes the document to be displayed if display
|
||||
* is YES, unless the -shouldCreateUI method returns NO.
|
||||
* is YES.
|
||||
*/
|
||||
- (id) openDocumentWithContentsOfFile: (NSString*)fileName
|
||||
display: (BOOL)display
|
||||
|
@ -540,7 +537,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
|
||||
[self addDocument: document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
}
|
||||
|
@ -549,7 +546,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
// remember this document as opened
|
||||
[self noteNewRecentDocument: document];
|
||||
|
||||
if (display && [self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
|
@ -560,7 +557,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
/**
|
||||
* Creates an [NSDocument] object from the data at the supplied url.<br />
|
||||
* Causes the document to be displayed if display
|
||||
* is YES, unless the -shouldCreateUI method returns NO.
|
||||
* is YES.
|
||||
*/
|
||||
- (id) openDocumentWithContentsOfURL: (NSURL *)url display: (BOOL)display
|
||||
{
|
||||
|
@ -579,7 +576,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
|
||||
[self addDocument: document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
}
|
||||
|
@ -588,7 +585,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
// remember this document as opened
|
||||
[self noteNewRecentDocument: document];
|
||||
|
||||
if (display && [self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
|
@ -596,7 +593,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
return document;
|
||||
}
|
||||
|
||||
- (id) openUntitledDocumentAndDisplay: (BOOL)flag
|
||||
- (id) openUntitledDocumentAndDisplay: (BOOL)display
|
||||
error: (NSError **)err
|
||||
{
|
||||
NSString *type;
|
||||
|
@ -605,7 +602,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
|
||||
if (OVERRIDDEN(openUntitledDocumentOfType:display:))
|
||||
{
|
||||
return [self openUntitledDocumentOfType: type display: flag];
|
||||
return [self openUntitledDocumentOfType: type display: display];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -618,27 +615,24 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
}
|
||||
|
||||
[self addDocument: document];
|
||||
if ([self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
if (flag)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) openDocumentWithContentsOfURL: (NSURL *)url
|
||||
display: (BOOL)flag
|
||||
display: (BOOL)display
|
||||
error: (NSError **)err
|
||||
{
|
||||
if (OVERRIDDEN(openDocumentWithContentsOfFile:display:) && [url isFileURL])
|
||||
{
|
||||
return [self openDocumentWithContentsOfFile: [url path]
|
||||
display: flag];
|
||||
display: display];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -664,7 +658,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
|
||||
[self addDocument: document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
}
|
||||
|
@ -673,7 +667,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
// remember this document as opened
|
||||
[self noteNewRecentDocument: document];
|
||||
|
||||
if (flag && [self shouldCreateUI])
|
||||
if (display)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
|
@ -682,6 +676,77 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) openDocumentWithContentsOfURL: (NSURL*)url
|
||||
display: (BOOL)display
|
||||
completionHandler: (GSCompletionBlock1)completionHandler
|
||||
{
|
||||
NSError *err = nil;
|
||||
BOOL existing = NO;
|
||||
|
||||
if (OVERRIDDEN(openDocumentWithContentsOfURL:display:error:))
|
||||
{
|
||||
NSDocument *document = [self openDocumentWithContentsOfURL: url
|
||||
display: display
|
||||
error: &err];
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OVERRIDDEN(openDocumentWithContentsOfFile:display:) && [url isFileURL])
|
||||
{
|
||||
NSDocument *document = [self openDocumentWithContentsOfFile: [url path]
|
||||
display: display];
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDocument *document = [self documentForURL: url];
|
||||
|
||||
if (document == nil)
|
||||
{
|
||||
NSString *type = [self typeForContentsOfURL: url error: &err];
|
||||
|
||||
if (type == nil)
|
||||
{
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
return;
|
||||
}
|
||||
|
||||
document = [self makeDocumentWithContentsOfURL: url
|
||||
ofType: type
|
||||
error: &err];
|
||||
|
||||
if (document == nil)
|
||||
{
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
return;
|
||||
}
|
||||
|
||||
[self addDocument: document];
|
||||
|
||||
if (display)
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existing = YES;
|
||||
}
|
||||
|
||||
// remember this document as opened
|
||||
[self noteNewRecentDocument: document];
|
||||
|
||||
if (display)
|
||||
{
|
||||
[document showWindows];
|
||||
}
|
||||
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) reopenDocumentForURL: (NSURL *)url
|
||||
withContentsOfURL: (NSURL *)contents
|
||||
error: (NSError **)err
|
||||
|
@ -712,6 +777,53 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void) reopenDocumentForURL: (NSURL*)url
|
||||
withContentsOfURL: (NSURL*)contents
|
||||
display: (BOOL)display
|
||||
completionHandler: (GSCompletionBlock1)completionHandler
|
||||
{
|
||||
NSError *err = nil;
|
||||
BOOL existing = NO;
|
||||
|
||||
if (OVERRIDDEN(reopenDocumentForURL:withContentsOfURL:error:))
|
||||
{
|
||||
[self reopenDocumentForURL: url
|
||||
withContentsOfURL: contents
|
||||
error: &err];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDocument *document = nil;
|
||||
NSString *type = [self typeForContentsOfURL: contents error: &err];
|
||||
|
||||
if (type == nil)
|
||||
{
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
return;
|
||||
}
|
||||
|
||||
document = [self makeDocumentForURL: url
|
||||
withContentsOfURL: contents
|
||||
ofType: type
|
||||
error: &err];
|
||||
if (document)
|
||||
{
|
||||
[self addDocument:document];
|
||||
|
||||
// remember this document as opened
|
||||
[self noteNewRecentDocument: document];
|
||||
|
||||
if ([self shouldCreateUI])
|
||||
{
|
||||
[document makeWindowControllers];
|
||||
[document showWindows];
|
||||
}
|
||||
}
|
||||
|
||||
CALL_BLOCK(completionHandler, document, existing, err);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSOpenPanel *) _setupOpenPanel
|
||||
{
|
||||
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
||||
|
@ -783,6 +895,50 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void) beginOpenPanelWithCompletionHandler: (GSCompletionBlock2)completionHandler
|
||||
{
|
||||
if (OVERRIDDEN(URLsFromRunningOpenPanel) || OVERRIDDEN(runModalOpenPanel:forTypes:))
|
||||
{
|
||||
NSArray *urls = [self URLsFromRunningOpenPanel];
|
||||
CALL_BLOCK(completionHandler, urls);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if __has_feature(blocks)
|
||||
NSArray *types = [self _openableFileExtensions];
|
||||
__block NSOpenPanel *openPanel = [self _setupOpenPanel];
|
||||
__block GSCompletionBlock2 ch = completionHandler;
|
||||
|
||||
GSCompletionBlock3 block =
|
||||
^(NSInteger result)
|
||||
{
|
||||
if (result == NSOKButton)
|
||||
{
|
||||
CALL_BLOCK(ch, [openPanel URLs]);
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL_BLOCK(ch, nil);
|
||||
}
|
||||
};
|
||||
[self beginOpenPanel: openPanel forTypes: types completionHandler: block];
|
||||
#else
|
||||
NSArray *urls = [self URLsFromRunningOpenPanel];
|
||||
CALL_BLOCK(completionHandler, urls);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void) beginOpenPanel: (NSOpenPanel*)openPanel
|
||||
forTypes: (NSArray*)types
|
||||
completionHandler: (GSCompletionBlock3)completionHandler
|
||||
{
|
||||
// FIXME
|
||||
NSInteger result = [self runModalOpenPanel: openPanel forTypes: types];
|
||||
CALL_BLOCK(completionHandler, result);
|
||||
}
|
||||
|
||||
- (IBAction) saveAllDocuments: (id)sender
|
||||
{
|
||||
NSDocument *document;
|
||||
|
@ -806,11 +962,25 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
urlEnum = [[self URLsFromRunningOpenPanel] objectEnumerator];
|
||||
while ((url = [urlEnum nextObject]))
|
||||
{
|
||||
#if __has_feature(blocks)
|
||||
GSCompletionBlock1 block =
|
||||
^(NSDocument *document, BOOL existing, NSError *err)
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
[self presentError: err];
|
||||
}
|
||||
};
|
||||
[self openDocumentWithContentsOfURL: url display: YES completionHandler: block];
|
||||
#else
|
||||
// FIXME: Should be calling openDocumentWithContentsOfURL:display:completionHandler:
|
||||
// but this requires Block support
|
||||
[self openDocumentWithContentsOfURL: url display: YES error: &err];
|
||||
if (err && ![self presentError: err])
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -980,6 +1150,14 @@ static BOOL _shouldClose = YES;
|
|||
nil);
|
||||
}
|
||||
|
||||
- (id) duplicateDocumentWithContentsOfURL: (NSURL*)url
|
||||
copying: (BOOL)duplicateByCopying
|
||||
displayName: (NSString*)displayNameOrNil
|
||||
error: (NSError**)outError
|
||||
{
|
||||
// FIXME: Implementation missing
|
||||
return nil;
|
||||
}
|
||||
|
||||
#ifdef OPENSTEP_ONLY
|
||||
/*
|
||||
|
@ -1727,11 +1905,8 @@ static NSString *processName = nil;
|
|||
|
||||
[self openDocumentWithContentsOfURL: url display: YES error: &err];
|
||||
if (err)
|
||||
{
|
||||
[self presentError: err];
|
||||
[self _updateRecentDocumentsMenu];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _saveRecentDocuments
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue