mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-15 14:52:28 +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
|
@optional
|
||||||
- (NSString *)label;
|
- (NSString *)label;
|
||||||
- (NSImage *)image;
|
- (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
|
@end
|
||||||
|
|||||||
@@ -59,6 +59,9 @@
|
|||||||
NSLog(@"Warning. Unknow settingscontroller for identifier: %@. Did you miss to add the controller?", identifier);
|
NSLog(@"Warning. Unknow settingscontroller for identifier: %@. Did you miss to add the controller?", identifier);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if([tab respondsToSelector:@selector(willSelectTab)]) {
|
||||||
|
[tab willSelectTab];
|
||||||
|
}
|
||||||
[self.toolbar setSelectedItemIdentifier:identifier];
|
[self.toolbar setSelectedItemIdentifier:identifier];
|
||||||
if([tab respondsToSelector:@selector(label)]) {
|
if([tab respondsToSelector:@selector(label)]) {
|
||||||
[[self window] setTitle:[tab label]];
|
[[self window] setTitle:[tab label]];
|
||||||
@@ -83,6 +86,9 @@
|
|||||||
views:NSDictionaryOfVariableBindings(tabView)]];
|
views:NSDictionaryOfVariableBindings(tabView)]];
|
||||||
|
|
||||||
[contentView layoutSubtreeIfNeeded];
|
[contentView layoutSubtreeIfNeeded];
|
||||||
|
if([tab respondsToSelector:@selector(didSelectTab)]) {
|
||||||
|
[tab didSelectTab];
|
||||||
|
}
|
||||||
[[self window] makeKeyAndOrderFront:[self window]];
|
[[self window] makeKeyAndOrderFront:[self window]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#import "MPSettingsTab.h"
|
#import "MPSettingsTab.h"
|
||||||
|
|
||||||
@interface MPWorkflowSettingsController : MPViewController <MPSettingsTab>
|
@interface MPWorkflowSettingsController : MPViewController <MPSettingsTab>
|
||||||
|
|
||||||
@property (weak) IBOutlet NSPopUpButton *browserPopup;
|
@property (weak) IBOutlet NSPopUpButton *browserPopup;
|
||||||
|
|
||||||
|
- (IBAction)showCustomBrowserSelection:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -10,10 +10,6 @@
|
|||||||
|
|
||||||
#import "MPSettingsHelper.h"
|
#import "MPSettingsHelper.h"
|
||||||
|
|
||||||
NSString *const kMPChromeBundleId = @"com.google.chrome";
|
|
||||||
NSString *const kMPSafariBundleId = @"com.apple.safari";
|
|
||||||
NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
|
||||||
|
|
||||||
@interface MPWorkflowSettingsController ()
|
@interface MPWorkflowSettingsController ()
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -26,30 +22,8 @@ NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
||||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
||||||
if (self) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)didLoadView {
|
- (void)didLoadView {
|
||||||
NSMenu *browserMenu = [[NSMenu alloc] init];
|
[self _updateBrowserSelection];
|
||||||
[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
|
#pragma mark MPSettingsTab Protocol
|
||||||
@@ -65,21 +39,53 @@ NSString *const kMPFirefoxBundleId = @"org.mozilla.firefox";
|
|||||||
return NSLocalizedString(@"WORKFLOW_SETTINGS", "");
|
return NSLocalizedString(@"WORKFLOW_SETTINGS", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)willSelectTab {
|
||||||
|
[self _updateBrowserSelection];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark Actions
|
#pragma mark Actions
|
||||||
- (IBAction)selectBrowser:(id)sender {
|
- (void)selectBrowser:(id)sender {
|
||||||
NSString *browserBundleId = [sender representedObject];
|
NSString *browserBundleId = [sender representedObject];
|
||||||
NSLog(@"New default Browser: %@", browserBundleId);
|
NSLog(@"New default Browser: %@", browserBundleId);
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:browserBundleId forKey:kMPSettingsKeyBrowserBundleId];
|
[[NSUserDefaults standardUserDefaults] setObject:browserBundleId forKey:kMPSettingsKeyBrowserBundleId];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark Helper
|
- (void)showCustomBrowserSelection:(id)sender {
|
||||||
- (NSArray *)_availableBrowser {
|
NSAssert(NO,@"Not implemented!");
|
||||||
NSArray *browser = @[kMPChromeBundleId, kMPSafariBundleId, kMPFirefoxBundleId];
|
|
||||||
for(NSString *bundle in browser) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil;
|
|
||||||
|
#pragma mark Helper
|
||||||
|
- (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];
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
@end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?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>
|
<dependencies>
|
||||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user