mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 10:32:26 +00:00
Browser selection now populates the menu. Selection is not used and not saved for now.
This commit is contained in:
@@ -20,5 +20,9 @@
|
||||
@optional
|
||||
- (NSString *)label;
|
||||
- (NSImage *)image;
|
||||
/* Called when the tab is about to be selected and displayed */
|
||||
- (void)willSelectTab;
|
||||
/* Called whent the tab was selected and is being displayed */
|
||||
- (void)didSelectTab;
|
||||
|
||||
@end
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
NSLog(@"Warning. Unknow settingscontroller for identifier: %@. Did you miss to add the controller?", identifier);
|
||||
return;
|
||||
}
|
||||
if([tab respondsToSelector:@selector(willSelectTab)]) {
|
||||
[tab willSelectTab];
|
||||
}
|
||||
[self.toolbar setSelectedItemIdentifier:identifier];
|
||||
if([tab respondsToSelector:@selector(label)]) {
|
||||
[[self window] setTitle:[tab label]];
|
||||
@@ -83,6 +86,9 @@
|
||||
views:NSDictionaryOfVariableBindings(tabView)]];
|
||||
|
||||
[contentView layoutSubtreeIfNeeded];
|
||||
if([tab respondsToSelector:@selector(didSelectTab)]) {
|
||||
[tab didSelectTab];
|
||||
}
|
||||
[[self window] makeKeyAndOrderFront:[self window]];
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#import "MPSettingsTab.h"
|
||||
|
||||
@interface MPWorkflowSettingsController : MPViewController <MPSettingsTab>
|
||||
|
||||
@property (weak) IBOutlet NSPopUpButton *browserPopup;
|
||||
|
||||
- (IBAction)showCustomBrowserSelection:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#import "MPSettingsHelper.h"
|
||||
|
||||
NSString *const kMPChromeBundleId = @"com.google.chrome";
|
||||
NSString *const kMPSafariBundleId = @"com.apple.safari";
|
||||
NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
||||
|
||||
@interface MPWorkflowSettingsController ()
|
||||
|
||||
@end
|
||||
@@ -26,30 +22,8 @@ NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
}
|
||||
|
||||
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];
|
||||
[self _updateBrowserSelection];
|
||||
}
|
||||
|
||||
#pragma mark MPSettingsTab Protocol
|
||||
@@ -65,21 +39,53 @@ NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
||||
return NSLocalizedString(@"WORKFLOW_SETTINGS", "");
|
||||
}
|
||||
|
||||
- (void)willSelectTab {
|
||||
[self _updateBrowserSelection];
|
||||
}
|
||||
|
||||
#pragma mark Actions
|
||||
- (IBAction)selectBrowser:(id)sender {
|
||||
- (void)selectBrowser:(id)sender {
|
||||
NSString *browserBundleId = [sender representedObject];
|
||||
NSLog(@"New default Browser: %@", browserBundleId);
|
||||
[[NSUserDefaults standardUserDefaults] setObject:browserBundleId forKey:kMPSettingsKeyBrowserBundleId];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
- (void)showCustomBrowserSelection:(id)sender {
|
||||
NSAssert(NO,@"Not implemented!");
|
||||
}
|
||||
|
||||
#pragma mark Helper
|
||||
- (NSArray *)_availableBrowser {
|
||||
NSArray *browser = @[kMPChromeBundleId, kMPSafariBundleId, kMPFirefoxBundleId];
|
||||
for(NSString *bundle in browser) {
|
||||
|
||||
- (void)_updateBrowserSelection {
|
||||
/* Use a delegate ? */
|
||||
NSMenu *browserMenu = [[NSMenu alloc] init];
|
||||
[self.browserPopup setMenu:browserMenu];
|
||||
|
||||
[browserMenu addItemWithTitle:NSLocalizedString(@"DEFAULT_BROWSER", "Default Browser") action:NULL keyEquivalent:@""];
|
||||
[browserMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
for(NSString *bundleIdentifier in [self _bundleIdentifierForHTTPS]) {
|
||||
NSString *bundlePath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:bundleIdentifier];
|
||||
NSString *browserName = [[NSFileManager defaultManager] displayNameAtPath:bundlePath];
|
||||
NSMenuItem *browserItem = [[NSMenuItem alloc] initWithTitle:browserName action:@selector(selectBrowser:) keyEquivalent:@""];
|
||||
[browserItem setRepresentedObject:bundleIdentifier];
|
||||
[browserItem setTarget:self];
|
||||
[browserMenu addItem:browserItem];
|
||||
}
|
||||
return nil;
|
||||
|
||||
if([[browserMenu itemArray] count] > 2) {
|
||||
[browserMenu addItem:[NSMenuItem separatorItem]];
|
||||
}
|
||||
NSMenuItem *selectOtherBrowserItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"OTHER_BROWSER", "Selecte Browser")
|
||||
action:@selector(showCustomBrowserSelection:)
|
||||
keyEquivalent:@""];
|
||||
[selectOtherBrowserItem setTarget:self];
|
||||
[browserMenu addItem:selectOtherBrowserItem];
|
||||
}
|
||||
|
||||
- (NSArray *)_bundleIdentifierForHTTPS {
|
||||
NSArray *browserBundles = CFBridgingRelease(LSCopyAllHandlersForURLScheme(CFSTR("https")));
|
||||
return browserBundles;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
|
||||
|
||||
Reference in New Issue
Block a user