//
// A p p D e l e g a t e . s w i f t
// R S w i t c h
//
// C r e a t e d b y h r b r m s t r o n 8 / 2 4 / 1 9 .
// C o p y r i g h t © 2 0 1 9 B o b R u d i s . A l l r i g h t s r e s e r v e d .
//
import Cocoa
@NSApplicationMain
class AppDelegate : NSObject , NSApplicationDelegate {
@objc func showAabout ( _ sender : NSMenuItem ? ) { abtController . showWindow ( self ) }
@objc func performTimer ( _ sender : Timer ) { print ( " timer fired " ) }
var mainStoryboard : NSStoryboard !
var abtController : NSWindowController !
let statusItem = NSStatusBar . system . statusItem ( withLength : NSStatusItem . variableLength )
let statusMenu = NSMenu ( title : " RSwitch " )
var rdevel_enabled : Bool !
var rstudio_enabled : Bool !
var timer : Timer ? = nil ;
override init ( ) {
super . init ( )
statusMenu . delegate = self
rdevel_enabled = true
rstudio_enabled = true
URLCache . shared = URLCache ( memoryCapacity : 0 , diskCapacity : 0 , diskPath : nil )
}
func applicationWillFinishLaunching ( _ aNotification : Notification ) {
if Preferences . firstRunGone = = false {
Preferences . firstRunGone = true
Preferences . restore ( )
}
DockIcon . standard . setVisibility ( Preferences . showDockIcon )
}
func applicationDidFinishLaunching ( _ aNotification : Notification ) {
// d i a l b y I c o n M a r k f r o m t h e N o u n P r o j e c t
statusItem . button ? . image = # imageLiteral ( resourceName : " RSwitch " )
statusItem . menu = statusMenu
mainStoryboard = NSStoryboard ( name : " Main " , bundle : nil )
abtController = ( mainStoryboard . instantiateController ( withIdentifier : " aboutPanelController " ) as ! NSWindowController )
timer = Timer . scheduledTimer (
timeInterval : 3600 ,
target : self ,
selector : #selector ( performTimer ) ,
userInfo : nil ,
repeats : true
)
}
func applicationWillTerminate ( _ aNotification : Notification ) { }
}