PageRenderTime 32ms CodeModel.GetById 18ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/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
19#import "GTMXcodeMenuItem.h"
20#import "GTMXcodePlugin.h"
21
22// Handles the about GTM Xcode Plugin menu item in the Application menu.
23@interface GTMXcodeAboutItem : GTMXcodeMenuItem
24@end
25
26@implementation GTMXcodeAboutItem
27+ (void)load {
28  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
29  [GTMXcodePlugin registerMenuItem:[[[self alloc] init] autorelease]];
30  [pool release];
31}
32
33- (NSString*)title {
34  return @"About GTM Xcode Plugin";
35}
36
37- (void)action:(id)sender {
38  NSBundle *mainBundle = [GTMXcodePlugin pluginBundle];
39  NSString *creditsPath = [mainBundle pathForResource:@"Credits" ofType:@"rtf"];
40  NSAttributedString *credits
41    = [[[NSAttributedString alloc] initWithPath:creditsPath
42                             documentAttributes:nil] autorelease];
43
44  NSString *path = [mainBundle pathForResource:@"GTM"
45                                        ofType:@"icns"];
46  NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
47  NSDictionary *optionsDict = [NSDictionary dictionaryWithObjectsAndKeys:
48    credits, @"Credits",
49    [mainBundle objectForInfoDictionaryKey:@"CFBundleName"], 
50    @"ApplicationName",
51    [mainBundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], 
52    @"Copyright",
53    [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], 
54    @"ApplicationVersion",
55    @"", @"Version",
56    icon, @"ApplicationIcon",
57    nil];
58  [NSApp orderFrontStandardAboutPanelWithOptions:optionsDict];
59}
60
61- (NSMenu*)insertionMenu {
62  NSMenu *rootMenu = [NSApp mainMenu];
63  NSMenuItem *appleMenuItem = [rootMenu itemAtIndex:0];
64  return [appleMenuItem submenu];
65}
66
67- (int)insertionIndex {
68  return 1;
69}
70@end