Changeset 319 for trunk/ICeCoffEE/ICeCoffEE/ICeCoffEE.m
- Timestamp:
- 06/11/07 01:21:55 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEE.m
r272 r319 291 291 // RFC-ordained max URL length, just to avoid passing IC/LS multi-megabyte documents 292 292 #if ICCF_DEBUG 293 const long ICCF_MAX_URL_LEN = 60; // XXX change later293 const long ICCF_MAX_URL_LEN = 120; // XXX change later 294 294 #else 295 295 const long ICCF_MAX_URL_LEN = 1024; … … 436 436 437 437 // returns YES if menu contains useful items, NO otherwise 438 BOOL ICCF_ConsolidateServicesMenu(NSMenu *menu, NSDictionary *serviceOptions ) {438 BOOL ICCF_ConsolidateServicesMenu(NSMenu *menu, NSDictionary *serviceOptions, NSDictionary *serviceInfo) { 439 439 [menu update]; // doesn't propagate to submenus, so we need to do this first 440 440 NSEnumerator *enumerator = [[menu itemArray] objectEnumerator]; 441 441 NSMenuItem *menuItem; 442 442 NSMenu *submenu; 443 NSDictionary *itemOptions = nil ;443 NSDictionary *itemOptions = nil, *itemInfo = nil; 444 444 BOOL shouldKeepItem = NO, shouldKeepMenu = NO; 445 445 … … 447 447 if (serviceOptions != nil) 448 448 itemOptions = [serviceOptions objectForKey: [menuItem title]]; 449 if (serviceInfo != nil) 450 itemInfo = [serviceInfo objectForKey: [menuItem title]]; 449 451 if ([[itemOptions objectForKey: (NSString *)kICServiceHidden] boolValue]) { 450 452 shouldKeepItem = NO; 451 453 } else if ( (submenu = [menuItem submenu]) != nil) { 452 shouldKeepItem = ICCF_ConsolidateServicesMenu(submenu, [itemOptions objectForKey: (NSString *)kICServiceSubmenu]); 454 // XXX don't rely on nil-sending working 455 shouldKeepItem = ICCF_ConsolidateServicesMenu(submenu, [itemOptions objectForKey: (NSString *)kICServiceSubmenu], itemInfo); 453 456 if (shouldKeepItem && [submenu numberOfItems] == 1) { // consolidate 454 457 NSMenuItem *serviceItem = [[submenu itemAtIndex: 0] retain]; 455 458 [serviceItem setTitle: 456 459 [NSString stringWithFormat: @"%@ %@ %@", [menuItem title], [NSString stringWithCharacters: &UNICHAR_BLACK_RIGHT_POINTING_SMALL_TRIANGLE length: 1], [serviceItem title]]]; 457 460 458 461 int serviceIndex = [menu indexOfItem: menuItem]; 459 462 [submenu removeItemAtIndex: 0]; // can't have item in two menus … … 461 464 [menu insertItem: serviceItem atIndex: serviceIndex]; 462 465 [serviceItem release]; 466 menuItem = serviceItem; 463 467 } 464 468 } else { … … 466 470 shouldKeepItem = [menuItem isEnabled]; 467 471 } 468 if (shouldKeepItem) { 469 shouldKeepMenu = YES; 470 } else { 472 if (!shouldKeepItem) { 471 473 [menu removeItem: menuItem]; 472 } 474 continue; 475 } 476 shouldKeepMenu = YES; 477 478 if (itemInfo == nil) continue; 479 NSString *bundlePath = (NSString *)[itemInfo objectForKey: (NSString *)kICServiceBundlePath]; 480 if (bundlePath == NULL) continue; 481 IconRef serviceIcon = ICCF_CopyIconRefForPath(bundlePath); 482 if (serviceIcon == NULL) continue; 483 [menuItem _setIconRef: serviceIcon]; 484 ReleaseIconRef(serviceIcon); 473 485 } 474 486 … … 478 490 NSMenuItem *ICCF_ContextualServicesMenuItem() { 479 491 NSMenuItem *servicesItem = ICCF_ServicesMenuItem(); 480 if (ICCF_ConsolidateServicesMenu([servicesItem submenu], (NSDictionary *)ICCF_prefs.serviceOptions)) 492 NSDictionary *servicesInfo = ICCF_GetServicesInfo(); // XXX cache/retain 493 if (ICCF_ConsolidateServicesMenu([servicesItem submenu], (NSDictionary *)ICCF_prefs.serviceOptions, servicesInfo)) 481 494 return servicesItem; 482 495 else
Note:
See TracChangeset
for help on using the changeset viewer.