From bacd180a4ba664b561379be18fe0d371178ac1db Mon Sep 17 00:00:00 2001 From: FivePixels Date: Sat, 1 Dec 2018 00:21:21 -0600 Subject: Initial commit --- DWA140Menu.xcodeproj/project.pbxproj | 19 ++++---- .../xcschemes/xcschememanagement.plist | 5 +++ DWA140Menu/AppDelegate.swift | 28 ++++++------ .../CreditsPNG.imageset/Contents.json | 8 ++++ ...tError-1_55A54008AD1BA589AA210D2629C1DF41_0.png | Bin 0 -> 743 bytes .../WifiError.imageset/Contents.json | 24 ++++++++++ ...tError-1_55A54008AD1BA589AA210D2629C1DF41_0.png | Bin 743 -> 0 bytes .../wifierror.imageset/Contents.json | 24 ---------- DWA140Menu/Base.lproj/Main.storyboard | 49 ++------------------- 9 files changed, 65 insertions(+), 92 deletions(-) create mode 100644 DWA140Menu/Assets.xcassets/WifiError.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png create mode 100644 DWA140Menu/Assets.xcassets/WifiError.imageset/Contents.json delete mode 100644 DWA140Menu/Assets.xcassets/wifierror.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png delete mode 100644 DWA140Menu/Assets.xcassets/wifierror.imageset/Contents.json diff --git a/DWA140Menu.xcodeproj/project.pbxproj b/DWA140Menu.xcodeproj/project.pbxproj index 02e624c..1aa69f3 100644 --- a/DWA140Menu.xcodeproj/project.pbxproj +++ b/DWA140Menu.xcodeproj/project.pbxproj @@ -194,13 +194,16 @@ TargetAttributes = { E7DA7E45213DD9DD00931016 = { CreatedOnToolsVersion = 9.4.1; + LastSwiftMigration = 1010; }; E7DA7E57213DD9DD00931016 = { CreatedOnToolsVersion = 9.4.1; + LastSwiftMigration = 1010; TestTargetID = E7DA7E45213DD9DD00931016; }; E7DA7E62213DD9DD00931016 = { CreatedOnToolsVersion = 9.4.1; + LastSwiftMigration = 1010; TestTargetID = E7DA7E45213DD9DD00931016; }; }; @@ -336,7 +339,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -397,7 +400,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; @@ -433,7 +436,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140Menu; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -451,7 +454,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140Menu; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -470,7 +473,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140MenuTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DWA140Menu.app/Contents/MacOS/DWA140Menu"; }; name = Debug; @@ -490,7 +493,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140MenuTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DWA140Menu.app/Contents/MacOS/DWA140Menu"; }; name = Release; @@ -509,7 +512,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140MenuUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = DWA140Menu; }; name = Debug; @@ -528,7 +531,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.FivePixels.DWA140MenuUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = DWA140Menu; }; name = Release; diff --git a/DWA140Menu.xcodeproj/xcuserdata/dylanbolger.xcuserdatad/xcschemes/xcschememanagement.plist b/DWA140Menu.xcodeproj/xcuserdata/dylanbolger.xcuserdatad/xcschemes/xcschememanagement.plist index 6480145..3774684 100644 --- a/DWA140Menu.xcodeproj/xcuserdata/dylanbolger.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/DWA140Menu.xcodeproj/xcuserdata/dylanbolger.xcuserdatad/xcschemes/xcschememanagement.plist @@ -9,6 +9,11 @@ orderHint 0 + DWA140Menu.xcscheme_^#shared#^_ + + orderHint + 0 + diff --git a/DWA140Menu/AppDelegate.swift b/DWA140Menu/AppDelegate.swift index cd78f1a..b3d0ee6 100644 --- a/DWA140Menu/AppDelegate.swift +++ b/DWA140Menu/AppDelegate.swift @@ -45,6 +45,7 @@ struct Networking { } + // Credit to Martin R http://stackoverflow.com/a/34016247/600753 for this lovely code // New Swift 3 implementation needed upated to replace unsafepointer calls with .withMemoryRebound func getInterfaces() -> [(name : String, addr: String, mac : String)] { @@ -99,13 +100,14 @@ struct Networking { freeifaddrs(ifaddr) + + // Now add the mac address to the tuples: for (i, addr) in addresses.enumerated() { if let mac = nameToMac[addr.name] { addresses[i] = (name: addr.name, addr: addr.addr, mac : mac) } } - return addresses } } @@ -113,17 +115,17 @@ struct Networking { class AppDelegate: NSObject, NSApplicationDelegate { @objc func openCredits() { - let myWindowController = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil).instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "credits")) as! NSWindowController - myWindowController.showWindow(self) + + NSWorkspace.shared.open((URL(string:"https://github.com/fivepixels/dwa140shortcut") ?? nil)!) } @objc func changeIcon() { if let button = statusItem.button { if Networking.isConnectedByEthernet { - button.image = NSImage(named: NSImage.Name(rawValue: "WifiConnected")) + button.image = NSImage(named: "WifiConnected") } else { - button.image = NSImage(named: NSImage.Name(rawValue: "wifierror")) + button.image = NSImage(named: "WifiError") } } @@ -152,7 +154,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @objc func ethStatus() -> String { if Networking.isConnectedByEthernet { - return "USB WiFi is connected. (en4)" + return "USB WiFi is connected." } else { return "USB WiFi is disconnected." } @@ -162,25 +164,23 @@ class AppDelegate: NSObject, NSApplicationDelegate { let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength) func applicationDidFinishLaunching(_ aNotification: Notification) { - changeIcon() - -constructMenu() - } + constructMenu() + } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } func constructMenu() { let menu = NSMenu() - menu.addItem(NSMenuItem(title: "DWA-140 Shortcut", action: #selector(openCredits), keyEquivalent: "")) + menu.addItem(NSMenuItem(title: "DWA-140 Shortcut (GitHub)", action: #selector(openCredits), keyEquivalent: "")) menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem(title: ethStatus(), action: nil, keyEquivalent: "")) - menu.addItem(NSMenuItem(title: "Refresh Status", action: #selector(restartApp), keyEquivalent: "")) - menu.addItem(NSMenuItem(title: "Open DWA-140" , action: #selector(openDWA), keyEquivalent: "")) + menu.addItem(NSMenuItem(title: "Refresh Status", action: #selector(restartApp), keyEquivalent: "r")) + menu.addItem(NSMenuItem(title: "Open DWA-140" , action: #selector(openDWA), keyEquivalent: "t1")) menu.addItem(NSMenuItem(title: "Network Preferences" , action: #selector(openNetwork), keyEquivalent: "")) menu.addItem(NSMenuItem.separator()) - menu.addItem(NSMenuItem(title: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")) + menu.addItem(NSMenuItem(title: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")) statusItem.menu = menu diff --git a/DWA140Menu/Assets.xcassets/CreditsPNG.imageset/Contents.json b/DWA140Menu/Assets.xcassets/CreditsPNG.imageset/Contents.json index 03a16f6..5e49329 100644 --- a/DWA140Menu/Assets.xcassets/CreditsPNG.imageset/Contents.json +++ b/DWA140Menu/Assets.xcassets/CreditsPNG.imageset/Contents.json @@ -4,6 +4,14 @@ "idiom" : "universal", "filename" : "CreditsPNG.png", "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/DWA140Menu/Assets.xcassets/WifiError.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png b/DWA140Menu/Assets.xcassets/WifiError.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png new file mode 100644 index 0000000..039d66f Binary files /dev/null and b/DWA140Menu/Assets.xcassets/WifiError.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png differ diff --git a/DWA140Menu/Assets.xcassets/WifiError.imageset/Contents.json b/DWA140Menu/Assets.xcassets/WifiError.imageset/Contents.json new file mode 100644 index 0000000..3f18ed4 --- /dev/null +++ b/DWA140Menu/Assets.xcassets/WifiError.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/DWA140Menu/Assets.xcassets/wifierror.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png b/DWA140Menu/Assets.xcassets/wifierror.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png deleted file mode 100644 index 039d66f..0000000 Binary files a/DWA140Menu/Assets.xcassets/wifierror.imageset/AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png and /dev/null differ diff --git a/DWA140Menu/Assets.xcassets/wifierror.imageset/Contents.json b/DWA140Menu/Assets.xcassets/wifierror.imageset/Contents.json deleted file mode 100644 index 3f18ed4..0000000 --- a/DWA140Menu/Assets.xcassets/wifierror.imageset/Contents.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "AirPortError-1_55A54008AD1BA589AA210D2629C1DF41_0.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" - } -} \ No newline at end of file diff --git a/DWA140Menu/Base.lproj/Main.storyboard b/DWA140Menu/Base.lproj/Main.storyboard index 42bdba8..5744e11 100644 --- a/DWA140Menu/Base.lproj/Main.storyboard +++ b/DWA140Menu/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -680,48 +680,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3