/core/externals/update-engine/externals/google-toolbox-for-mac/XcodePlugin/GTMXcodeAboutItem.m

http://macfuse.googlecode.com/ · Objective C · 70 lines · 44 code · 8 blank · 18 comment · 0 complexity · ba0f94bb86066f3377a2c80e7ac226cd MD5 · raw file

  1. //
  2. // GTMXcodeAboutItem.m
  3. //
  4. // Copyright 2007-2009 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. #import "GTMXcodeMenuItem.h"
  19. #import "GTMXcodePlugin.h"
  20. // Handles the about GTM Xcode Plugin menu item in the Application menu.
  21. @interface GTMXcodeAboutItem : GTMXcodeMenuItem
  22. @end
  23. @implementation GTMXcodeAboutItem
  24. + (void)load {
  25. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  26. [GTMXcodePlugin registerMenuItem:[[[self alloc] init] autorelease]];
  27. [pool release];
  28. }
  29. - (NSString*)title {
  30. return @"About GTM Xcode Plugin";
  31. }
  32. - (void)action:(id)sender {
  33. NSBundle *mainBundle = [GTMXcodePlugin pluginBundle];
  34. NSString *creditsPath = [mainBundle pathForResource:@"Credits" ofType:@"rtf"];
  35. NSAttributedString *credits
  36. = [[[NSAttributedString alloc] initWithPath:creditsPath
  37. documentAttributes:nil] autorelease];
  38. NSString *path = [mainBundle pathForResource:@"GTM"
  39. ofType:@"icns"];
  40. NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
  41. NSDictionary *optionsDict = [NSDictionary dictionaryWithObjectsAndKeys:
  42. credits, @"Credits",
  43. [mainBundle objectForInfoDictionaryKey:@"CFBundleName"],
  44. @"ApplicationName",
  45. [mainBundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"],
  46. @"Copyright",
  47. [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
  48. @"ApplicationVersion",
  49. @"", @"Version",
  50. icon, @"ApplicationIcon",
  51. nil];
  52. [NSApp orderFrontStandardAboutPanelWithOptions:optionsDict];
  53. }
  54. - (NSMenu*)insertionMenu {
  55. NSMenu *rootMenu = [NSApp mainMenu];
  56. NSMenuItem *appleMenuItem = [rootMenu itemAtIndex:0];
  57. return [appleMenuItem submenu];
  58. }
  59. - (int)insertionIndex {
  60. return 1;
  61. }
  62. @end