Stubbed workflow settings to select preferred browser for URL handling

This commit is contained in:
michael starke
2013-12-01 23:10:52 +01:00
parent f266375a09
commit bb88534daa
3 changed files with 52 additions and 7 deletions

View File

@@ -10,5 +10,6 @@
#import "MPSettingsTab.h"
@interface MPWorkflowSettingsController : MPViewController <MPSettingsTab>
@property (weak) IBOutlet NSPopUpButton *browserPopup;
@end

View File

@@ -8,12 +8,19 @@
#import "MPWorkflowSettingsController.h"
#import "MPSettingsHelper.h"
NSString *const kMPChromeBundleId = @"com.google.chrome";
NSString *const kMPSafariBundleId = @"com.apple.safari";
NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
@interface MPWorkflowSettingsController ()
@end
@implementation MPWorkflowSettingsController
#pragma mark LifeCycle
- (id)init {
self = [self initWithNibName:@"WorkflowSettings" bundle:nil];
return self;
@@ -27,6 +34,25 @@
return self;
}
- (void)didLoadView {
NSMenu *browserMenu = [[NSMenu alloc] init];
[browserMenu addItemWithTitle:NSLocalizedString(@"DEFAULT_BROWSER", "Default Browser") action:NULL keyEquivalent:@""];
[browserMenu addItem:[NSMenuItem separatorItem]];
NSArray *browser = @[kMPChromeBundleId, kMPSafariBundleId, kMPFirefoxBundleId];
for(NSString *bundle in browser) {
}
if([[browserMenu itemArray] count] > 2) {
[browserMenu addItem:[NSMenuItem separatorItem]];
}
[browserMenu addItemWithTitle:NSLocalizedString(@"OTHER_BROWSER", "Selecte Browser") action:NULL keyEquivalent:@""];
[self.browserPopup setMenu:browserMenu];
}
#pragma mark MPSettingsTab Protocol
- (NSString *)identifier {
return @"WorkflowSettings";
}
@@ -39,4 +65,21 @@
return NSLocalizedString(@"WORKFLOW", "");
}
#pragma mark Actions
- (IBAction)selectBrowser:(id)sender {
NSString *browserBundleId = [sender representedObject];
NSLog(@"New default Browser: %@", browserBundleId);
[[NSUserDefaults standardUserDefaults] setObject:browserBundleId forKey:kMPSettingsKeyBrowserBundleId];
[[NSUserDefaults standardUserDefaults] synchronize];
}
#pragma mark Helper
- (NSArray *)_availableBrowser {
NSArray *browser = @[kMPChromeBundleId, kMPSafariBundleId, kMPFirefoxBundleId];
for(NSString *bundle in browser) {
}
return nil;
}
@end

View File

@@ -7,6 +7,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPWorkflowSettingsController">
<connections>
<outlet property="browserPopup" destination="ehI-gq-lsb" id="YMy-L1-pQw"/>
<outlet property="view" destination="1" id="52"/>
</connections>
</customObject>
@@ -35,12 +36,12 @@
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="13">
<rect key="frame" x="161" y="42" width="105" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Copies URL" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="14">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="14">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="15">
<items>
<menuItem title="Copies URL" state="on" id="16"/>
<menuItem title="Copies URL" id="16"/>
<menuItem title="Opens URL" id="17"/>
</items>
</menu>
@@ -58,12 +59,12 @@
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="40">
<rect key="frame" x="161" y="11" width="136" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Opens Inspector" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="41">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="41">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="42">
<items>
<menuItem title="Opens Inspector" state="on" id="44"/>
<menuItem title="Opens Inspector" id="44"/>
<menuItem title="is Ignored" id="43"/>
</items>
</menu>
@@ -92,7 +93,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Default Browser" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="7YX-EA-9KA" id="7Ip-sU-sAK">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="XgO-Tj-QjO">
<items>
<menuItem title="Default Browser" state="on" id="7YX-EA-9KA"/>