mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Initial start of the menu bar app.
Has menu items to join/leave networks which currently displays an empty popover from the icon (icon needs to be made still)
This commit is contained in:
parent
0582338015
commit
225c2b095b
13 changed files with 195 additions and 6 deletions
|
@ -10,6 +10,10 @@
|
|||
93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; };
|
||||
93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; };
|
||||
93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; };
|
||||
93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */; };
|
||||
93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */; };
|
||||
93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */; };
|
||||
93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
@ -18,6 +22,10 @@
|
|||
93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
93326BE01CE7C816005CA2AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
93326BE21CE7C816005CA2AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinNetworkViewController.swift; sourceTree = "<group>"; };
|
||||
93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JoinNetworkViewController.xib; sourceTree = "<group>"; };
|
||||
93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowNetworksViewController.swift; sourceTree = "<group>"; };
|
||||
93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowNetworksViewController.xib; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -51,9 +59,13 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
93326BDB1CE7C816005CA2AC /* AppDelegate.swift */,
|
||||
93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */,
|
||||
93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */,
|
||||
93326BDD1CE7C816005CA2AC /* Assets.xcassets */,
|
||||
93326BDF1CE7C816005CA2AC /* MainMenu.xib */,
|
||||
93326BE21CE7C816005CA2AC /* Info.plist */,
|
||||
93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */,
|
||||
93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */,
|
||||
);
|
||||
path = "ZeroTier One";
|
||||
sourceTree = "<group>";
|
||||
|
@ -116,6 +128,8 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */,
|
||||
93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */,
|
||||
93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */,
|
||||
93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */,
|
||||
);
|
||||
|
@ -129,6 +143,8 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */,
|
||||
93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */,
|
||||
93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
</Bucket>
|
|
@ -14,8 +14,34 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
|
||||
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2.0)
|
||||
|
||||
let networkListPopover = NSPopover()
|
||||
let joinNetworkPopover = NSPopover()
|
||||
|
||||
var transientMonitor: AnyObject? = nil
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
// Insert code here to initialize your application
|
||||
|
||||
|
||||
statusItem.image = NSImage(named: "MenuBarIconMac")
|
||||
|
||||
let menu = NSMenu()
|
||||
|
||||
menu.addItem(NSMenuItem(title: "Show Networks", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n"))
|
||||
menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j"))
|
||||
menu.addItem(NSMenuItem.separatorItem())
|
||||
menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q"))
|
||||
|
||||
statusItem.menu = menu
|
||||
|
||||
joinNetworkPopover.contentViewController = JoinNetworkViewController(
|
||||
nibName: "JoinNetworkViewController", bundle: nil)
|
||||
joinNetworkPopover.behavior = .Transient
|
||||
|
||||
networkListPopover.contentViewController = ShowNetworksViewController(
|
||||
nibName: "ShowNetworksViewController", bundle: nil)
|
||||
networkListPopover.behavior = .Transient
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
|
@ -23,5 +49,41 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
}
|
||||
|
||||
|
||||
func showNetworks() {
|
||||
if let button = statusItem.button {
|
||||
networkListPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY)
|
||||
|
||||
if transientMonitor == nil {
|
||||
transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask(
|
||||
[.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in
|
||||
|
||||
NSEvent.removeMonitor(self.transientMonitor!)
|
||||
self.transientMonitor = nil
|
||||
self.networkListPopover.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func joinNetwork() {
|
||||
if let button = statusItem.button {
|
||||
joinNetworkPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY)
|
||||
|
||||
if transientMonitor == nil {
|
||||
transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask(
|
||||
[.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in
|
||||
|
||||
NSEvent.removeMonitor(self.transientMonitor!)
|
||||
self.transientMonitor = nil
|
||||
self.joinNetworkPopover.close()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func quit() {
|
||||
NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
ZeroTier One/Assets.xcassets/Contents.json
Normal file
6
ZeroTier One/Assets.xcassets/Contents.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
21
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json
vendored
Normal file
21
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"filename" : "MenuBarIconMac.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"filename" : "MenuBarIconMac@2x.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
BIN
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png
vendored
Normal file
BIN
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png
vendored
Normal file
BIN
ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
|
@ -11,7 +12,7 @@
|
|||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target">
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="ZeroTier_One" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
|
@ -666,11 +667,11 @@
|
|||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="ZeroTier One" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<window title="ZeroTier One" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1716" height="1024"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
|
|
18
ZeroTier One/JoinNetworkViewController.swift
Normal file
18
ZeroTier One/JoinNetworkViewController.swift
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// JoinNetworkViewController.swift
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 5/14/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class JoinNetworkViewController: NSViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do view setup here.
|
||||
}
|
||||
|
||||
}
|
20
ZeroTier One/JoinNetworkViewController.xib
Normal file
20
ZeroTier One/JoinNetworkViewController.xib
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="JoinNetworkViewController" customModule="ZeroTier_One" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
18
ZeroTier One/ShowNetworksViewController.swift
Normal file
18
ZeroTier One/ShowNetworksViewController.swift
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// ShowNetworksViewController.swift
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 5/14/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class ShowNetworksViewController: NSViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do view setup here.
|
||||
}
|
||||
|
||||
}
|
20
ZeroTier One/ShowNetworksViewController.xib
Normal file
20
ZeroTier One/ShowNetworksViewController.xib
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ShowNetworksViewController" customModule="ZeroTier_One" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
Loading…
Add table
Reference in a new issue