Skip to content

Commit

Permalink
Added "Reset Position" menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
SamusAranX committed Dec 15, 2018
1 parent d7ce7ee commit e3534a6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
12 changes: 9 additions & 3 deletions Sharkle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@
TargetAttributes = {
5687554F1EA82781004C351F = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 4YJ6956B5Q;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.HardenedRuntime = {
enabled = 1;
};
com.apple.Sandbox = {
enabled = 0;
};
Expand Down Expand Up @@ -342,8 +344,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Sharkle/Sharkle.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 4YJ6956B5Q;
DEVELOPMENT_TEAM = 4254J4CMHQ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Sharkle/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
Expand All @@ -362,8 +366,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Sharkle/Sharkle.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 4YJ6956B5Q;
DEVELOPMENT_TEAM = 4254J4CMHQ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Sharkle/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions Sharkle/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

weak var sharkleController: SharkleWindowController!

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

@IBAction func resetSharklePosition(_ sender: NSMenuItem) {
if let window = self.sharkleController.window {
window.setFrameOrigin(NSPoint(x: 24, y: 24))
}
}

}

17 changes: 12 additions & 5 deletions Sharkle/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14306.4" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14306.4"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -84,6 +84,13 @@
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="mdo-xo-Pqz"/>
<menuItem title="Reset Position" id="bcF-Ql-NH0">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="resetSharklePosition:" target="Voe-Tx-rLC" id="b6g-Pm-hdc"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
Expand Down Expand Up @@ -115,7 +122,7 @@
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Sharkle" customModuleProvider="target"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-190" y="163"/>
<point key="canvasLocation" x="-226" y="154"/>
</scene>
<!--Window Controller-->
<scene sceneID="R2V-B0-nI4">
Expand All @@ -124,7 +131,7 @@
<window key="window" title="Sharkle" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hasShadow="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SharkleMainWindow" animationBehavior="default" id="IQv-IB-iLA">
<windowCollectionBehavior key="collectionBehavior" canJoinAllSpaces="YES" stationary="YES" ignoresCycle="YES" fullScreenNone="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="246" height="246"/>
<rect key="contentRect" x="32" y="32" width="246" height="246"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<value key="minSize" type="size" width="246" height="246"/>
<value key="maxSize" type="size" width="246" height="246"/>
Expand Down Expand Up @@ -352,7 +359,7 @@ For a relatively spoiler-free explanation, watch this part of Jesse Cox's playth
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Let me know!" id="oxE-Mc-HMG">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="systemYellowColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="linkColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down
2 changes: 1 addition & 1 deletion Sharkle/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
Expand Down
4 changes: 3 additions & 1 deletion Sharkle/SharkleWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class SharkleWindowController: NSWindowController {

override func windowDidLoad() {
super.windowDidLoad()

(NSApplication.shared.delegate as! AppDelegate).sharkleController = self

// Yes, I'm taking a valid value returned by the system and arbitrarily adding one to it. Sue me.
// This is the only way to make Sharkle able to intercept clicks.
self.window?.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(CGWindowLevelKey.desktopIconWindow)) + 1)
// Make window movable by its background, durr
self.window?.isMovableByWindowBackground = true

Expand Down

0 comments on commit e3534a6

Please sign in to comment.