BathyScapheのアイコンセット生成&適用ツール
Revision | aa1117f03ce716aa3be49239bb5fec28eeebe7ec (tree) |
---|---|
Zeit | 2012-05-31 23:17:50 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
[Mod] ソースコード整理
@@ -127,26 +127,10 @@ enum { | ||
127 | 127 | |
128 | 128 | -(void)sendingSetColor:(ColorType)colorType |
129 | 129 | { |
130 | - NSString *bsBundleID; | |
131 | 130 | OSType type; |
132 | 131 | id targetColor; |
133 | - id tempColor; | |
134 | - CGFloat red, green, blue, alpha; | |
135 | 132 | OSStatus err; |
136 | 133 | |
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 | - | |
150 | 134 | switch(colorType) { |
151 | 135 | case kTypeThreadsListColor: |
152 | 136 | type = 'brCo'; |
@@ -160,40 +144,39 @@ enum { | ||
160 | 144 | } |
161 | 145 | |
162 | 146 | /* 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]; | |
165 | 149 | |
166 | 150 | /* Setting color */ |
151 | + NSAppleEventDescriptor *colorDesc = [NSAppleEventDescriptor listDescriptor];; | |
167 | 152 | if( targetColor ) { |
168 | - tempColor = [targetColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; | |
153 | + CGFloat red, green, blue, alpha; | |
154 | + id tempColor = [targetColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; | |
169 | 155 | [tempColor getRed:&red green:&green blue:&blue alpha:&alpha]; |
170 | 156 | |
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]; | |
174 | 160 | |
175 | 161 | colorDesc = [NSAppleEventDescriptor listDescriptor]; |
176 | 162 | [colorDesc insertDescriptor:redDesc atIndex:1]; |
177 | 163 | [colorDesc insertDescriptor:greenDesc atIndex:2]; |
178 | 164 | [colorDesc insertDescriptor:blueDesc atIndex:3]; |
179 | - } else { | |
180 | - | |
181 | - colorDesc = [NSAppleEventDescriptor listDescriptor]; | |
182 | 165 | } |
183 | 166 | |
184 | 167 | /* 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]; | |
190 | 173 | |
191 | 174 | /* 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]; | |
197 | 180 | |
198 | 181 | [ae setParamDescriptor:colorDesc forKeyword:keyAEData]; |
199 | 182 | [ae setParamDescriptor:propDesc forKeyword:keyDirectObject]; |
@@ -210,23 +193,12 @@ enum { | ||
210 | 193 | } |
211 | 194 | + (NSColor *)getBathyScapheColor:(ColorType)colorType |
212 | 195 | { |
213 | - NSString *bsBundleID; | |
214 | 196 | OSType type; |
215 | 197 | id result = nil; |
216 | - float red, green, blue; | |
217 | 198 | OSStatus err; |
218 | 199 | |
219 | 200 | [[IconSetComposer sharedInstance] launchBS]; |
220 | 201 | |
221 | - NSAppleEventDescriptor *replyDesc; | |
222 | - NSAppleEventDescriptor *colorComponentsDesc; | |
223 | - NSAppleEventDescriptor *colorComponentDesc; | |
224 | - | |
225 | - NSAppleEventDescriptor *ae; | |
226 | - NSAppleEventDescriptor *bsDesc; | |
227 | - NSAppleEventDescriptor *propDesc; | |
228 | - NSAppleEventDescriptor *keyDataDesc; | |
229 | - | |
230 | 202 | switch(colorType) { |
231 | 203 | case kTypeThreadsListColor: |
232 | 204 | type = 'brCo'; |
@@ -236,23 +208,23 @@ enum { | ||
236 | 208 | } |
237 | 209 | |
238 | 210 | /* 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]; | |
241 | 213 | |
242 | 214 | |
243 | 215 | /* 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]; | |
249 | 221 | |
250 | 222 | /* 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]; | |
256 | 228 | |
257 | 229 | [ae setParamDescriptor:propDesc forKeyword:keyDirectObject]; |
258 | 230 |
@@ -260,7 +232,7 @@ enum { | ||
260 | 232 | NSLog(@"%@", ae); |
261 | 233 | #endif |
262 | 234 | |
263 | - | |
235 | + NSAppleEventDescriptor *replyDesc; | |
264 | 236 | err = [ae sendAppleEventWithMode:kAECanInteract + kAEWaitReply |
265 | 237 | timeOutInTicks:kAEDefaultTimeout |
266 | 238 | reply:&replyDesc]; |
@@ -273,14 +245,14 @@ enum { | ||
273 | 245 | #ifdef DEBUG |
274 | 246 | NSLog(@"%@", replyDesc); |
275 | 247 | #endif |
276 | - | |
277 | - colorComponentsDesc = [replyDesc paramDescriptorForKeyword:keyDirectObject]; | |
248 | + NSAppleEventDescriptor *colorComponentDesc; | |
249 | + NSAppleEventDescriptor *colorComponentsDesc = [replyDesc paramDescriptorForKeyword:keyDirectObject]; | |
278 | 250 | colorComponentDesc = [colorComponentsDesc descriptorAtIndex:1]; |
279 | - red = [[colorComponentDesc stringValue] floatValue]; | |
251 | + CGFloat red = [[colorComponentDesc stringValue] floatValue]; | |
280 | 252 | colorComponentDesc = [colorComponentsDesc descriptorAtIndex:2]; |
281 | - green = [[colorComponentDesc stringValue] floatValue]; | |
253 | + CGFloat green = [[colorComponentDesc stringValue] floatValue]; | |
282 | 254 | colorComponentDesc = [colorComponentsDesc descriptorAtIndex:3]; |
283 | - blue = [[colorComponentDesc stringValue] floatValue]; | |
255 | + CGFloat blue = [[colorComponentDesc stringValue] floatValue]; | |
284 | 256 | |
285 | 257 | result = [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1]; |
286 | 258 |
@@ -333,15 +305,12 @@ enum { | ||
333 | 305 | |
334 | 306 | - (IBAction)changeColor:(id)sender |
335 | 307 | { |
336 | - int tag; | |
337 | - | |
338 | 308 | if( ![sender respondsToSelector:@selector(tag)] |
339 | 309 | && ![sender respondsToSelector:@selector(color)] ) { |
340 | 310 | return; |
341 | 311 | } |
342 | 312 | |
343 | - tag = [sender tag]; | |
344 | - switch(tag) { | |
313 | + switch([sender tag]) { | |
345 | 314 | case ThreadsListColorTag: |
346 | 315 | [self setThreadsListColor:[sender color]]; |
347 | 316 | break; |
@@ -352,14 +321,11 @@ enum { | ||
352 | 321 | |
353 | 322 | - (IBAction)revertColor:(id)sender |
354 | 323 | { |
355 | - int tag; | |
356 | - | |
357 | 324 | if( ![sender respondsToSelector:@selector(tag)] ) { |
358 | 325 | return; |
359 | 326 | } |
360 | 327 | |
361 | - tag = [sender tag]; | |
362 | - switch(tag) { | |
328 | + switch([sender tag]) { | |
363 | 329 | case ThreadsListColorTag: |
364 | 330 | [self setThreadsListColor:nil]; |
365 | 331 | break; |
@@ -382,15 +348,12 @@ enum { | ||
382 | 348 | } |
383 | 349 | - (BOOL)setPlistURL:(NSURL *)url |
384 | 350 | { |
385 | - NSDictionary *dict; | |
386 | - NSColor *color; | |
387 | - | |
388 | - dict = [NSDictionary dictionaryWithContentsOfURL:url]; | |
351 | + NSDictionary *dict = [NSDictionary dictionaryWithContentsOfURL:url]; | |
389 | 352 | if( !dict ) { |
390 | 353 | return NO; |
391 | 354 | } |
392 | 355 | |
393 | - color = [NSColor colorWithPlist:[dict objectForKey:ThreadsListColorKey]]; | |
356 | + NSColor *color = [NSColor colorWithPlist:[dict objectForKey:ThreadsListColorKey]]; | |
394 | 357 | [self setThreadsListColor:color]; |
395 | 358 | |
396 | 359 | [self setIncludeColors:[[dict objectForKey:IncludeColorsKey] boolValue]]; |
@@ -28,12 +28,11 @@ static IconSetComposer *_instance = nil; | ||
28 | 28 | andDecrementals:(NSArray *)decrementalImages |
29 | 29 | { |
30 | 30 | int result; |
31 | - // | |
31 | + | |
32 | 32 | NSString *title = NSLocalizedString( @"Caution!", @"Caution!" ); |
33 | 33 | NSString *message = @""; |
34 | 34 | NSString *defaultCaption = NSLocalizedString( @"Quit", @"Quit" ); |
35 | 35 | NSString *alternateCaption = NSLocalizedString( @"Continue", @"Continue" ); |
36 | -// NSString *otherCaption; | |
37 | 36 | |
38 | 37 | NSString *tmpString; |
39 | 38 | NSString *inc = nil; |
@@ -68,33 +67,25 @@ static IconSetComposer *_instance = nil; | ||
68 | 67 | } |
69 | 68 | -(BOOL)isSupportedBathyScaphe |
70 | 69 | { |
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]; | |
85 | 71 | if( !bsBundle ) { |
86 | 72 | return NO; |
87 | 73 | } |
88 | 74 | |
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]; | |
92 | 83 | |
93 | - managedImages = [IconSetDocument managedImageNames]; | |
94 | - managedImageNum = [managedImages count]; | |
84 | + NSArray *managedImages = [IconSetDocument managedImageNames]; | |
85 | + NSUInteger managedImageNum = [managedImages count]; | |
95 | 86 | |
96 | - knownBSSystemImages = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BathyScapheSystemImages" | |
97 | - ofType:@"plist"]]; | |
87 | + NSArray *knownBSSystemImages = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BathyScapheSystemImages" | |
88 | + ofType:@"plist"]]; | |
98 | 89 | |
99 | 90 | for(NSString *filename in bsResources) { |
100 | 91 | if( [[self class] isAcceptImageExtension:[filename pathExtension]] ) { |
@@ -137,11 +128,8 @@ static IconSetComposer *_instance = nil; | ||
137 | 128 | |
138 | 129 | +(NSBundle *)bathyScapheBundle |
139 | 130 | { |
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]; | |
145 | 133 | |
146 | 134 | return bsBundle; |
147 | 135 | } |
@@ -199,7 +187,7 @@ final: | ||
199 | 187 | { |
200 | 188 | static NSString *result = nil; |
201 | 189 | |
202 | - if( !result ) { | |
190 | + if( !result ) { | |
203 | 191 | NSArray *dirs = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask, YES ); |
204 | 192 | NSString *tmp; |
205 | 193 |
@@ -219,7 +207,7 @@ final: | ||
219 | 207 | { |
220 | 208 | static NSString *result = nil; |
221 | 209 | |
222 | - if( !result ) { | |
210 | + if( !result ) { | |
223 | 211 | NSString *tmp; |
224 | 212 | |
225 | 213 | result = [self bathyScapheSupportFolder]; |
@@ -261,12 +249,8 @@ final: | ||
261 | 249 | +(NSImage *)defaultImageForIdentifier:(NSString *)identifier |
262 | 250 | { |
263 | 251 | 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]; | |
270 | 254 | |
271 | 255 | return image; |
272 | 256 | } |
@@ -345,19 +329,16 @@ final: | ||
345 | 329 | -(long)quitBS |
346 | 330 | { |
347 | 331 | OSStatus err; |
348 | - NSAppleEventDescriptor *ae; | |
349 | - NSAppleEventDescriptor *bsDesc; | |
350 | 332 | |
351 | 333 | /* set up BathyScaphe addr */ |
352 | - bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:[self bathyScapheIdentifier]]; | |
334 | + NSAppleEventDescriptor *bsDesc = [NSAppleEventDescriptor targetDescriptorWithApplicationIdentifier:[self bathyScapheIdentifier]]; | |
353 | 335 | |
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]; | |
359 | 341 | |
360 | -// err = AESendMessage( [ae aeDesc], NULL, kAECanInteract, kAEDefaultTimeout ); | |
361 | 342 | err = [ae sendAppleEventWithMode:kAECanInteract | kAEWaitReply |
362 | 343 | timeOutInTicks:kAEDefaultTimeout |
363 | 344 | reply:NULL]; |
@@ -404,14 +385,9 @@ final: | ||
404 | 385 | } |
405 | 386 | -(IBAction)createDocumentFromCurrentSetting:(id)sender |
406 | 387 | { |
407 | - NSString *bsSupPath = [[self class] bathyScapheSupportFolder]; | |
408 | - NSBundle *bsSupBundle; | |
409 | 388 | 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]; | |
415 | 391 | |
416 | 392 | if(!imageNames || !bsSupBundle) { |
417 | 393 | NSLog(@"HOGE!!"); |
@@ -419,9 +395,8 @@ final: | ||
419 | 395 | return; |
420 | 396 | } |
421 | 397 | |
422 | - newDocument = [[NSDocumentController sharedDocumentController] | |
423 | - openUntitledDocumentOfType:@"IconSetType" | |
424 | - display:NO]; | |
398 | + IconSetDocument *newDocument = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"IconSetType" | |
399 | + display:NO]; | |
425 | 400 | if(!newDocument) { |
426 | 401 | NSLog(@"Can not create new document."); |
427 | 402 | NSBeep(); |
@@ -429,7 +404,7 @@ final: | ||
429 | 404 | } |
430 | 405 | |
431 | 406 | for(NSString *imageName in imageNames) { |
432 | - imagePath = [bsSupBundle pathForImageResource:imageName]; | |
407 | + NSString *imagePath = [bsSupBundle pathForImageResource:imageName]; | |
433 | 408 | [newDocument setPath:imagePath forIdentifier:imageName]; |
434 | 409 | } |
435 | 410 |
@@ -285,14 +285,12 @@ static NSArray *sThreadIdentifiers; | ||
285 | 285 | |
286 | 286 | -(void)didChangeColorSet:(ColorSet *)set |
287 | 287 | { |
288 | - NSString *identifier; | |
289 | - NSDictionary *plist; | |
290 | 288 | NSFileWrapper *fw; |
291 | 289 | NSString *path; |
292 | 290 | TemporaryFolder *t = [TemporaryFolder temporaryFolder]; |
293 | 291 | |
294 | - identifier = [set identifier]; | |
295 | - plist = [set plist]; | |
292 | + NSString *identifier = [set identifier]; | |
293 | + NSDictionary *plist = [set plist]; | |
296 | 294 | if( !plist && ![plist respondsToSelector:@selector(writeToFile:atomically:)] ) { |
297 | 295 | return; |
298 | 296 | } |
@@ -451,31 +449,23 @@ static NSArray *sThreadIdentifiers; | ||
451 | 449 | |
452 | 450 | -(void)updateAll |
453 | 451 | { |
454 | - id keys = [[wrapper fileWrappers] keyEnumerator]; | |
455 | - id identifier; | |
456 | - | |
457 | - while( identifier = [keys nextObject] ) { | |
452 | + for(id identifier in [wrapper fileWrappers]) { | |
458 | 453 | identifier = [identifier stringByDeletingPathExtension]; |
459 | 454 | [self updateForKey:identifier]; |
460 | 455 | } |
461 | 456 | } |
462 | 457 | -(void)updateForKey:(NSString *)key |
463 | 458 | { |
464 | - NSImage *image; | |
465 | - NSFileWrapper *fw; | |
466 | - NSData *data; | |
467 | - NSString *filename; | |
468 | - | |
469 | - fw = [self fileWrapperForIdentifier:key]; | |
459 | + NSFileWrapper *fw = [self fileWrapperForIdentifier:key]; | |
470 | 460 | if( !fw ) { |
471 | 461 | // NSLog(@"can't load image for %@", key); |
472 | 462 | return; |
473 | 463 | } |
474 | 464 | |
475 | - data = [fw regularFileContents]; | |
476 | - image = [[[NSImage alloc] initWithData:data] autorelease]; | |
465 | + NSData *data = [fw regularFileContents]; | |
466 | + NSImage *image = [[[NSImage alloc] initWithData:data] autorelease]; | |
477 | 467 | if( !image ) { |
478 | - filename = [fw filename]; | |
468 | + NSString *filename = [fw filename]; | |
479 | 469 | if( !filename ) return; |
480 | 470 | NSURL *bundleURL = [self fileURL]; |
481 | 471 | NSURL *colorSetURL = [bundleURL URLByAppendingPathComponent:filename]; |
@@ -505,31 +495,23 @@ static NSArray *sThreadIdentifiers; | ||
505 | 495 | |
506 | 496 | -(void)applyAndRestartBathyScaphe:(id)sender |
507 | 497 | { |
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]; | |
515 | 501 | [command setDirectParameter:[self objectSpecifier]]; |
516 | - | |
517 | 502 | [command executeCommand]; |
518 | 503 | } |
519 | 504 | |
520 | 505 | -(void)changeFileOfImage:(NSFileWrapper *)imageFileWrapper forIdentifier:(NSString *)identifier |
521 | 506 | { |
522 | - NSFileWrapper *fw; | |
523 | - NSString *filename; | |
524 | - | |
525 | - filename = [imageFileWrapper preferredFilename]; | |
507 | + NSString *filename = [imageFileWrapper preferredFilename]; | |
526 | 508 | |
527 | 509 | if(filename && ![[filename stringByDeletingPathExtension] isEqualTo:identifier] ) { |
528 | 510 | filename = [identifier stringByAppendingPathExtension:[filename pathExtension]]; |
529 | 511 | [imageFileWrapper setPreferredFilename:filename]; |
530 | 512 | } |
531 | 513 | |
532 | - fw = [self fileWrapperForIdentifier:identifier]; | |
514 | + NSFileWrapper *fw = [self fileWrapperForIdentifier:identifier]; | |
533 | 515 | if( fw ) { |
534 | 516 | if( [fw isEqual:imageFileWrapper] ) { |
535 | 517 | return; |
@@ -46,21 +46,14 @@ | ||
46 | 46 | } |
47 | 47 | - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender |
48 | 48 | { |
49 | - NSPasteboard *pb; | |
50 | - NSArray *paths; | |
51 | - NSString *path; | |
52 | - NSArray *types; | |
53 | 49 | 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]; | |
59 | 52 | |
60 | 53 | if([types containsObject:NSFilesPromisePboardType]) { |
61 | 54 | 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]; | |
64 | 57 | |
65 | 58 | path = [[tmp path] stringByAppendingPathComponent:path]; |
66 | 59 | [self setImageFilePath:path]; |