mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-14 02:33:50 +00:00
Cleanuped up open/save panel.
Reviewed by me.
This commit is contained in:
1 parent
4a8a205ae2
commit
fce91c7ad3
4 files changed
+31
-88
No files matched your search
+1
-1
@@ -791,7 +791,7 @@ var CPDocumentUntitledCount = 0;
|
||||
if (!response)
|
||||
return;
|
||||
|
||||
var saveURL = [savePanel filename];
|
||||
var saveURL = [savePanel URL];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPDocumentWillSaveNotification
|
||||
|
||||
@@ -223,15 +223,15 @@ var CPSharedDocumentController = nil;
|
||||
-(void)openDocument:(id)aSender
|
||||
{
|
||||
var openPanel = [CPOpenPanel openPanel];
|
||||
|
||||
[openPanel runModalForTypes:nil];//[@"nib", @"xib", @"cib"]];
|
||||
|
||||
var filenames = [openPanel filenames],
|
||||
|
||||
[openPanel runModal];
|
||||
|
||||
var URLs = [openPanel URLs],
|
||||
index = 0,
|
||||
count = [filenames count];
|
||||
count = [URLs count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
[self openDocumentWithContentsOfURL:[CPURL URLWithString:filenames[index]] display:YES error:nil];
|
||||
[self openDocumentWithContentsOfURL:[CPURL URLWithString:URLs[index]] display:YES error:nil];
|
||||
}
|
||||
|
||||
// Managing Documents
|
||||
|
||||
+18
-61
@@ -5,7 +5,11 @@
|
||||
|
||||
@implementation CPOpenPanel : CPPanel
|
||||
{
|
||||
JSObject _openPanel;
|
||||
BOOL _canChooseFiles @accessors(property=canChooseFiles);
|
||||
BOOL _canChooseDirectories @accessors(property=canChooseDirectories);
|
||||
BOOL _allowsMultipleSelection @accessors(property=allowsMultipleSelection);
|
||||
CPURL _directoryURL @accessors(property=directoryURL);
|
||||
CPArray _URLs;
|
||||
}
|
||||
|
||||
+ (id)openPanel
|
||||
@@ -13,73 +17,26 @@
|
||||
return [[CPOpenPanel alloc] init];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
_openPanel = window.application.createOpenPanel();
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)canChooseFiles
|
||||
{
|
||||
return _openPanel.canChooseFiles;
|
||||
}
|
||||
|
||||
- (void)setCanChooseFiles:(BOOL)shouldChooseFiles
|
||||
{
|
||||
_openPanel.canChooseFiles = shouldChooseFiles;
|
||||
}
|
||||
|
||||
- (BOOL)canChooseDirectories
|
||||
{
|
||||
return _openPanel.canChooseDirectories;
|
||||
}
|
||||
|
||||
- (void)setCanChooseDirectories:(BOOL)shouldChooseDirectories
|
||||
{
|
||||
_openPanel.canChooseDirectories = shouldChooseDirectories;
|
||||
}
|
||||
|
||||
- (BOOL)resolvesAliases
|
||||
{
|
||||
return _openPanel.resolvesAliases;
|
||||
}
|
||||
|
||||
- (BOOL)setResolvesAliases:(BOOL)shouldResolveAliases
|
||||
{
|
||||
return _openPanel.resolvesAliases = shouldResolveAliases;
|
||||
}
|
||||
|
||||
- (BOOL)allowsMultipleSelections
|
||||
{
|
||||
return _openPanel.resolvesAliases;
|
||||
}
|
||||
|
||||
- (BOOL)setAllowsMultipleSelections:(BOOL)shouldAllowMultipleSelection
|
||||
{
|
||||
return _openPanel.allowsMultipleSelection = shouldAllowMultipleSelection;
|
||||
}
|
||||
|
||||
- (void)filenames
|
||||
{
|
||||
return _openPanel.filenames;
|
||||
}
|
||||
|
||||
- (CPInteger)runModalForDirectory:(CPString)anAbsoluteDirectoryPath file:(CPString)aFilename types:(CPArray)fileTypes
|
||||
- (CPInteger)runModal
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _openPanel.runModal(anAbsoluteDirectoryPath, aFilename, fileTypes);
|
||||
var options = { directoryURL: [self directoryURL],
|
||||
canChooseFiles: [self canChooseFiles],
|
||||
canChooseDirectories: [self canChooseDirectories],
|
||||
allowsMultipleSelection: [self allowsMultipleSelection] };
|
||||
|
||||
var result = window.cpOpenPanel(options);
|
||||
|
||||
_URLs = result.URLs;
|
||||
|
||||
return result.button;
|
||||
}
|
||||
|
||||
- (CPInteger)runModalForTypes:(CPArray)fileTypes
|
||||
- (CPArray)URLs
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _openPanel.runModal(fileTypes);
|
||||
return _URLs;
|
||||
}
|
||||
|
||||
@end
|
||||
+6
-20
@@ -4,7 +4,7 @@
|
||||
|
||||
@implementation CPSavePanel : CPPanel
|
||||
{
|
||||
JSObject _savePanel;
|
||||
Object result;
|
||||
}
|
||||
|
||||
+ (id)savePanel
|
||||
@@ -12,33 +12,19 @@
|
||||
return [[CPSavePanel alloc] init];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
_savePanel = window.application.createSavePanel();
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPInteger)runModal
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _savePanel.runModal();
|
||||
result = window.cpSavePanel();
|
||||
|
||||
return result.button;
|
||||
}
|
||||
|
||||
- (CPInteger)runModalForDirectory:(CPString)anAbsoluteDirectoryPath
|
||||
- (CPURL)URL
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _savePanel.runModal(anAbsoluteDirectoryPath);
|
||||
}
|
||||
|
||||
- (CPString)filename
|
||||
{
|
||||
return _savePanel.filename;
|
||||
return [CPURL URLWithString:result.URL];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user