• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BathyScapheのアイコンセット生成&適用ツール


Commit MetaInfo

修订版aa1117f03ce716aa3be49239bb5fec28eeebe7ec (tree)
时间2012-05-31 23:17:50
作者masakih <masakih@user...>
Commitermasakih

Log Message

[Mod] ソースコード整理

更改概述

差异

--- a/ColorSet.m
+++ b/ColorSet.m
@@ -127,26 +127,10 @@ enum {
127127
128128 -(void)sendingSetColor:(ColorType)colorType
129129 {
130- NSString *bsBundleID;
131130 OSType type;
132131 id targetColor;
133- id tempColor;
134- CGFloat red, green, blue, alpha;
135132 OSStatus err;
136133
137- NSAppleEventDescriptor *ae;
138-
139- NSAppleEventDescriptor *bsDesc;
140-
141- NSAppleEventDescriptor *propDesc;
142-
143- NSAppleEventDescriptor *keyDataDesc;
144-
145- NSAppleEventDescriptor *colorDesc;
146- NSAppleEventDescriptor *redDesc;
147- NSAppleEventDescriptor *greenDesc;
148- NSAppleEventDescriptor *blueDesc;
149-
150134 switch(colorType) {
151135 case kTypeThreadsListColor:
152136 type = 'brCo';
@@ -160,40 +144,39 @@ enum {
160144 }
161145
162146 /* set up BathyScaphe addr */
163- bsBundleID = [[IconSetComposer bathyScapheBundle] bundleIdentifier];
164- bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:bsBundleID];
147+ NSString *bsBundleID = [[IconSetComposer bathyScapheBundle] bundleIdentifier];
148+ NSAppleEventDescriptor *bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:bsBundleID];
165149
166150 /* Setting color */
151+ NSAppleEventDescriptor *colorDesc = [NSAppleEventDescriptor listDescriptor];;
167152 if( targetColor ) {
168- tempColor = [targetColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
153+ CGFloat red, green, blue, alpha;
154+ id tempColor = [targetColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
169155 [tempColor getRed:&red green:&green blue:&blue alpha:&alpha];
170156
171- redDesc = [NSAppleEventDescriptor descriptorWithFloat:red];
172- greenDesc = [NSAppleEventDescriptor descriptorWithFloat:green];
173- blueDesc = [NSAppleEventDescriptor descriptorWithFloat:blue];
157+ NSAppleEventDescriptor *redDesc = [NSAppleEventDescriptor descriptorWithFloat:red];
158+ NSAppleEventDescriptor *greenDesc = [NSAppleEventDescriptor descriptorWithFloat:green];
159+ NSAppleEventDescriptor *blueDesc = [NSAppleEventDescriptor descriptorWithFloat:blue];
174160
175161 colorDesc = [NSAppleEventDescriptor listDescriptor];
176162 [colorDesc insertDescriptor:redDesc atIndex:1];
177163 [colorDesc insertDescriptor:greenDesc atIndex:2];
178164 [colorDesc insertDescriptor:blueDesc atIndex:3];
179- } else {
180-
181- colorDesc = [NSAppleEventDescriptor listDescriptor];
182165 }
183166
184167 /* create typeObjectSpecifier Descriptor */
185- keyDataDesc = [NSAppleEventDescriptor descriptorWithTypeCode:type];
186- propDesc = [NSAppleEventDescriptor objectSpecifierWithDesiredClass:cProperty
187- container:nil
188- keyForm:formPropertyID
189- keyData:keyDataDesc];
168+ NSAppleEventDescriptor *keyDataDesc = [NSAppleEventDescriptor descriptorWithTypeCode:type];
169+ NSAppleEventDescriptor *propDesc = [NSAppleEventDescriptor objectSpecifierWithDesiredClass:cProperty
170+ container:nil
171+ keyForm:formPropertyID
172+ keyData:keyDataDesc];
190173
191174 /* create AppleEvent */
192- ae = [NSAppleEventDescriptor appleEventWithEventClass:kAECoreSuite
193- eventID:kAESetData
194- targetDescriptor:bsDesc
195- returnID:kAutoGenerateReturnID
196- transactionID:kAnyTransactionID];
175+ NSAppleEventDescriptor *ae = [NSAppleEventDescriptor appleEventWithEventClass:kAECoreSuite
176+ eventID:kAESetData
177+ targetDescriptor:bsDesc
178+ returnID:kAutoGenerateReturnID
179+ transactionID:kAnyTransactionID];
197180
198181 [ae setParamDescriptor:colorDesc forKeyword:keyAEData];
199182 [ae setParamDescriptor:propDesc forKeyword:keyDirectObject];
@@ -210,23 +193,12 @@ enum {
210193 }
211194 + (NSColor *)getBathyScapheColor:(ColorType)colorType
212195 {
213- NSString *bsBundleID;
214196 OSType type;
215197 id result = nil;
216- float red, green, blue;
217198 OSStatus err;
218199
219200 [[IconSetComposer sharedInstance] launchBS];
220201
221- NSAppleEventDescriptor *replyDesc;
222- NSAppleEventDescriptor *colorComponentsDesc;
223- NSAppleEventDescriptor *colorComponentDesc;
224-
225- NSAppleEventDescriptor *ae;
226- NSAppleEventDescriptor *bsDesc;
227- NSAppleEventDescriptor *propDesc;
228- NSAppleEventDescriptor *keyDataDesc;
229-
230202 switch(colorType) {
231203 case kTypeThreadsListColor:
232204 type = 'brCo';
@@ -236,23 +208,23 @@ enum {
236208 }
237209
238210 /* set up BathyScaphe addr */
239- bsBundleID = [[IconSetComposer bathyScapheBundle] bundleIdentifier];
240- bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:bsBundleID];
211+ NSString *bsBundleID = [[IconSetComposer bathyScapheBundle] bundleIdentifier];
212+ NSAppleEventDescriptor *bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:bsBundleID];
241213
242214
243215 /* create typeObjectSpecifier Descriptor */
244- keyDataDesc = [NSAppleEventDescriptor descriptorWithTypeCode:type];
245- propDesc = [NSAppleEventDescriptor objectSpecifierWithDesiredClass:cProperty
246- container:nil
247- keyForm:formPropertyID
248- keyData:keyDataDesc];
216+ NSAppleEventDescriptor *keyDataDesc = [NSAppleEventDescriptor descriptorWithTypeCode:type];
217+ NSAppleEventDescriptor *propDesc = [NSAppleEventDescriptor objectSpecifierWithDesiredClass:cProperty
218+ container:nil
219+ keyForm:formPropertyID
220+ keyData:keyDataDesc];
249221
250222 /* create AppleEvent */
251- ae = [NSAppleEventDescriptor appleEventWithEventClass:kAECoreSuite
252- eventID:kAEGetData
253- targetDescriptor:bsDesc
254- returnID:kAutoGenerateReturnID
255- transactionID:kAnyTransactionID];
223+ NSAppleEventDescriptor *ae = [NSAppleEventDescriptor appleEventWithEventClass:kAECoreSuite
224+ eventID:kAEGetData
225+ targetDescriptor:bsDesc
226+ returnID:kAutoGenerateReturnID
227+ transactionID:kAnyTransactionID];
256228
257229 [ae setParamDescriptor:propDesc forKeyword:keyDirectObject];
258230
@@ -260,7 +232,7 @@ enum {
260232 NSLog(@"%@", ae);
261233 #endif
262234
263-
235+ NSAppleEventDescriptor *replyDesc;
264236 err = [ae sendAppleEventWithMode:kAECanInteract + kAEWaitReply
265237 timeOutInTicks:kAEDefaultTimeout
266238 reply:&replyDesc];
@@ -273,14 +245,14 @@ enum {
273245 #ifdef DEBUG
274246 NSLog(@"%@", replyDesc);
275247 #endif
276-
277- colorComponentsDesc = [replyDesc paramDescriptorForKeyword:keyDirectObject];
248+ NSAppleEventDescriptor *colorComponentDesc;
249+ NSAppleEventDescriptor *colorComponentsDesc = [replyDesc paramDescriptorForKeyword:keyDirectObject];
278250 colorComponentDesc = [colorComponentsDesc descriptorAtIndex:1];
279- red = [[colorComponentDesc stringValue] floatValue];
251+ CGFloat red = [[colorComponentDesc stringValue] floatValue];
280252 colorComponentDesc = [colorComponentsDesc descriptorAtIndex:2];
281- green = [[colorComponentDesc stringValue] floatValue];
253+ CGFloat green = [[colorComponentDesc stringValue] floatValue];
282254 colorComponentDesc = [colorComponentsDesc descriptorAtIndex:3];
283- blue = [[colorComponentDesc stringValue] floatValue];
255+ CGFloat blue = [[colorComponentDesc stringValue] floatValue];
284256
285257 result = [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1];
286258
@@ -333,15 +305,12 @@ enum {
333305
334306 - (IBAction)changeColor:(id)sender
335307 {
336- int tag;
337-
338308 if( ![sender respondsToSelector:@selector(tag)]
339309 && ![sender respondsToSelector:@selector(color)] ) {
340310 return;
341311 }
342312
343- tag = [sender tag];
344- switch(tag) {
313+ switch([sender tag]) {
345314 case ThreadsListColorTag:
346315 [self setThreadsListColor:[sender color]];
347316 break;
@@ -352,14 +321,11 @@ enum {
352321
353322 - (IBAction)revertColor:(id)sender
354323 {
355- int tag;
356-
357324 if( ![sender respondsToSelector:@selector(tag)] ) {
358325 return;
359326 }
360327
361- tag = [sender tag];
362- switch(tag) {
328+ switch([sender tag]) {
363329 case ThreadsListColorTag:
364330 [self setThreadsListColor:nil];
365331 break;
@@ -382,15 +348,12 @@ enum {
382348 }
383349 - (BOOL)setPlistURL:(NSURL *)url
384350 {
385- NSDictionary *dict;
386- NSColor *color;
387-
388- dict = [NSDictionary dictionaryWithContentsOfURL:url];
351+ NSDictionary *dict = [NSDictionary dictionaryWithContentsOfURL:url];
389352 if( !dict ) {
390353 return NO;
391354 }
392355
393- color = [NSColor colorWithPlist:[dict objectForKey:ThreadsListColorKey]];
356+ NSColor *color = [NSColor colorWithPlist:[dict objectForKey:ThreadsListColorKey]];
394357 [self setThreadsListColor:color];
395358
396359 [self setIncludeColors:[[dict objectForKey:IncludeColorsKey] boolValue]];
--- a/IconSetComposer.m
+++ b/IconSetComposer.m
@@ -28,12 +28,11 @@ static IconSetComposer *_instance = nil;
2828 andDecrementals:(NSArray *)decrementalImages
2929 {
3030 int result;
31- //
31+
3232 NSString *title = NSLocalizedString( @"Caution!", @"Caution!" );
3333 NSString *message = @"";
3434 NSString *defaultCaption = NSLocalizedString( @"Quit", @"Quit" );
3535 NSString *alternateCaption = NSLocalizedString( @"Continue", @"Continue" );
36-// NSString *otherCaption;
3736
3837 NSString *tmpString;
3938 NSString *inc = nil;
@@ -68,33 +67,25 @@ static IconSetComposer *_instance = nil;
6867 }
6968 -(BOOL)isSupportedBathyScaphe
7069 {
71- NSBundle *bsBundle;
72- NSString *bsResourcesPath;
73- NSArray *bsResources;
74- NSArray *knownBSSystemImages;
75- NSArray *managedImages;
76- unsigned managedImageNum;
77- unsigned bsResourceImageNum = 0;
78- id fm;
79- int status = 0;
80- NSMutableArray *incrementalImages = [NSMutableArray array];
81- NSMutableArray *decrementalImages = nil;
82- NSMutableArray *containsImages = [NSMutableArray array];
83-
84- bsBundle = [[self class] bathyScapheBundle];
70+ NSBundle *bsBundle = [[self class] bathyScapheBundle];
8571 if( !bsBundle ) {
8672 return NO;
8773 }
8874
89- fm = [NSFileManager defaultManager];
90- bsResourcesPath = [bsBundle resourcePath];
91- bsResources = [fm directoryContentsAtPath:bsResourcesPath];
75+ NSUInteger bsResourceImageNum = 0;
76+ NSInteger status = 0;
77+ NSMutableArray *incrementalImages = [NSMutableArray array];
78+ NSMutableArray *decrementalImages = nil;
79+ NSMutableArray *containsImages = [NSMutableArray array];
80+ id fm = [NSFileManager defaultManager];
81+ NSString *bsResourcesPath = [bsBundle resourcePath];
82+ NSArray *bsResources = [fm directoryContentsAtPath:bsResourcesPath];
9283
93- managedImages = [IconSetDocument managedImageNames];
94- managedImageNum = [managedImages count];
84+ NSArray *managedImages = [IconSetDocument managedImageNames];
85+ NSUInteger managedImageNum = [managedImages count];
9586
96- knownBSSystemImages = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BathyScapheSystemImages"
97- ofType:@"plist"]];
87+ NSArray *knownBSSystemImages = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BathyScapheSystemImages"
88+ ofType:@"plist"]];
9889
9990 for(NSString *filename in bsResources) {
10091 if( [[self class] isAcceptImageExtension:[filename pathExtension]] ) {
@@ -137,11 +128,8 @@ static IconSetComposer *_instance = nil;
137128
138129 +(NSBundle *)bathyScapheBundle
139130 {
140- NSString *bsPath;
141- NSBundle *bsBundle;
142-
143- bsPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:[self bathyScapheIdentifier]];
144- bsBundle = [NSBundle bundleWithPath:bsPath];
131+ NSString *bsPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:[self bathyScapheIdentifier]];
132+ NSBundle *bsBundle = [NSBundle bundleWithPath:bsPath];
145133
146134 return bsBundle;
147135 }
@@ -199,7 +187,7 @@ final:
199187 {
200188 static NSString *result = nil;
201189
202- if( !result ) {
190+ if( !result ) {
203191 NSArray *dirs = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask, YES );
204192 NSString *tmp;
205193
@@ -219,7 +207,7 @@ final:
219207 {
220208 static NSString *result = nil;
221209
222- if( !result ) {
210+ if( !result ) {
223211 NSString *tmp;
224212
225213 result = [self bathyScapheSupportFolder];
@@ -261,12 +249,8 @@ final:
261249 +(NSImage *)defaultImageForIdentifier:(NSString *)identifier
262250 {
263251 NSBundle *bsBundle = [self bathyScapheBundle];
264-
265- NSString *path;
266- NSImage *image;
267-
268- path = [bsBundle pathForImageResource:identifier];
269- image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
252+ NSString *path = [bsBundle pathForImageResource:identifier];
253+ NSImage *image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
270254
271255 return image;
272256 }
@@ -345,19 +329,16 @@ final:
345329 -(long)quitBS
346330 {
347331 OSStatus err;
348- NSAppleEventDescriptor *ae;
349- NSAppleEventDescriptor *bsDesc;
350332
351333 /* set up BathyScaphe addr */
352- bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:[self bathyScapheIdentifier]];
334+ NSAppleEventDescriptor *bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:[self bathyScapheIdentifier]];
353335
354- ae = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
355- eventID:kAEQuitApplication
356- targetDescriptor:bsDesc
357- returnID:kAutoGenerateReturnID
358- transactionID:kAnyTransactionID];
336+ NSAppleEventDescriptor *ae = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
337+ eventID:kAEQuitApplication
338+ targetDescriptor:bsDesc
339+ returnID:kAutoGenerateReturnID
340+ transactionID:kAnyTransactionID];
359341
360-// err = AESendMessage( [ae aeDesc], NULL, kAECanInteract, kAEDefaultTimeout );
361342 err = [ae sendAppleEventWithMode:kAECanInteract | kAEWaitReply
362343 timeOutInTicks:kAEDefaultTimeout
363344 reply:NULL];
@@ -404,14 +385,9 @@ final:
404385 }
405386 -(IBAction)createDocumentFromCurrentSetting:(id)sender
406387 {
407- NSString *bsSupPath = [[self class] bathyScapheSupportFolder];
408- NSBundle *bsSupBundle;
409388 NSArray *imageNames = [IconSetDocument managedImageNames];
410- NSString *imagePath;
411-
412- IconSetDocument *newDocument;
413-
414- bsSupBundle = [NSBundle bundleWithPath:bsSupPath];
389+ NSString *bsSupPath = [[self class] bathyScapheSupportFolder];
390+ NSBundle *bsSupBundle = [NSBundle bundleWithPath:bsSupPath];
415391
416392 if(!imageNames || !bsSupBundle) {
417393 NSLog(@"HOGE!!");
@@ -419,9 +395,8 @@ final:
419395 return;
420396 }
421397
422- newDocument = [[NSDocumentController sharedDocumentController]
423- openUntitledDocumentOfType:@"IconSetType"
424- display:NO];
398+ IconSetDocument *newDocument = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"IconSetType"
399+ display:NO];
425400 if(!newDocument) {
426401 NSLog(@"Can not create new document.");
427402 NSBeep();
@@ -429,7 +404,7 @@ final:
429404 }
430405
431406 for(NSString *imageName in imageNames) {
432- imagePath = [bsSupBundle pathForImageResource:imageName];
407+ NSString *imagePath = [bsSupBundle pathForImageResource:imageName];
433408 [newDocument setPath:imagePath forIdentifier:imageName];
434409 }
435410
--- a/IconSetDocument.m
+++ b/IconSetDocument.m
@@ -285,14 +285,12 @@ static NSArray *sThreadIdentifiers;
285285
286286 -(void)didChangeColorSet:(ColorSet *)set
287287 {
288- NSString *identifier;
289- NSDictionary *plist;
290288 NSFileWrapper *fw;
291289 NSString *path;
292290 TemporaryFolder *t = [TemporaryFolder temporaryFolder];
293291
294- identifier = [set identifier];
295- plist = [set plist];
292+ NSString *identifier = [set identifier];
293+ NSDictionary *plist = [set plist];
296294 if( !plist && ![plist respondsToSelector:@selector(writeToFile:atomically:)] ) {
297295 return;
298296 }
@@ -451,31 +449,23 @@ static NSArray *sThreadIdentifiers;
451449
452450 -(void)updateAll
453451 {
454- id keys = [[wrapper fileWrappers] keyEnumerator];
455- id identifier;
456-
457- while( identifier = [keys nextObject] ) {
452+ for(id identifier in [wrapper fileWrappers]) {
458453 identifier = [identifier stringByDeletingPathExtension];
459454 [self updateForKey:identifier];
460455 }
461456 }
462457 -(void)updateForKey:(NSString *)key
463458 {
464- NSImage *image;
465- NSFileWrapper *fw;
466- NSData *data;
467- NSString *filename;
468-
469- fw = [self fileWrapperForIdentifier:key];
459+ NSFileWrapper *fw = [self fileWrapperForIdentifier:key];
470460 if( !fw ) {
471461 // NSLog(@"can't load image for %@", key);
472462 return;
473463 }
474464
475- data = [fw regularFileContents];
476- image = [[[NSImage alloc] initWithData:data] autorelease];
465+ NSData *data = [fw regularFileContents];
466+ NSImage *image = [[[NSImage alloc] initWithData:data] autorelease];
477467 if( !image ) {
478- filename = [fw filename];
468+ NSString *filename = [fw filename];
479469 if( !filename ) return;
480470 NSURL *bundleURL = [self fileURL];
481471 NSURL *colorSetURL = [bundleURL URLByAppendingPathComponent:filename];
@@ -505,31 +495,23 @@ static NSArray *sThreadIdentifiers;
505495
506496 -(void)applyAndRestartBathyScaphe:(id)sender
507497 {
508- NSScriptCommandDescription *desc;
509- NSScriptCommand *command;
510-
511- desc = [[NSScriptSuiteRegistry sharedScriptSuiteRegistry] commandDescriptionWithAppleEventClass:'bSiS'
512- andAppleEventCode:'bSaP'];
513- command = [desc createCommandInstance];
514-
498+ NSScriptCommandDescription *desc = [[NSScriptSuiteRegistry sharedScriptSuiteRegistry] commandDescriptionWithAppleEventClass:'bSiS'
499+ andAppleEventCode:'bSaP'];
500+ NSScriptCommand *command = [desc createCommandInstance];
515501 [command setDirectParameter:[self objectSpecifier]];
516-
517502 [command executeCommand];
518503 }
519504
520505 -(void)changeFileOfImage:(NSFileWrapper *)imageFileWrapper forIdentifier:(NSString *)identifier
521506 {
522- NSFileWrapper *fw;
523- NSString *filename;
524-
525- filename = [imageFileWrapper preferredFilename];
507+ NSString *filename = [imageFileWrapper preferredFilename];
526508
527509 if(filename && ![[filename stringByDeletingPathExtension] isEqualTo:identifier] ) {
528510 filename = [identifier stringByAppendingPathExtension:[filename pathExtension]];
529511 [imageFileWrapper setPreferredFilename:filename];
530512 }
531513
532- fw = [self fileWrapperForIdentifier:identifier];
514+ NSFileWrapper *fw = [self fileWrapperForIdentifier:identifier];
533515 if( fw ) {
534516 if( [fw isEqual:imageFileWrapper] ) {
535517 return;
--- a/IconTray-Dragging.m
+++ b/IconTray-Dragging.m
@@ -46,21 +46,14 @@
4646 }
4747 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
4848 {
49- NSPasteboard *pb;
50- NSArray *paths;
51- NSString *path;
52- NSArray *types;
5349 id oldImage = [self image];
54-
55- // NSLog(@"Enter %@.", NSStringFromSelector(_cmd));
56-
57- pb = [sender draggingPasteboard];
58- types = [pb types];
50+ NSPasteboard *pb = [sender draggingPasteboard];
51+ NSArray *types = [pb types];
5952
6053 if([types containsObject:NSFilesPromisePboardType]) {
6154 TemporaryFolder *tmp = [self temporaryFolder];
62- paths = [sender namesOfPromisedFilesDroppedAtDestination:[tmp url]];
63- path = [paths objectAtIndex:0];
55+ NSArray *paths = [sender namesOfPromisedFilesDroppedAtDestination:[tmp url]];
56+ NSString *path = [paths objectAtIndex:0];
6457
6558 path = [[tmp path] stringByAppendingPathComponent:path];
6659 [self setImageFilePath:path];