mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-04 11:54:59 +00:00
Merge branch 'desktop' into jake
This commit is contained in:
commit
95274f618c
5 files changed
+133
-44
No files matched your search
+14
-10
@@ -24,6 +24,7 @@
|
||||
@import <Foundation/CPArray.j>
|
||||
|
||||
@import "CPResponder.j"
|
||||
@import "CPSavePanel.j"
|
||||
@import "CPViewController.j"
|
||||
@import "CPWindowController.j"
|
||||
|
||||
@@ -416,7 +417,7 @@ var CPDocumentUntitledCount = 0;
|
||||
|
||||
// FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
|
||||
_readConnection = [CPURLConnection connectionWithRequest:[CPURLRequest requestWithURL:anAbsoluteURL] delegate:self];
|
||||
|
||||
|
||||
_readConnection.session = _CPReadSessionMake(aType, aDelegate, aDidReadSelector, aContextInfo);
|
||||
}
|
||||
|
||||
@@ -459,17 +460,17 @@ var CPDocumentUntitledCount = 0;
|
||||
|
||||
_writeRequest = [CPURLRequest requestWithURL:anAbsoluteURL];
|
||||
|
||||
[_writeRequest setHTTPMethod:@"POST"];
|
||||
[_writeRequest setHTTPMethod:@"PUT"];
|
||||
[_writeRequest setHTTPBody:[data string]];
|
||||
|
||||
|
||||
[_writeRequest setValue:@"close" forHTTPHeaderField:@"Connection"];
|
||||
|
||||
if (aSaveOperation == CPSaveOperation)
|
||||
[_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"];
|
||||
|
||||
|
||||
if (aSaveOperation != CPSaveToOperation)
|
||||
[self updateChangeCount:CPChangeCleared];
|
||||
|
||||
|
||||
// FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
|
||||
var connection = [CPURLConnection connectionWithRequest:_writeRequest delegate:self];
|
||||
|
||||
@@ -784,16 +785,19 @@ var CPDocumentUntitledCount = 0;
|
||||
*/
|
||||
- (void)saveDocumentAs:(id)aSender
|
||||
{
|
||||
_documentName = window.prompt("Document Name:");
|
||||
var savePanel = [CPSavePanel savePanel],
|
||||
response = [savePanel runModal];
|
||||
|
||||
if (!_documentName)
|
||||
if (!response)
|
||||
return;
|
||||
|
||||
|
||||
var saveURL = [savePanel filename];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPDocumentWillSaveNotification
|
||||
object:self];
|
||||
|
||||
[self saveToURL:[self proposedFileURL] ofType:[self fileType] forSaveOperation:CPSaveAsOperation delegate:self didSaveSelector:@selector(document:didSave:contextInfo:) contextInfo:NULL];
|
||||
|
||||
[self saveToURL:saveURL ofType:[self fileType] forSaveOperation:CPSaveAsOperation delegate:self didSaveSelector:@selector(document:didSave:contextInfo:) contextInfo:NULL];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@import <Foundation/CPBundle.j>
|
||||
|
||||
@import "CPDocument.j"
|
||||
@import "CPOpenPanel.j";
|
||||
|
||||
|
||||
var CPSharedDocumentController = nil;
|
||||
@@ -138,11 +139,11 @@ var CPSharedDocumentController = nil;
|
||||
- (CPDocument)openDocumentWithContentsOfURL:(CPURL)anAbsoluteURL display:(BOOL)shouldDisplay error:(CPError)anError
|
||||
{
|
||||
var result = [self documentForURL:anAbsoluteURL];
|
||||
|
||||
|
||||
if (!result)
|
||||
{
|
||||
var type = [self typeForContentsOfURL:anAbsoluteURL error:anError];
|
||||
|
||||
|
||||
result = [self makeDocumentWithContentsOfURL:anAbsoluteURL ofType:type delegate:self didReadSelector:@selector(document:didRead:contextInfo:) contextInfo:[CPDictionary dictionaryWithObject:shouldDisplay forKey:@"shouldDisplay"]];
|
||||
}
|
||||
else if (shouldDisplay)
|
||||
@@ -219,6 +220,20 @@ var CPSharedDocumentController = nil;
|
||||
[self openUntitledDocumentOfType:[[_documentTypes objectAtIndex:0] objectForKey:@"CPBundleTypeName"] display:YES];
|
||||
}
|
||||
|
||||
-(void)openDocument:(id)aSender
|
||||
{
|
||||
var openPanel = [CPOpenPanel openPanel];
|
||||
|
||||
[openPanel runModalForTypes:nil];//[@"nib", @"xib", @"cib"]];
|
||||
|
||||
var filenames = [openPanel filenames],
|
||||
index = 0,
|
||||
count = [filenames count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
[self openDocumentWithContentsOfURL:[CPURL URLWithString:filenames[index]] display:YES error:nil];
|
||||
}
|
||||
|
||||
// Managing Documents
|
||||
|
||||
/*!
|
||||
|
||||
+3
-1
@@ -1501,7 +1501,9 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
if (self)
|
||||
{
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/39-dont-allow-windows-to-go-above-menubar
|
||||
[self setLevel:-1];//CPTornOffMenuWindowLevel];
|
||||
if ([CPPlatform isBrowser])
|
||||
[self setLevel:-1];//CPTornOffMenuWindowLevel];
|
||||
|
||||
[self setAutoresizingMask:CPWindowWidthSizable];
|
||||
|
||||
var contentView = [self contentView];
|
||||
|
||||
+55
-31
@@ -2,60 +2,84 @@
|
||||
@import <AppKit/CPPanel.j>
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
var SharedOpenPanel = nil;
|
||||
|
||||
@implementation CPOpenPanel : CPPanel
|
||||
{
|
||||
CPArray _files;
|
||||
BOOL _canChooseFiles @accessors(property=canChooseFiles);
|
||||
BOOL _canChooseDirectories @accessors(property=canChooseDirectories);
|
||||
BOOL _allowsMultipleSelection @accessors(property=allowsMultipleSelection);
|
||||
JSObject _openPanel;
|
||||
}
|
||||
|
||||
+ (id)openPanel
|
||||
{
|
||||
if (!SharedOpenPanel)
|
||||
SharedOpenPanel = [[CPOpenPanel alloc] init];
|
||||
|
||||
return SharedOpenPanel;
|
||||
return [[CPOpenPanel alloc] init];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_files = [];
|
||||
_canChooseFiles = YES;
|
||||
}
|
||||
_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 _files;
|
||||
return _openPanel.filenames;
|
||||
}
|
||||
|
||||
- (unsigned)runModalForDirectory:(CPString)absoluteDirectoryPath file:(CPString)filename types:(CPArray)fileTypes
|
||||
- (CPInteger)runModalForDirectory:(CPString)anAbsoluteDirectoryPath file:(CPString)aFilename types:(CPArray)fileTypes
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (window.Titanium)
|
||||
{
|
||||
_files = Titanium.Desktop.openFiles({
|
||||
path:absoluteDirectoryPath,
|
||||
types:fileTypes,
|
||||
multiple:_allowsMultipleSelection,
|
||||
filename:filename,
|
||||
directories:_canChooseDirectories,
|
||||
files:_canChooseFiles
|
||||
});
|
||||
}
|
||||
#endif
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _openPanel.runModal(anAbsoluteDirectoryPath, aFilename, fileTypes);
|
||||
}
|
||||
|
||||
- (unsigned)runModalForTypes:(CPArray)fileTypes
|
||||
{alert("HERE");
|
||||
[self runModalForDirectory:"/" file:nil types:fileTypes];
|
||||
- (CPInteger)runModalForTypes:(CPArray)fileTypes
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _openPanel.runModal(fileTypes);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
@import <AppKit/CPPanel.j>
|
||||
|
||||
|
||||
@implementation CPSavePanel : CPPanel
|
||||
{
|
||||
JSObject _savePanel;
|
||||
}
|
||||
|
||||
+ (id)savePanel
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
- (CPInteger)runModalForDirectory:(CPString)anAbsoluteDirectoryPath
|
||||
{
|
||||
// FIXME: Is this correct???
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
return _savePanel.runModal(anAbsoluteDirectoryPath);
|
||||
}
|
||||
|
||||
- (CPString)filename
|
||||
{
|
||||
return _savePanel.filename;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user