A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed). https://rud.is/rswitch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.6 KiB

// Menu.swift
// RSwitch
// Created by hrbrmstr on 8/24/19.
// Copyright © 2019 Bob Rudis. All rights reserved.
import Foundation
import Cocoa
extension AppDelegate: NSMenuDelegate {
func menuWillOpen(_ menu: NSMenu) {
if (menu != self.statusMenu) { return }
// clear the menu
// add selection to open frameworks dir in Finder
menu.addItem(NSMenuItem(title: "Open R Frameworks Directory", action: #selector(openFrameworksDir), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "Current R Version:", action: nil, keyEquivalent: ""))
// populate installed versions
RVersions.populateRVersionsMenu(menu: menu, handler: #selector(handleRSwitch))
// Add items to download latest r-devel tarball and latest macOS daily
let rdevelItem = NSMenuItem(title: NSLocalizedString("Download latest R-devel tarball", comment: "Download latest tarball item"), action: self.rdevel_enabled ? #selector(download_latest_tarball) : nil, keyEquivalent: "")
rdevelItem.isEnabled = self.rdevel_enabled
let rstudioItem = NSMenuItem(title: NSLocalizedString("Download latest RStudio daily build", comment: "Download latest RStudio item"), action: self.rstudio_enabled ? #selector(download_latest_rstudio) : nil, keyEquivalent: "")
rstudioItem.isEnabled = self.rstudio_enabled
// Add items to open various R for macOS pages
BrowseMenuAction.populateWebItems(menu: menu)
// Add links to local copies of the R Manuals
BrowseMenuAction.populateLocalRManualsItems(menu: menu)
// Add links to free R online books
BrowseMenuAction.populateRBooksItems(menu: menu)
// Add running apps
populateRunningApps(menu: menu)
// Add launchers
populateLaunchers(menu: menu)
// Add a Check for update
menu.addItem(NSMenuItem(title: "Check for update…", action: #selector(checkForUpdate), keyEquivalent: ""))
// Add an About item
menu.addItem(NSMenuItem(title: "About RSwitch…", action: #selector(about), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "RSwitch Help…", action: #selector(rswitch_help), keyEquivalent: ""))
// Add a Quit item
menu.addItem(NSMenuItem(title: "Quit", action: #selector(NSApp.terminate), keyEquivalent: "q"))