diff --git a/RSwitch.xcodeproj/project.pbxproj b/RSwitch.xcodeproj/project.pbxproj
index aec6cde..ed0def4 100644
--- a/RSwitch.xcodeproj/project.pbxproj
+++ b/RSwitch.xcodeproj/project.pbxproj
@@ -542,7 +542,7 @@
"$(PROJECT_DIR)/RSwitch/ObjC/ProcInfo",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
- MARKETING_VERSION = 1.4.2;
+ MARKETING_VERSION = 1.5.0;
PRODUCT_BUNDLE_IDENTIFIER = is.rud.bob.RSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -575,7 +575,7 @@
"$(PROJECT_DIR)/RSwitch/ObjC/ProcInfo",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
- MARKETING_VERSION = 1.4.2;
+ MARKETING_VERSION = 1.5.0;
PRODUCT_BUNDLE_IDENTIFIER = is.rud.bob.RSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
diff --git a/RSwitch/Base.lproj/Main.storyboard b/RSwitch/Base.lproj/Main.storyboard
index 7485221..1b578bb 100644
--- a/RSwitch/Base.lproj/Main.storyboard
+++ b/RSwitch/Base.lproj/Main.storyboard
@@ -730,7 +730,7 @@
-
+
@@ -822,7 +822,7 @@
-
+
@@ -831,7 +831,7 @@
-
+
@@ -841,7 +841,7 @@
-
+
Gw
@@ -855,7 +855,7 @@ Gw
-
+
DQ
@@ -948,7 +948,7 @@ DQ
-RSwitch v1.4.2
+RSwitch v1.5.0
Copyright © 2019 Bob Rudis
@@ -982,7 +982,8 @@ Cgo
dial app icon by IconMark from the Noun Project
String+Version by DragonCherry
-ProcInfo by Patrick Wardle
+ProcInfo by Patrick Wardle
+Just by Daniel Duan
diff --git a/RSwitch/Swift/AppDelegate.swift b/RSwitch/Swift/AppDelegate.swift
index c07d397..551f659 100644
--- a/RSwitch/Swift/AppDelegate.swift
+++ b/RSwitch/Swift/AppDelegate.swift
@@ -26,8 +26,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSToolbarDelegate {
NSApp.activate(ignoringOtherApps: true)
}
+ @objc func performRStudioCheck(_ sender: NSObject) {
+ let v = RStudioUtils.latestVersionNumber()
+ if (!Preferences.lastVersionNotified.isVersion(equalTo: v)) {
+ Preferences.lastVersionNotified = v
+ notifyUser(title: "New RStudio Daily version available", text: ("Version: " + v))
+ }
+ }
+
@objc func performTimer(_ sender: Timer) {
- print("timer fired")
+ if (Preferences.hourlyRStudioCheck) { performRStudioCheck(sender) }
}
var mainStoryboard: NSStoryboard!
@@ -69,7 +77,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSToolbarDelegate {
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
-
+
// dial by IconMark from the Noun Project
statusItem.button?.image = #imageLiteral(resourceName: "RSwitch")
statusItem.menu = statusMenu
diff --git a/RSwitch/Swift/Menu.swift b/RSwitch/Swift/Menu.swift
index 0a7acf3..98b34bd 100644
--- a/RSwitch/Swift/Menu.swift
+++ b/RSwitch/Swift/Menu.swift
@@ -22,6 +22,18 @@ extension AppDelegate: NSMenuDelegate {
}
}
+
+ @objc func toggle_hourly_rstudio_check(_ sender: NSMenuItem) {
+
+ Preferences.hourlyRStudioCheck = !Preferences.hourlyRStudioCheck
+
+ if (Preferences.hourlyRStudioCheck) { performRStudioCheck(sender) }
+
+ if let menu = statusItem.menu, let item = menu.item(withTag: 98) {
+ item.state = Preferences.hourlyRStudioCheck.stateValue
+ }
+
+ }
func menuWillOpen(_ menu: NSMenu) {
@@ -52,16 +64,21 @@ extension AppDelegate: NSMenuDelegate {
menu.addItem(NSMenuItem.separator())
+ let refsDropdown = NSMenuItem(title: "Reference Desk", action: nil, keyEquivalent: "")
+ let refsSub = NSMenu()
+ menu.addItem(refsDropdown)
+ menu.setSubmenu(refsSub, for: refsDropdown)
+
// Add items to open various R for macOS pages
- BrowseMenuAction.populateWebItems(menu: menu)
+ BrowseMenuAction.populateWebItems(menu: refsSub)
menu.addItem(NSMenuItem.separator())
// Add links to local copies of the R Manuals
- BrowseMenuAction.populateLocalRManualsItems(menu: menu)
+ BrowseMenuAction.populateLocalRManualsItems(menu: refsSub)
// Add links to free R online books
- BrowseMenuAction.populateRBooksItems(menu: menu)
+ BrowseMenuAction.populateRBooksItems(menu: refsSub)
// Add running apps
populateRunningApps(menu: menu)
@@ -71,22 +88,32 @@ extension AppDelegate: NSMenuDelegate {
RStudioServerMenuAction.populateRStudioServerSessions(menu: menu, manager: sess)
- // Add a Check for update
- menu.addItem(NSMenuItem.separator())
- menu.addItem(NSMenuItem(title: "Check for update…", action: #selector(checkForUpdate), keyEquivalent: ""))
-
- // Add an About item
menu.addItem(NSMenuItem.separator())
- menu.addItem(NSMenuItem(title: "About RSwitch…", action: #selector(showAbout), keyEquivalent: ""))
- menu.addItem(NSMenuItem(title: "RSwitch Help…", action: #selector(rswitch_help), keyEquivalent: ""))
// Toggle Dock Icon
menu.addItem(NSMenuItem.separator())
- let item = NSMenuItem(title: "Toggle Dock Icon", action: #selector(toggle_dock_icon), keyEquivalent: "")
- item.tag = 99
- item.target = self
- item.state = Preferences.showDockIcon.stateValue
- menu.addItem(item)
+
+ let prefsDropdown = NSMenuItem(title: "Preferences", action: nil, keyEquivalent: "")
+ let prefSub = NSMenu()
+
+ menu.addItem(prefsDropdown)
+ menu.setSubmenu(prefSub, for: prefsDropdown)
+
+ let dockItem = NSMenuItem(title: "Show Dock Icon", action: #selector(toggle_dock_icon), keyEquivalent: "")
+ dockItem.tag = 99
+ dockItem.target = self
+ dockItem.state = Preferences.showDockIcon.stateValue
+ prefSub.addItem(dockItem)
+
+ let rstudioCheckItem = NSMenuItem(title: "Notify me when a new RStudio Daily is available", action: #selector(toggle_hourly_rstudio_check), keyEquivalent: "")
+ rstudioCheckItem.tag = 98
+ rstudioCheckItem.target = self
+ rstudioCheckItem.state = Preferences.hourlyRStudioCheck.stateValue
+ prefSub.addItem(rstudioCheckItem)
+
+ menu.addItem(NSMenuItem(title: "Check for update…", action: #selector(checkForUpdate), keyEquivalent: ""))
+ menu.addItem(NSMenuItem(title: "About RSwitch…", action: #selector(showAbout), keyEquivalent: ""))
+ menu.addItem(NSMenuItem(title: "RSwitch Help…", action: #selector(rswitch_help), keyEquivalent: ""))
// Add a Quit item
menu.addItem(NSMenuItem.separator())
diff --git a/RSwitch/Swift/MenuActions/RStudioServerAction.swift b/RSwitch/Swift/MenuActions/RStudioServerAction.swift
index 72698b4..9fe7a79 100644
--- a/RSwitch/Swift/MenuActions/RStudioServerAction.swift
+++ b/RSwitch/Swift/MenuActions/RStudioServerAction.swift
@@ -18,7 +18,6 @@ extension AppDelegate {
}
@objc func activateServerSession(_ sender: NSMenuItem) {
- print("activate Session")
let sess = (sender.representedObject as! RStudioServerSession)
sess.show()
}
diff --git a/RSwitch/Swift/NewSessionViewController.swift b/RSwitch/Swift/NewSessionViewController.swift
index 6e5ae77..0041d23 100644
--- a/RSwitch/Swift/NewSessionViewController.swift
+++ b/RSwitch/Swift/NewSessionViewController.swift
@@ -37,9 +37,18 @@ class NewSessionViewController: NSViewController {
@IBAction func cancelPressed(_ sender: Any) {
self.view.window?.windowController?.close()
}
+
+ override func viewWillAppear() {
+
+ nickname.stringValue = ""
+ serverURL.stringValue = "https://"
+
+ super.viewDidAppear()
+
+ }
override func viewDidLoad() {
- print("VIEW IS LOADING")
+
super.viewDidLoad()
nickname.delegate = self
@@ -61,9 +70,7 @@ extension NewSessionViewController : NSTextFieldDelegate {
let currNames = appDelegate.sess.sessions!.map {
$0.menuTitle
}
-
- print(currNames)
-
+
let nickUnique = !(currNames.firstIndex(of: nick) != nil)
okButton.isEnabled = ((nick.count > 0) && nickUnique && sURL.isValidURL)
diff --git a/RSwitch/Swift/Notify.swift b/RSwitch/Swift/Notify.swift
index 659d117..339f67e 100644
--- a/RSwitch/Swift/Notify.swift
+++ b/RSwitch/Swift/Notify.swift
@@ -11,7 +11,7 @@ import Cocoa
extension AppDelegate : NSUserNotificationCenterDelegate {
- func notifyUser(title: String? = nil, subtitle: String? = nil, text: String? = nil) -> Void {
+func notifyUser(title: String? = nil, subtitle: String? = nil, text: String? = nil) -> Void {
let notification = NSUserNotification()
diff --git a/RSwitch/Swift/Utils/Preferences.swift b/RSwitch/Swift/Utils/Preferences.swift
index 662e42e..ca86105 100644
--- a/RSwitch/Swift/Utils/Preferences.swift
+++ b/RSwitch/Swift/Utils/Preferences.swift
@@ -20,7 +20,9 @@ extension UserDefaults {
enum Key: String {
case showDockIcon = "showDockIcon"
+ case hourlyRStudioCheck = "hourlyRStudioCheck"
case firstRunGone = "firstRunGone"
+ case lastVersionNotified = ""
}
func set(_ value: T, forKey key: Key) { set(value, forKey: key.rawValue) }
@@ -50,6 +52,14 @@ struct DockIcon {
struct Preferences {
+ static var hourlyRStudioCheck: Bool {
+ get { return(defaults.bool(forKey: .hourlyRStudioCheck)) }
+ set {
+ defaults.set(newValue, forKey: .hourlyRStudioCheck)
+ defaults.synchronize()
+ }
+ }
+
static var showDockIcon: Bool {
get { return(defaults.bool(forKey: .showDockIcon)) }
set {
@@ -66,7 +76,22 @@ struct Preferences {
}
}
- static func restore() { Preferences.showDockIcon = false }
+ static var lastVersionNotified : String {
+ get {
+ let x = defaults.string(forKey: .lastVersionNotified)
+ return((x == nil) ? "" : x!)
+ }
+ set {
+ defaults.set(newValue, forKey: .lastVersionNotified)
+ defaults.synchronize()
+ }
+ }
+
+ static func restore() {
+ Preferences.showDockIcon = false
+ Preferences.hourlyRStudioCheck = false
+ Preferences.lastVersionNotified = ""
+ }
}