forked from coyim/coyim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounts_menu.go
70 lines (52 loc) · 1.96 KB
/
accounts_menu.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
package gui
import (
"sync"
"github.com/twstrike/coyim/Godeps/_workspace/src/github.com/twstrike/gotk3adapter/glibi"
"github.com/twstrike/coyim/Godeps/_workspace/src/github.com/twstrike/gotk3adapter/gtki"
"github.com/twstrike/coyim/config"
"github.com/twstrike/coyim/i18n"
)
var (
// TODO: shouldn't this be specific to the account ID in question?
accountChangedSignal glibi.Signal
)
var accountsLock sync.Mutex
func (u *gtkUI) buildStaticAccountsMenu(submenu gtki.Menu) {
connectAutomaticallyItem, _ := g.gtk.CheckMenuItemNewWithMnemonic(i18n.Local("Connect On _Startup"))
u.config.WhenLoaded(func(a *config.ApplicationConfig) {
connectAutomaticallyItem.SetActive(a.ConnectAutomatically)
})
connectAutomaticallyItem.Connect("activate", func() {
u.setConnectAllAutomatically(connectAutomaticallyItem.GetActive())
})
submenu.Append(connectAutomaticallyItem)
connectAllMenu, _ := g.gtk.MenuItemNewWithMnemonic(i18n.Local("_Connect All"))
connectAllMenu.Connect("activate", func() { u.connectAllAutomatics(true) })
submenu.Append(connectAllMenu)
sep2, _ := g.gtk.SeparatorMenuItemNew()
submenu.Append(sep2)
addAccMenu, _ := g.gtk.MenuItemNewWithMnemonic(i18n.Local("_Add..."))
addAccMenu.Connect("activate", u.showAddAccountWindow)
submenu.Append(addAccMenu)
importMenu, _ := g.gtk.MenuItemNewWithMnemonic(i18n.Local("_Import..."))
importMenu.Connect("activate", u.runImporter)
submenu.Append(importMenu)
registerAccMenu, _ := g.gtk.MenuItemNewWithMnemonic(i18n.Local("_Register..."))
registerAccMenu.Connect("activate", u.showServerSelectionWindow)
submenu.Append(registerAccMenu)
}
func (u *gtkUI) buildAccountsMenu() {
accountsLock.Lock()
defer accountsLock.Unlock()
submenu, _ := g.gtk.MenuNew()
for _, account := range u.accounts {
account.appendMenuTo(submenu)
}
if len(u.accounts) > 0 {
sep, _ := g.gtk.SeparatorMenuItemNew()
submenu.Append(sep)
}
u.buildStaticAccountsMenu(submenu)
submenu.ShowAll()
u.accountsMenu.SetSubmenu(submenu)
}