From d8b2946fb57a76d5963ff58af43f36ad0443cbe2 Mon Sep 17 00:00:00 2001 From: Francisco Tolmasky Date: Tue, 19 May 2009 02:48:21 -0700 Subject: [PATCH] Updated themes so Rakefile will build your theme. Reviewed by me. --- AppKit/CPThemeBlend.j | 2 +- AppKit/Themes/Aristo/ThemeDescriptors.j | 2 +- AppKit/Tools/blend/main.j | 62 +++++++++---------- Tools/capp/Templates/ThemeDescriptor/Rakefile | 25 ++++---- .../ThemeDescriptor/ThemeDescriptors.j | 2 +- 5 files changed, 43 insertions(+), 50 deletions(-) diff --git a/AppKit/CPThemeBlend.j b/AppKit/CPThemeBlend.j index 4c46af1c1..18736ca1b 100644 --- a/AppKit/CPThemeBlend.j +++ b/AppKit/CPThemeBlend.j @@ -33,7 +33,7 @@ @implementation CPThemeBlend : CPObject { CPBundle _bundle; - CPArray _themes @accessors(readonly); + CPArray _themes @accessors(readonly, getter=themes); id _loadDelegate; } diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index 55152c618..3a8a72c20 100644 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -7,7 +7,7 @@ */ @import -@import +@import @implementation AristoThemeDescriptor : CPObject diff --git a/AppKit/Tools/blend/main.j b/AppKit/Tools/blend/main.j index 716cf60c5..5af515ee3 100755 --- a/AppKit/Tools/blend/main.j +++ b/AppKit/Tools/blend/main.j @@ -5,9 +5,7 @@ @import @import -importClass(java.io.FileOutputStream); -importClass(java.io.BufferedWriter); -importClass(java.io.OutputStreamWriter); +var File = require("file"); function main() @@ -18,7 +16,8 @@ function main() outputFilePath = "", descriptorFiles = [], resourcesPath = nil, - cibFiles = []; + cibFiles = [], + blendName = "Untitled"; for (; index < count; ++index) { @@ -67,11 +66,9 @@ function main() var objectTemplates = BKThemeObjectTemplatesForClass(theClass), data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])), temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"), - temporaryCibFilePath = temporaryCibFile.getAbsolutePath(), - writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temporaryCibFilePath), "UTF-8")); + temporaryCibFilePath = String(temporaryCibFile.getAbsolutePath()); - writer.write([data string]); - writer.close(); + File.write(temporaryCibFilePath, [data string], { charset:"UTF8" }); cibFiles.push(temporaryCibFilePath); } @@ -113,52 +110,49 @@ function getDirectory(aPath) function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath) { var resourcesFile = nil; - + if (resourcesPath) resourcesFile = new Packages.java.io.File(resourcesPath); - + var count = cibFiles.length, replacedFiles = [], staticContent = @""; - + while (count--) { var theme = themeFromCibFile(new Packages.java.io.File(cibFiles[count])), - + // Archive our theme. filePath = [theme name] + ".keyedtheme", fileContents = [[CPKeyedArchiver archivedDataWithRootObject:theme] string]; - + replacedFiles.push(filePath); staticContent += MARKER_PATH + ';' + filePath.length + ';' + filePath + MARKER_TEXT + ';' + fileContents.length + ';' + fileContents; } - - staticContent = "@STATIC;1.0;" + staticContent; - - var infoDictionary = [CPDictionary dictionary]; - staticContentName = "Aristo";//getFileNameWithoutExtension(project.activeTarget().name()); - [infoDictionary setObject:@"Yikes." forKey:@"CPBundleName"]; - [infoDictionary setObject:@"Yikes." forKey:@"CPBundleIdentifier"]; + staticContent = "@STATIC;1.0;" + staticContent; + + var blendName = File.basename(outputFilePath), + extension = File.extname(outputFilePath); + + if (extension.length) + blendName = blendName.substr(0, blendName.length - extension.length); + + var infoDictionary = [CPDictionary dictionary], + staticContentName = blendName + ".sj"; + + [infoDictionary setObject:blendName forKey:@"CPBundleName"]; + [infoDictionary setObject:blendName forKey:@"CPBundleIdentifier"]; [infoDictionary setObject:replacedFiles forKey:@"CPBundleReplacedFiles"]; [infoDictionary setObject:staticContentName forKey:@"CPBundleExecutable"]; var outputFile = new Packages.java.io.File(outputFilePath).getCanonicalFile(); outputFile.mkdirs(); - - var writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFilePath + "/Info.plist"), "UTF-8")); - - writer.write(CPPropertyListCreate280NorthData(infoDictionary).string); - - writer.close(); - - writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFilePath + '/' + staticContentName), "UTF-8")); - - writer.write(staticContent); - - writer.close(); + + File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF8" }); + File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF8" }); if (resourcesPath) rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath)); @@ -186,6 +180,8 @@ function themeFromCibFile(aFile) theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]]; } + print("Building " + [theme name] + " theme"); + [templates makeObjectsPerformSelector:@selector(blendAddThemedObjectAttributesToTheme:) withObject:theme]; return theme; @@ -286,7 +282,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput) if (themedObject) { - print(" Recording theme for " + [themedObject className] + "."); + print(" Recording themed properties for " + [themedObject className] + "."); [aTheme takeThemeFromObject:themedObject]; } diff --git a/Tools/capp/Templates/ThemeDescriptor/Rakefile b/Tools/capp/Templates/ThemeDescriptor/Rakefile index 44dce7c54..c88a1aeae 100644 --- a/Tools/capp/Templates/ThemeDescriptor/Rakefile +++ b/Tools/capp/Templates/ThemeDescriptor/Rakefile @@ -6,19 +6,16 @@ if !ENV['CONFIG'] ENV['CONFIG'] = 'Debug' end -ObjectiveJ::BundleTask.new(:__project.nameasidentifier__) do |t| - t.name = '__project.name__' - t.identifier = '__project.identifier__' - t.version = '1.0' - t.author = '__organization.name__' - t.email = '__organization.email__' - t.summary = '__project.name__' - t.sources = FileList['*.j'] - t.resources = FileList['Resources/*'] - t.license = ObjectiveJ::License::LGPL_v2_1 - t.build_path = File.join('Build', ENV['CONFIG'], '__project.nameasidentifier__') - t.flag = '-DDEBUG' if ENV['CONFIG'] == 'Debug' - t.flag = '-O' if ENV['CONFIG'] == 'Release' +$BLEND_PRODUCT = File.join('Build', ENV['CONFIG'], '__project.nameasidentifier__.blend'); + +file_d $BLEND_PRODUCT => ['ThemeDescriptors.j'] do + File.popen("blend -d ThemeDescriptors.j -o #{$BLEND_PRODUCT} -R Resources") do |blend| + blend.sync = true + + while str = blend.gets + puts str + end + end end -task :default => [:__project.nameasidentifier__] +task :default => [$BLEND_PRODUCT] diff --git a/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j b/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j index 3eb1d0a75..8e17474d0 100644 --- a/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j +++ b/Tools/capp/Templates/ThemeDescriptor/ThemeDescriptors.j @@ -18,7 +18,7 @@ return @"__project.name__"; } -+ (CPButton)themedStandardButton ++ (CPButton)themedButton { var button = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 20.0)];