-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
handlers.go
49 lines (38 loc) · 1.25 KB
/
handlers.go
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
package main
import (
"time"
"github.com/getlantern/systray"
)
func (a *app) handleIdleItemSelected(mIdleTimes []*systray.MenuItem, index int) {
prevIndex := getMinutesSliceIndexFromDuration(a.maxAllowedIdleTime, idleTimeOptionsInSettings[:])
if prevIndex >= 0 && prevIndex < len(mIdleTimes) {
mIdleTimes[prevIndex].Uncheck()
}
mIdleTimes[index].Check()
a.setMaxAllowedIdleTime(int(idleTimeOptionsInSettings[index]))
}
func (a *app) handleKeepTimeLogsForOptionSelected(mKeepTimeLogsForOptions []*systray.MenuItem, index int) {
prevIndex := getMinutesSliceIndexFromDuration(a.keepTimeLogsFor, keepTimeLogsForOptionsInSettings[:])
if prevIndex >= 0 && prevIndex < len(mKeepTimeLogsForOptions) {
mKeepTimeLogsForOptions[prevIndex].Uncheck()
}
mKeepTimeLogsForOptions[index].Check()
a.setKeepTimeLogsFor(int(keepTimeLogsForOptionsInSettings[index]))
a.checkAndCleanExpiredTimeLogs()
}
func (a *app) handleOpenAtLoginClicked(item *systray.MenuItem) {
if a.startup.RunningAtStartup() {
a.startup.RemoveStartupItem()
item.Uncheck()
} else {
a.startup.AddStartupItem()
item.Check()
}
}
func (a *app) handleQuitClicked() {
a.addActivePeriodEntry(a.lastIdleTime, time.Now())
systray.Quit()
}
func (a *app) handleAboutClicked() {
openURL(aboutURL)
}