Skip to content

Commit

Permalink
Support for #22.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed Dec 15, 2016
1 parent 959bad9 commit c87cc9d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 3 deletions.
18 changes: 16 additions & 2 deletions CCMenu/CCMenu-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
<dict>
<key>CCMSourceVersion</key>
<string>#gitsha#</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>org.ccmenu</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ccmenu+http</string>
<string>ccmenu+https</string>
</array>
</dict>
</array>
<key>CFBundleDisplayName</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -19,11 +33,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>12.1</string>
<string>13.0d1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1121.2</string>
<string>1130.1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
20 changes: 20 additions & 0 deletions CCMenu/Classes/CCMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

@implementation CCMAppController

- (void)registerURLScheme
{
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
}

- (void)setupRequestCache
{
NSURLCache *cache = [NSURLCache sharedURLCache];
Expand Down Expand Up @@ -48,6 +54,11 @@ - (void)startServices
[userNotificationHandler start];
}

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
[self registerURLScheme];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
@try
Expand All @@ -69,4 +80,13 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
}
}


- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
url = [url stringByReplacingOccurrencesOfString:@"ccmenu+" withString:@"" options:NSAnchoredSearch range:NSMakeRange(0, [url length])];
[preferencesController addProjectsForURL:url];
}


@end
1 change: 1 addition & 0 deletions CCMenu/Classes/CCMPreferencesController.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- (IBAction)preferencesChanged:(id)sender;
- (IBAction)activationPolicyChanged:(id)sender;

- (void)addProjectsForURL:(NSString *)url;

@end

Expand Down
15 changes: 15 additions & 0 deletions CCMenu/Classes/CCMPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ - (void)editProject:(id)sender
[addProjectsController beginEditSheetWithProject:[self selectedProject] forWindow:preferencesWindow];
}

- (void)addProjectsForURL:(NSString *)url
{
[NSThread sleepForTimeInterval:0.2];

[self showWindow:self];

[[preferencesWindow toolbar] setSelectedItemIdentifier:@"Projects"];
[self switchPreferencesPane:self];

// slightly naughty but we want to split the XIB files eventually
[addProjectsController setValue:defaultsManager forKey:@"defaultsManager"];
[addProjectsController beginAddSheetWithURL:url forWindow:preferencesWindow];
}


- (void)removeProjects:(id)sender
{
[allProjectsViewController remove:sender];
Expand Down
1 change: 1 addition & 0 deletions CCMenu/Classes/CCMProjectSheetController.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


- (void)beginAddSheetForWindow:(NSWindow *)aWindow;
- (void)beginAddSheetWithURL:(NSString *)url forWindow:(NSWindow *)aWindow;
- (void)beginEditSheetWithProject:(NSDictionary *)aProject forWindow:(NSWindow *)aWindow;
- (void)beginSheetForWindow:(NSWindow *)aWindow contextInfo:(void *)contextInfo;
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
Expand Down
10 changes: 10 additions & 0 deletions CCMenu/Classes/CCMProjectSheetController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ - (void)beginAddSheetForWindow:(NSWindow *)aWindow
[self beginSheetForWindow:aWindow contextInfo:NULL];
}

- (void)beginAddSheetWithURL:(NSString *)url forWindow:(NSWindow *)aWindow
{
[urlComboBox setStringValue:url];
[serverTypeMatrix selectCellWithTag:CCMUseGivenURL];
[continueButton setTag:CCMButtonContinue];
[continueButton setTitle:SHEET_CONTINUE_BUTTON];
[self beginSheetForWindow:aWindow contextInfo:NULL];
[continueButton performClick:self];
}

- (void)beginEditSheetWithProject:(NSDictionary *)aProject forWindow:(NSWindow *)aWindow
{
[urlComboBox setStringValue:[aProject objectForKey:@"serverUrl"]];
Expand Down
7 changes: 7 additions & 0 deletions RELEASENOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CCMenu Release Notes


CCMenu 13.0 (not released yet)

* CCMenu now registers its own URL schemes. This makes it possible to create
links on webpages that, when clicked, will open CCMenu and show a prefilled
list of projects to add.


CCMenu 12.1

* Fix for incompatibility with OS X 10.8/10.9 that was introduced in
Expand Down
3 changes: 2 additions & 1 deletion Tools/fakeserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def is_building()
%input{:type => "submit", :value => "Success", :disabled => !is_building() }
%form{:name => "input", :action => "control/failure", :method => "post"}
%input{:type => "submit", :value => "Failure", :disabled => !is_building() }

%p
%a{:href => "ccmenu+http://localhost:4567/cctray.xml"} Add a project to CCMenu

@@ cctray
!!! XML
Expand Down

0 comments on commit c87cc9d

Please sign in to comment.