mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-27 17:05:53 +00:00
Merge branch '0.9.1' of github.com:280north/cappuccino into 0.9.1
This commit is contained in:
commit
bdcf84ec15
3 files changed
+156
-174
No files matched your search
@@ -59,28 +59,21 @@ task ("sudo-install", ["CommonJS"], function()
|
||||
if (OS.system(["sudo", "tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO]))
|
||||
{
|
||||
// Attempt a hackish work-around for sudo compiled with the --with-secure-path option
|
||||
if (OS.system("sudo bash -c 'source " + getShellConfigFile() + "; tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO + "'"))
|
||||
OS.exit(1); //rake abort if ($? != 0)
|
||||
sudo("tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO)
|
||||
}
|
||||
});
|
||||
|
||||
task ("install-symlinks", function()
|
||||
task ("install-symlinks", function()
|
||||
{
|
||||
installSymlink($BUILD_CJS_OBJECTIVE_J);
|
||||
installSymlink($BUILD_CJS_CAPPUCCINO);
|
||||
});
|
||||
|
||||
function installSymlink(sourcePath) {
|
||||
var TUSK = require("narwhal/tusk");
|
||||
var INSTALL = require("narwhal/tusk/commands/install");
|
||||
|
||||
var packageName = FILE.basename(sourcePath);
|
||||
var packageDir = TUSK.getPackagesDirectory().join(packageName);
|
||||
stream.print("Symlinking \0cyan(" + packageDir + "\0) to \0cyan(" + sourcePath + "\0)");
|
||||
|
||||
FILE.symlink(sourcePath, packageDir);
|
||||
INSTALL.finishInstall(packageDir);
|
||||
}
|
||||
task ("install-debug-symlinks", function()
|
||||
{
|
||||
SYSTEM.env["CONFIG"] = "Debug";
|
||||
spawnJake("install-symlinks");
|
||||
});
|
||||
|
||||
// Documentation
|
||||
|
||||
@@ -355,19 +348,3 @@ function buildCmd(arrayOfCommands)
|
||||
return cmd.map(OS.enquote).join(" ");
|
||||
}).join(" && ");
|
||||
}
|
||||
|
||||
function getShellConfigFile()
|
||||
{
|
||||
var homeDir = SYSTEM.env["HOME"] + "/";
|
||||
// use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
|
||||
var possibilities = [homeDir + ".bash_profile",
|
||||
homeDir + ".bash_login",
|
||||
homeDir + ".profile",
|
||||
homeDir + ".bashrc"];
|
||||
|
||||
for (var i = 0; i < possibilities.length; i++)
|
||||
{
|
||||
if (FILE.exists(possibilities[i]))
|
||||
return possibilities[i];
|
||||
}
|
||||
}
|
||||
+68
-135
@@ -60,162 +60,95 @@ var NSButtonIsBorderedMask = 0x00800000,
|
||||
|
||||
if (self)
|
||||
{
|
||||
var cell = [aCoder decodeObjectForKey:@"NSCell"];
|
||||
var cell = [aCoder decodeObjectForKey:@"NSCell"],
|
||||
alternateImage = [cell alternateImage];
|
||||
|
||||
if ([alternateImage isKindOfClass:[NSButtonImageSource class]])
|
||||
{
|
||||
/*
|
||||
Because CPCheckBox and CPRadio are direct subclasses,
|
||||
we can just change the class of this object. In the
|
||||
case of CPRadio, we can add its _radioGroup ivar by setting it
|
||||
directly on self.
|
||||
*/
|
||||
if ([alternateImage imageName] === @"NSSwitch")
|
||||
self.isa = [CPCheckBox class];
|
||||
|
||||
else if ([alternateImage imageName] === @"NSRadioButton")
|
||||
{
|
||||
self.isa = [CPRadio class];
|
||||
self._radioGroup = [CPRadioGroup new];
|
||||
}
|
||||
}
|
||||
|
||||
NIB_CONNECTION_EQUIVALENCY_TABLE[[cell UID]] = self;
|
||||
|
||||
_title = [cell title];
|
||||
_controlSize = CPRegularControlSize;
|
||||
|
||||
if (![self NS_isCheckBox] && ![self NS_isRadio])
|
||||
[self setBordered:[cell isBordered]];
|
||||
_bezelStyle = [cell bezelStyle];
|
||||
|
||||
// clean up:
|
||||
switch (_bezelStyle)
|
||||
{
|
||||
_controlSize = CPRegularControlSize;
|
||||
|
||||
[self setBordered:[cell isBordered]];
|
||||
_bezelStyle = [cell bezelStyle];
|
||||
|
||||
// clean up:
|
||||
switch (_bezelStyle)
|
||||
{
|
||||
// implemented:
|
||||
case CPRoundedBezelStyle:
|
||||
case CPTexturedRoundedBezelStyle:
|
||||
case CPHUDBezelStyle:
|
||||
break;
|
||||
// approximations:
|
||||
case CPRoundRectBezelStyle:
|
||||
_bezelStyle = CPRoundedBezelStyle;
|
||||
break;
|
||||
case CPSmallSquareBezelStyle:
|
||||
case CPThickSquareBezelStyle:
|
||||
case CPThickerSquareBezelStyle:
|
||||
case CPRegularSquareBezelStyle:
|
||||
case CPTexturedSquareBezelStyle:
|
||||
case CPShadowlessSquareBezelStyle:
|
||||
_bezelStyle = CPTexturedRoundedBezelStyle;
|
||||
break;
|
||||
case CPRecessedBezelStyle:
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// unsupported
|
||||
case CPRoundedDisclosureBezelStyle:
|
||||
case CPHelpButtonBezelStyle:
|
||||
case CPCircularBezelStyle:
|
||||
case CPDisclosureBezelStyle:
|
||||
CPLog.warn("Unsupported bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// error:
|
||||
default:
|
||||
CPLog.error("Unknown bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
}
|
||||
|
||||
if ([cell isBordered])
|
||||
{
|
||||
CPLog.info("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + CPButtonDefaultHeight);
|
||||
_frame.size.height = CPButtonDefaultHeight;
|
||||
_frame.origin.y += 4.0;
|
||||
_bounds.size.height = CPButtonDefaultHeight;
|
||||
}
|
||||
// implemented:
|
||||
case CPRoundedBezelStyle:
|
||||
case CPTexturedRoundedBezelStyle:
|
||||
case CPHUDBezelStyle:
|
||||
break;
|
||||
// approximations:
|
||||
case CPRoundRectBezelStyle:
|
||||
_bezelStyle = CPRoundedBezelStyle;
|
||||
break;
|
||||
case CPSmallSquareBezelStyle:
|
||||
case CPThickSquareBezelStyle:
|
||||
case CPThickerSquareBezelStyle:
|
||||
case CPRegularSquareBezelStyle:
|
||||
case CPTexturedSquareBezelStyle:
|
||||
case CPShadowlessSquareBezelStyle:
|
||||
_bezelStyle = CPTexturedRoundedBezelStyle;
|
||||
break;
|
||||
case CPRecessedBezelStyle:
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// unsupported
|
||||
case CPRoundedDisclosureBezelStyle:
|
||||
case CPHelpButtonBezelStyle:
|
||||
case CPCircularBezelStyle:
|
||||
case CPDisclosureBezelStyle:
|
||||
CPLog.warn("Unsupported bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// error:
|
||||
default:
|
||||
CPLog.error("Unknown bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (![self isKindOfClass:CPCheckBox] && ![self isKindOfClass:CPRadio])
|
||||
{
|
||||
if ([self NS_isCheckBox])
|
||||
return [[CPCheckBox alloc] NS_initWithCoder:aCoder];
|
||||
else
|
||||
return [[CPRadio alloc] NS_initWithCoder:aCoder];
|
||||
}
|
||||
|
||||
[self setBordered:YES];
|
||||
if ([cell isBordered])
|
||||
{
|
||||
CPLog.info("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + CPButtonDefaultHeight);
|
||||
_frame.size.height = CPButtonDefaultHeight;
|
||||
_frame.origin.y += 4.0;
|
||||
_bounds.size.height = CPButtonDefaultHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)NS_isCheckBox
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)NS_isRadio
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPRadio (NS)
|
||||
|
||||
- (BOOL)NS_isRadio
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super NS_initWithCoder:aCoder])
|
||||
_radioGroup = [CPRadioGroup new];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPCheckBox (NS)
|
||||
|
||||
- (BOOL)NS_isCheckBox
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSButton : CPButton
|
||||
{
|
||||
BOOL _isCheckBox @accessors(readonly, getter=NS_isCheckBox);
|
||||
BOOL _isRadio @accessors(readonly, getter=NS_isRadio);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
// We need to do a bit of magic to determine if this is a checkbox or radio button
|
||||
// BEFORE we can initialize the rest of the object.
|
||||
var cell = [aCoder decodeObjectForKey:@"NSCell"],
|
||||
alternateImage = [cell alternateImage];
|
||||
|
||||
if ([alternateImage isKindOfClass:[NSButtonImageSource class]])
|
||||
{
|
||||
if ([alternateImage imageName] === @"NSSwitch")
|
||||
_isCheckBox = YES;
|
||||
|
||||
else if ([alternateImage imageName] === @"NSRadioButton")
|
||||
{
|
||||
_isRadio = YES;
|
||||
_radioGroup = [CPRadioGroup new];
|
||||
}
|
||||
}
|
||||
|
||||
self = [self NS_initWithCoder:aCoder];
|
||||
|
||||
self._allowsMixedState = [cell allowsMixedState];
|
||||
[self setImagePosition:[cell imagePosition]];
|
||||
|
||||
[self setKeyEquivalent:[cell keyEquivalent]];
|
||||
self._keyEquivalentModifierMask = [cell keyEquivalentModifierMask];
|
||||
|
||||
return self;
|
||||
return [self NS_initWithCoder:aCoder];
|
||||
}
|
||||
|
||||
- (Class)classForKeyedArchiver
|
||||
{
|
||||
if ([self NS_isCheckBox])
|
||||
return [CPCheckBox class];
|
||||
|
||||
if ([self NS_isRadio])
|
||||
return [CPRadio class];
|
||||
|
||||
return [CPButton class];
|
||||
}
|
||||
|
||||
@@ -232,7 +165,7 @@ var NSButtonIsBorderedMask = 0x00800000,
|
||||
BOOL _allowsMixedState @accessors(readonly, getter=allowsMixedState);
|
||||
BOOL _imagePosition @accessors(readonly, getter=imagePosition);
|
||||
|
||||
CPString _keyEquivalent @accessors(readonly, getter=keyEquivalent);
|
||||
CPString _keyEquivalent @accessors(readonly, getter=keyEquivalent);
|
||||
unsigned _keyEquivalentModifierMask @accessors(readonly, getter=keyEquivalentModifierMask);
|
||||
}
|
||||
|
||||
@@ -287,7 +220,7 @@ var NSButtonIsBorderedMask = 0x00800000,
|
||||
|
||||
@implementation NSButtonImageSource : CPObject
|
||||
{
|
||||
CPString _imageName @accessors(readonly, getter=imageName);
|
||||
CPString _imageName @accessors(readonly, getter=imageName);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
|
||||
+81
-9
@@ -14,7 +14,7 @@ SYSTEM.args.slice(1).forEach(function(arg){
|
||||
function ensurePackageUpToDate(packageName, requiredVersion, options)
|
||||
{
|
||||
options = options || {};
|
||||
|
||||
|
||||
var packageInfo = require("narwhal/packages").catalog[packageName];
|
||||
if (!packageInfo)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ function ensurePackageUpToDate(packageName, requiredVersion, options)
|
||||
var version = packageInfo.version;
|
||||
if (typeof version === "string")
|
||||
version = version.split(".");
|
||||
|
||||
|
||||
if (typeof requiredVersion === "string")
|
||||
requiredVersion = requiredVersion.split(".");
|
||||
|
||||
@@ -152,21 +152,21 @@ function additionalPackages()
|
||||
{
|
||||
var builtObjectiveJPackage = FILE.path($BUILD_CONFIGURATION_DIR).join("CommonJS", "objective-j", "");
|
||||
var builtCappuccinoPackage = FILE.path($BUILD_CONFIGURATION_DIR).join("CommonJS", "cappuccino", "");
|
||||
|
||||
|
||||
var packages = [];
|
||||
|
||||
|
||||
// load built objective-j if exists, otherwise unbuilt
|
||||
if (builtObjectiveJPackage.join("package.json").exists()) {
|
||||
if (!packageInCatalog(builtObjectiveJPackage))
|
||||
packages.push(builtObjectiveJPackage);
|
||||
}
|
||||
|
||||
|
||||
// load built cappuccino if it exists
|
||||
if (builtCappuccinoPackage.join("package.json").exists()) {
|
||||
if (!packageInCatalog(builtCappuccinoPackage))
|
||||
packages.push(builtCappuccinoPackage);
|
||||
}
|
||||
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ function packageInCatalog(path)
|
||||
serializedENV = function()
|
||||
{
|
||||
var envNew = {};
|
||||
|
||||
|
||||
// add changed keys to the new ENV
|
||||
Object.keys(SYSTEM.env).forEach(function(key) {
|
||||
if (SYSTEM.env[key] !== envInitial[key])
|
||||
@@ -202,6 +202,22 @@ serializedENV = function()
|
||||
}).join(" ");
|
||||
}
|
||||
|
||||
function getShellConfigFile()
|
||||
{
|
||||
var homeDir = SYSTEM.env["HOME"] + "/";
|
||||
// use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
|
||||
var possibilities = [homeDir + ".bash_profile",
|
||||
homeDir + ".bash_login",
|
||||
homeDir + ".profile",
|
||||
homeDir + ".bashrc"];
|
||||
|
||||
for (var i = 0; i < possibilities.length; i++)
|
||||
{
|
||||
if (FILE.exists(possibilities[i]))
|
||||
return possibilities[i];
|
||||
}
|
||||
}
|
||||
|
||||
function reforkWithPackages()
|
||||
{
|
||||
if (additionalPackages().length > 0) {
|
||||
@@ -251,7 +267,7 @@ global.cp_r = function(/*String*/ from, /*String*/ to)
|
||||
global.cp = function(/*String*/ from, /*String*/ to)
|
||||
{
|
||||
FILE.copy(from, to);
|
||||
// FILE.chmod(to, FILE.mod(from));
|
||||
// FILE.chmod(to, FILE.mod(from));
|
||||
}
|
||||
|
||||
global.mv = function(/*String*/ from, /*String*/ to)
|
||||
@@ -344,12 +360,58 @@ global.subtasks = function(subprojects, taskNames)
|
||||
});
|
||||
}
|
||||
|
||||
function spawnJake(/*String*/ aTaskName)
|
||||
global.installSymlink = function(sourcePath)
|
||||
{
|
||||
if (!FILE.isDirectory(sourcePath))
|
||||
return;
|
||||
|
||||
var packageName = FILE.basename(sourcePath),
|
||||
targetPath = FILE.join(SYSTEM.prefix, "packages", packageName);
|
||||
|
||||
if (FILE.isDirectory(targetPath))
|
||||
FILE.rmtree(targetPath);
|
||||
else if (FILE.linkExists(targetPath))
|
||||
FILE.remove(targetPath);
|
||||
|
||||
stream.print("Symlinking \0cyan(" + targetPath + "\0) ==> \0cyan(" + sourcePath + "\0)");
|
||||
FILE.symlink(sourcePath, targetPath);
|
||||
|
||||
var binPath = FILE.Path(FILE.join(targetPath, "bin"));
|
||||
|
||||
if (binPath.isDirectory())
|
||||
{
|
||||
var narwhalBin = FILE.Path(FILE.join(SYSTEM.prefix, "bin"));
|
||||
|
||||
binPath.list().forEach(function (name)
|
||||
{
|
||||
var binary = binPath.join(name);
|
||||
binary.chmod(0755);
|
||||
|
||||
var target = narwhalBin.join(name),
|
||||
relative = FILE.relative(target, binary);
|
||||
|
||||
if (target.linkExists())
|
||||
target.remove();
|
||||
|
||||
FILE.symlink(relative, target);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
global.spawnJake = function(/*String*/ aTaskName)
|
||||
{
|
||||
if (OS.system(serializedENV() + " " + SYSTEM.args[0] + " " + aTaskName))
|
||||
OS.exit(1);//rake abort if ($? != 0)
|
||||
}
|
||||
|
||||
global.sudo = function(/*String*/ aTaskName)
|
||||
{
|
||||
var cmd = "sudo bash -c 'source " + getShellConfigFile() + "; " + aTaskName + "'";
|
||||
|
||||
if (OS.system(cmd))
|
||||
OS.exit(1); //rake abort if ($? != 0)
|
||||
}
|
||||
|
||||
// built in tasks
|
||||
|
||||
task ("build");
|
||||
@@ -369,6 +431,16 @@ task ("debug", function()
|
||||
|
||||
task ("all", ["debug", "release"]);
|
||||
|
||||
task ("sudo-install-symlinks", function()
|
||||
{
|
||||
sudo("jake install-symlinks");
|
||||
});
|
||||
|
||||
task ("sudo-install-debug-symlinks", function()
|
||||
{
|
||||
sudo("jake install-debug-symlinks")
|
||||
});
|
||||
|
||||
task ("clean-debug", function()
|
||||
{
|
||||
SYSTEM.env['CONFIG'] = 'Debug'
|
||||
|
||||
Reference in new issue
Block a user