forked from coyim/coyim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifications.go
82 lines (65 loc) · 1.99 KB
/
notifications.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
package gui
import (
"fmt"
"github.com/twstrike/coyim/Godeps/_workspace/src/github.com/twstrike/gotk3adapter/gtki"
"github.com/twstrike/coyim/i18n"
)
func (u *gtkUI) showConnectAccountNotification(account *account) func() {
var notification gtki.InfoBar
doInUIThread(func() {
notification = account.buildConnectionNotification(u)
account.setCurrentNotification(notification, u.notificationArea)
})
return func() {
doInUIThread(func() {
account.removeCurrentNotificationIf(notification)
})
}
}
func (u *gtkUI) notifyTorIsNotRunning(account *account) {
doInUIThread(func() {
notification := account.buildTorNotRunningNotification(u)
account.setCurrentNotification(notification, u.notificationArea)
})
}
func (u *gtkUI) notifyConnectionFailure(account *account, moreInfo func()) {
doInUIThread(func() {
notification := account.buildConnectionFailureNotification(u, moreInfo)
account.setCurrentNotification(notification, u.notificationArea)
})
}
func buildVerifyIdentityNotification(acc *account, peer, resource string, win gtki.Window) gtki.InfoBar {
builder := newBuilder("VerifyIdentityNotification")
obj := builder.getObj("infobar")
infoBar := obj.(gtki.InfoBar)
obj = builder.getObj("message")
message := obj.(gtki.Label)
message.SetSelectable(true)
text := fmt.Sprintf(i18n.Local("You have not verified the identity of %s"), peer)
message.SetText(text)
obj = builder.getObj("button_verify")
button := obj.(gtki.Button)
button.Connect("clicked", func() {
doInUIThread(func() {
resp := verifyFingerprintDialog(acc, peer, resource, win)
if resp == gtki.RESPONSE_YES {
infoBar.Hide()
infoBar.Destroy()
}
})
})
infoBar.ShowAll()
return infoBar
}
func (u *gtkUI) notify(title, message string) {
builder := newBuilder("SimpleNotification")
obj := builder.getObj("dialog")
dlg := obj.(gtki.MessageDialog)
dlg.SetProperty("title", title)
dlg.SetProperty("text", message)
dlg.SetTransientFor(u.window)
doInUIThread(func() {
dlg.Run()
dlg.Destroy()
})
}