-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAppController.rb
86 lines (68 loc) · 1.95 KB
/
AppController.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require 'osx/cocoa'
class AppController < OSX::NSObject
def init
#puts $LOAD_PATH
init_prefs
$timerController = Clock.new
$timerController.resetTime
$timerController.timeDelta
$TunnelController = Tunnel.new
setPopupTimer
if (@statusItem == nil)
@statusItem = OSX::NSStatusBar.systemStatusBar.statusItemWithLength(OSX::NSVariableStatusItemLength)
@statusItem.setImage_(OSX::NSImage.imageNamed_("test2"))
@statusItem.setHighlightMode_(true)
menu = OSX::NSMenu.alloc.initWithTitle("")
menu.addItemWithTitle_action_keyEquivalent("Time To Ticket",:showLogTime,"")
menu.addItemWithTitle_action_keyEquivalent("Preferences",:showPreferences,"")
menu.addItemWithTitle_action_keyEquivalent("Quit",:quitApplication,"")
menu.addItemWithTitle_action_keyEquivalent(getVersion,nil,"")
@statusItem.setMenu(menu)
menu.release
return self
end
end
def setPopupTimer
@timer = OSX::NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( $settings[:popupInterval] , self, :tick, nil, true)
end
def getVersion
infoDictionary = OSX::NSBundle.mainBundle.infoDictionary
infoDictionary.objectForKey("CFBundleShortVersionString") + ' ('+ infoDictionary.objectForKey("CFBundleVersion") +')'
end
def init_prefs
$prefs = PrefsStorage.new
$prefs.initAll
end
def tick
openLogTimeWindow(self)
end
ib_action :showPreferences
def showPreferences(sender)
if not @prefsController
@prefsController = PreferencesController.alloc.init
end
@prefsController.showWindow(self)
end
ib_action :showLogTime
def showLogTime(sender)
setPopupTimer
openLogTimeWindow(self)
end
def openLogTimeWindow(sender)
if not $LogTimeContr
$LogTimeContr = LogTimeController.alloc.init
end
$LogTimeContr.openW
end
def test(x)
end
def applicationDidFinishLaunching(n10n)
p "Window Loaded!"
end
def applicationWillTerminate(n10n)
p "App terminated!"
end
def quitApplication(x)
OSX::NSApp.terminate_(nil)
end
end