Skip to content

Commit

Permalink
Merge branch 'georgesnow-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarke committed Aug 20, 2019
2 parents ca33444 + eaf1820 commit 4d2b49b
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 10 deletions.
47 changes: 45 additions & 2 deletions AutotypeURL.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
4C8139322281FD3900092FD7 /* ATUAutotypeURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8139312281FD3900092FD7 /* ATUAutotypeURL.m */; };
4C93F3C022859C54005C8A3D /* ATUSafariExtractor.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F3BF22859C54005C8A3D /* ATUSafariExtractor.m */; };
4C93F3C322859E46005C8A3D /* ATUChromeExtractor.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F3C222859E46005C8A3D /* ATUChromeExtractor.m */; };
7E9B915822D911BA0017A2BA /* ATUSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9B915622D911B90017A2BA /* ATUSettingsViewController.m */; };
7E9B915922D911BA0017A2BA /* AutotypeURLSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E9B915722D911BA0017A2BA /* AutotypeURLSettings.xib */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -22,6 +24,9 @@
4C93F3BF22859C54005C8A3D /* ATUSafariExtractor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ATUSafariExtractor.m; sourceTree = "<group>"; };
4C93F3C122859E46005C8A3D /* ATUChromeExtractor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ATUChromeExtractor.h; sourceTree = "<group>"; };
4C93F3C222859E46005C8A3D /* ATUChromeExtractor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ATUChromeExtractor.m; sourceTree = "<group>"; };
7E9B915522D911B90017A2BA /* ATUSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATUSettingsViewController.h; sourceTree = "<group>"; };
7E9B915622D911B90017A2BA /* ATUSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ATUSettingsViewController.m; sourceTree = "<group>"; };
7E9B915722D911BA0017A2BA /* AutotypeURLSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AutotypeURLSettings.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -54,6 +59,7 @@
4C8139292281FBC200092FD7 /* AutotypeURL */ = {
isa = PBXGroup;
children = (
7E9B915422D911A80017A2BA /* Settings */,
4C81392A2281FBC200092FD7 /* Info.plist */,
4C8139302281FD3900092FD7 /* ATUAutotypeURL.h */,
4C8139312281FD3900092FD7 /* ATUAutotypeURL.m */,
Expand All @@ -66,6 +72,16 @@
path = AutotypeURL;
sourceTree = "<group>";
};
7E9B915422D911A80017A2BA /* Settings */ = {
isa = PBXGroup;
children = (
7E9B915722D911BA0017A2BA /* AutotypeURLSettings.xib */,
7E9B915522D911B90017A2BA /* ATUSettingsViewController.h */,
7E9B915622D911B90017A2BA /* ATUSettingsViewController.m */,
);
path = Settings;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -75,6 +91,7 @@
buildPhases = (
4C8139232281FBC200092FD7 /* Sources */,
4C8139242281FBC200092FD7 /* Frameworks */,
4C6B333A230C32EE00A6C127 /* Versioning */,
4C8139252281FBC200092FD7 /* Resources */,
);
buildRules = (
Expand Down Expand Up @@ -123,17 +140,40 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7E9B915922D911BA0017A2BA /* AutotypeURLSettings.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4C6B333A230C32EE00A6C127 /* Versioning */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = Versioning;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "git=`sh /etc/profile; which git`\nbranch_name=`$git rev-parse --abbrev-ref HEAD`\ngit_count=`$git rev-list $branch_name |wc -l | sed 's/^ *//;s/ *$//'`\n\nbuild_number=\"${git_count}\"\nif [ $CONFIGURATION != \"Release\" ] || [ $branch_name != \"master\" ]; then\nbuild_number+=\"-$branch_name\"\nfi\nif [ \"$CI\" = \"true\" ]; then\nbuild_date=`date +\"%Y%m%d%H%m%S\"`\nbuild_number=\"$build_date-continuous\"\nfi\n\nplist=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\ndsym_plist=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $build_number\" \"$plist\"\nif [ -f \"$DSYM_INFO_PLIST\" ] ; then\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $build_number\" \"$dsym_plist\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
4C8139232281FBC200092FD7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C8139322281FD3900092FD7 /* ATUAutotypeURL.m in Sources */,
7E9B915822D911BA0017A2BA /* ATUSettingsViewController.m in Sources */,
4C93F3C022859C54005C8A3D /* ATUSafariExtractor.m in Sources */,
4C93F3C322859E46005C8A3D /* ATUChromeExtractor.m in Sources */,
);
Expand Down Expand Up @@ -199,7 +239,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -262,7 +302,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = (
Expand All @@ -278,6 +318,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.2;
DEPLOYMENT_LOCATION = YES;
DSTROOT = "$(HOME)";
INFOPLIST_FILE = AutotypeURL/Info.plist;
Expand All @@ -292,8 +333,10 @@
4C81392F2281FBC200092FD7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.2;
DEPLOYMENT_LOCATION = YES;
DSTROOT = "$(HOME)";
INFOPLIST_FILE = AutotypeURL/Info.plist;
Expand Down
4 changes: 3 additions & 1 deletion AutotypeURL/ATUAutotypeURL.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

NS_ASSUME_NONNULL_BEGIN

@interface ATUAutotypeURL : MPPlugin <MPAutotypeWindowTitleResolverPlugin>
FOUNDATION_EXPORT NSString *const kMPASettingsKeyFullMatch;

@interface ATUAutotypeURL : MPPlugin <MPPluginSettings, MPAutotypeWindowTitleResolverPlugin>;

@end

Expand Down
40 changes: 35 additions & 5 deletions AutotypeURL/ATUAutotypeURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,32 @@
#import "ATUAutotypeURL.h"
#import "ATUSafariExtractor.h"
#import "ATUChromeExtractor.h"
#import "ATUSettingsViewController.h"


NSString *const kMPASettingsKeyFullMatch = @"kMPASettingsKeyFullMatch";

@interface ATUAutotypeURL ()

@property (strong) NSDictionary<NSString *, id<ATUURLExtraction>> *extractors;

@property (nonatomic) BOOL fullMatchEnabled;

@end

@implementation ATUAutotypeURL
@synthesize settingsViewController = _settingsViewController;


+(void)initialize{
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ kMPASettingsKeyFullMatch : @NO }];
}

- (instancetype)initWithPluginHost:(MPPluginHost *)host {
self = [super initWithPluginHost:host];
if(self) {


ATUChromeExtractor *chrome = [[ATUChromeExtractor alloc] init];
ATUSafariExtractor *safari = [[ATUSafariExtractor alloc] init];
self.extractors = @{
Expand All @@ -38,14 +52,30 @@ - (BOOL)acceptsRunningApplication:(nonnull NSRunningApplication *)runningApplica

- (nonnull NSString *)windowTitleForRunningApplication:(nonnull NSRunningApplication *)runningApplication {
id<ATUURLExtraction> extractor = self.extractors[runningApplication.bundleIdentifier];
if(extractor) {
NSString *urlString = [extractor URLForRunningApplication:runningApplication];
NSURL *url = [[NSURL alloc] initWithString:urlString];
return url.host.length > 0 ? url.host : @"";

if(!extractor) {
return @"";
}
return @"";

BOOL fullMatch = [NSUserDefaults.standardUserDefaults boolForKey:kMPASettingsKeyFullMatch];

NSString *urlString = [extractor URLForRunningApplication:runningApplication];
NSURL *url = [[NSURL alloc] initWithString:urlString];

if(fullMatch) {
return url.host.length > 0 ? urlString : @"";
}
return url.host.length > 0 ? url.host : @"";
}

- (NSViewController *)settingsViewController {
if(!_settingsViewController) {
_settingsViewController = [[ATUSettingsViewController alloc] init];
}
return _settingsViewController;
}


@end


4 changes: 2 additions & 2 deletions AutotypeURL/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>UNKNOWN</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 HicknHack Software GmbH. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
15 changes: 15 additions & 0 deletions AutotypeURL/Settings/ATUSettingsViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ATUSettingsViewController.h
// AutotypeURL
//
// Created by George Snow on 7/10/19.
// Copyright © 2019 George Snow All rights reserved.
//

#import <Cocoa/Cocoa.h>

@class ATUAutotypeURL;

@interface ATUSettingsViewController : NSViewController

@end
55 changes: 55 additions & 0 deletions AutotypeURL/Settings/ATUSettingsViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// ATUSettingsViewController.m
// AutotypeURL
//
// Created by George Snow on 7/10/19.
// Copyright © 2019 George Snow All rights reserved.
//

#import "ATUSettingsViewController.h"
#import "ATUAutotypeURL.h"

@interface ATUSettingsViewController ()

@property (strong) IBOutlet NSButton *useCompleteURLAsWindowTitleButton;
@property (strong) IBOutlet NSButton *useURLHostAsWindowTitleButton;

- (IBAction)toggleWindowTitleBehaviour:(id)sender;

@end

@implementation ATUSettingsViewController

- (void)dealloc {
[self.useCompleteURLAsWindowTitleButton unbind:NSValueBinding];
}

- (NSBundle *)nibBundle {
return [NSBundle bundleForClass:self.class];
}

- (NSString *)nibName {
return @"AutotypeURLSettings";
}

- (void)viewDidLoad {
BOOL useCompletURL = [NSUserDefaults.standardUserDefaults boolForKey:kMPASettingsKeyFullMatch];
if(useCompletURL) {
self.useCompleteURLAsWindowTitleButton.state = NSOnState;
self.useURLHostAsWindowTitleButton.state = NSOffState;
}
else {
self.useCompleteURLAsWindowTitleButton.state = NSOffState;
self.useURLHostAsWindowTitleButton.state = NSOnState;
}
}

- (void)toggleWindowTitleBehaviour:(id)sender {
BOOL useCompletURL = self.useCompleteURLAsWindowTitleButton.state == NSOnState;
[NSUserDefaults.standardUserDefaults setBool:useCompletURL forKey:kMPASettingsKeyFullMatch];
}


@end


88 changes: 88 additions & 0 deletions AutotypeURL/Settings/AutotypeURLSettings.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ATUSettingsViewController">
<connections>
<outlet property="useCompleteURLAsWindowTitleButton" destination="Mlp-dR-3Eg" id="mzD-d8-rbG"/>
<outlet property="useURLHostAsWindowTitleButton" destination="sx5-m1-nBn" id="myQ-CW-q2C"/>
<outlet property="view" destination="Hz6-mo-xeY" id="ujE-Pk-8jr"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="444" height="124"/>
<subviews>
<stackView orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="b2a-03-dSA">
<rect key="frame" x="20" y="20" width="404" height="84"/>
<beginningViews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sx5-m1-nBn">
<rect key="frame" x="-1" y="67" width="170" height="18"/>
<buttonCell key="cell" type="radio" title="Use host as window title" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="UQ0-qc-9dN">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleWindowTitleBehaviour:" target="-2" id="aW3-FB-P3x"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Vy-hB-Qm7">
<rect key="frame" x="-2" y="46" width="290" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" title="https://sub.domain.com/some/path → sub.domain.com" id="BSO-Lz-Rbc">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Mlp-dR-3Eg">
<rect key="frame" x="-1" y="21" width="190" height="18"/>
<buttonCell key="cell" type="radio" title="Use full URL as window title" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="v8M-pT-gr1">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleWindowTitleBehaviour:" target="-2" id="OJj-hO-vlC"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oY1-b8-nf7">
<rect key="frame" x="-2" y="0.0" width="388" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" title="https://sub.domain.com/some/path → https://sub.domain.com/some/path" id="Qyx-Rx-Ngm">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</beginningViews>
<constraints>
<constraint firstItem="3Vy-hB-Qm7" firstAttribute="leading" secondItem="b2a-03-dSA" secondAttribute="leading" constant="20" id="mCa-PM-o58"/>
<constraint firstItem="oY1-b8-nf7" firstAttribute="leading" secondItem="b2a-03-dSA" secondAttribute="leading" constant="20" id="pY2-T8-YhD"/>
</constraints>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="b2a-03-dSA" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" symbolic="YES" id="9QH-Aw-T0r"/>
<constraint firstAttribute="trailing" secondItem="b2a-03-dSA" secondAttribute="trailing" constant="20" symbolic="YES" id="Ccz-6q-lG1"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="b2a-03-dSA" secondAttribute="bottom" constant="20" symbolic="YES" id="XiH-Op-deT"/>
<constraint firstItem="b2a-03-dSA" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" symbolic="YES" id="ddR-ia-qqg"/>
</constraints>
<point key="canvasLocation" x="116" y="-117"/>
</customView>
</objects>
</document>
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ xcodebuild
The Plugin is moved to the plugin folder of MacPass automacially.
````~/Library/Application Support/MacPass/AutotypeURL.mpplugin````



![](aturl-prefs.png)


## Contributors

Idea and initial Apple Script is based on the work of **@georgesnow** https://github.com/georgesnow/MPSafariAF
Expand Down
Binary file added aturl-prefs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4d2b49b

Please sign in to comment.