-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathutils.go
120 lines (100 loc) · 2.18 KB
/
utils.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package gui
import (
"time"
"github.com/atotto/clipboard"
"github.com/coyim/gotk3adapter/gtki"
)
const (
gmailURL = "https://mail.google.com/mail/"
yahooURL = "http://compose.mail.yahoo.com/"
outlookURL = "https://dub130.mail.live.com/default.aspx"
)
func (u *gtkUI) switchToMainWindow() {
u.doInUIThread(func() {
if u.currentWindow != nil {
u.currentWindow.Hide()
u.currentWindow = nil
}
if u.mainWindow != nil {
u.switchToWindow(u.mainWindow)
}
})
}
func (u *gtkUI) switchToWindow(win gtki.ApplicationWindow) {
win.SetApplication(u.app)
u.setCurrentWindow(win)
u.doInUIThread(win.Show)
}
func (u *gtkUI) showMainWindow() {
if u.mainWindow != nil {
u.switchToWindow(u.mainWindow)
}
}
func (u *gtkUI) copyToClipboard(text string) error {
return clipboard.WriteAll(text)
}
func (u *gtkUI) isCopyToClipboardSupported() bool {
return !clipboard.Unsupported
}
func (u *gtkUI) messageToLabel(label gtki.Label, message string, seconds int) {
u.doInUIThread(func() {
label.SetVisible(true)
label.SetText(message)
})
time.Sleep(time.Duration(seconds) * time.Second)
u.doInUIThread(func() {
label.SetText("")
label.SetVisible(false)
})
}
func (u *gtkUI) enableWindow(win gtki.Window) {
if win != nil {
u.doInUIThread(func() {
win.SetSensitive(true)
})
}
}
func (u *gtkUI) disableWindow(win gtki.Window) {
if win != nil {
u.doInUIThread(func() {
win.SetSensitive(false)
})
}
}
func (u *gtkUI) disableMainWindow() {
if u.mainWindow != nil {
u.doInUIThread(func() {
u.disableWindow(u.mainWindow)
})
}
}
func (u *gtkUI) enableMainWindow() {
if u.mainWindow != nil {
u.enableWindow(u.mainWindow)
}
}
func (u *gtkUI) disableCurrentWindow() {
if u.currentWindow != nil {
u.disableWindow(u.currentWindow)
}
}
func (u *gtkUI) enableCurrentWindow() {
if u.currentWindow != nil {
u.enableWindow(u.currentWindow)
}
}
func (u *gtkUI) setCurrentWindow(win gtki.Window) {
if u.currentWindow != win {
u.currentWindow = win
}
}
func (u *gtkUI) hideMainWindow() {
if u.mainWindow != nil {
u.doInUIThread(u.mainWindow.Hide)
}
}
func (u *gtkUI) hideCurrentWindow() {
if u.currentWindow != nil {
u.doInUIThread(u.currentWindow.Hide)
}
}