diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-02 18:32:04 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-02 18:32:04 +0200 |
commit | 48098ab608248a613da960d64dad4a653194aa41 (patch) | |
tree | c875a8cfae219f13b0c816463a905c82312a7433 /ui | |
parent | ui: move toolbar up (diff) | |
download | wireguard-windows-48098ab608248a613da960d64dad4a653194aa41.tar.xz wireguard-windows-48098ab608248a613da960d64dad4a653194aa41.zip |
ui: rename things to say tunnel less
Diffstat (limited to 'ui')
-rw-r--r-- | ui/editdialog.go (renamed from ui/tunneleditdialog.go) | 30 | ||||
-rw-r--r-- | ui/listview.go (renamed from ui/tunnelsview.go) | 34 | ||||
-rw-r--r-- | ui/tunnelspage.go | 2 |
3 files changed, 33 insertions, 33 deletions
diff --git a/ui/tunneleditdialog.go b/ui/editdialog.go index 6f5ca8ab..3cd5b606 100644 --- a/ui/tunneleditdialog.go +++ b/ui/editdialog.go @@ -41,7 +41,7 @@ const ( allowedIPsStateOther ) -type TunnelEditDialog struct { +type EditDialog struct { *walk.Dialog nameEdit *walk.LineEdit pubkeyEdit *walk.LineEdit @@ -61,7 +61,7 @@ func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config { name string ) - dlg := &TunnelEditDialog{tunnel: tunnel} + dlg := &EditDialog{tunnel: tunnel} if tunnel == nil { // Creating a new tunnel, create a new private key and use the default template @@ -143,7 +143,7 @@ func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel) *conf.Config { return nil } -func (dlg *TunnelEditDialog) updateAllowedIPsState() { +func (dlg *EditDialog) updateAllowedIPsState() { var newState allowedIPsState if len(dlg.config.Peers) == 1 { if allowedIPs := dlg.allowedIPsSet(); allowedIPs.IsSupersetOf(ipv4Wildcard) { @@ -165,16 +165,16 @@ func (dlg *TunnelEditDialog) updateAllowedIPsState() { } } -func (dlg *TunnelEditDialog) canExcludePrivateIPs() bool { +func (dlg *EditDialog) canExcludePrivateIPs() bool { return dlg.allowedIPsState == allowedIPsStateContainsIPV4PublicNetworks || dlg.allowedIPsState == allowedIPsStateContainsIPV4Wildcard } -func (dlg *TunnelEditDialog) privateIPsExcluded() bool { +func (dlg *EditDialog) privateIPsExcluded() bool { return dlg.allowedIPsState == allowedIPsStateContainsIPV4PublicNetworks } -func (dlg *TunnelEditDialog) setPrivateIPsExcluded(excluded bool) { +func (dlg *EditDialog) setPrivateIPsExcluded(excluded bool) { if !dlg.canExcludePrivateIPs() || dlg.privateIPsExcluded() == excluded { return } @@ -220,7 +220,7 @@ func (dlg *TunnelEditDialog) setPrivateIPsExcluded(excluded bool) { dlg.replaceLine(configKeyAllowedIPs, strings.Join(output.ToSlice(), ", ")) } -func (dlg *TunnelEditDialog) replaceLine(key, value string) { +func (dlg *EditDialog) replaceLine(key, value string) { text := dlg.syntaxEdit.Text() start := strings.Index(text, key) @@ -231,25 +231,25 @@ func (dlg *TunnelEditDialog) replaceLine(key, value string) { dlg.syntaxEdit.SetText(strings.ReplaceAll(text, oldLine, newLine)) } -func (dlg *TunnelEditDialog) updateExcludePrivateIPsCBVisible() { +func (dlg *EditDialog) updateExcludePrivateIPsCBVisible() { dlg.updateAllowedIPsState() dlg.excludePrivateIPsCB.SetVisible(dlg.canExcludePrivateIPs()) } -func (dlg *TunnelEditDialog) dnsRoutes() []string { +func (dlg *EditDialog) dnsRoutes() []string { return dlg.routes(configKeyDNS) } -func (dlg *TunnelEditDialog) allowedIPs() []string { +func (dlg *EditDialog) allowedIPs() []string { return dlg.routes(configKeyAllowedIPs) } -func (dlg *TunnelEditDialog) allowedIPsSet() *orderedStringSet { +func (dlg *EditDialog) allowedIPsSet() *orderedStringSet { return orderedStringSetFromSlice(dlg.allowedIPs()) } -func (dlg *TunnelEditDialog) routes(key string) []string { +func (dlg *EditDialog) routes(key string) []string { var routes []string lines := strings.Split(dlg.syntaxEdit.Text(), "\n") @@ -267,11 +267,11 @@ func (dlg *TunnelEditDialog) routes(key string) []string { return routes } -func (dlg *TunnelEditDialog) onExcludePrivateIPsCBCheckedChanged() { +func (dlg *EditDialog) onExcludePrivateIPsCBCheckedChanged() { dlg.setPrivateIPsExcluded(dlg.excludePrivateIPsCB.Checked()) } -func (dlg *TunnelEditDialog) onSyntaxEditPrivateKeyChanged(privateKey string) { +func (dlg *EditDialog) onSyntaxEditPrivateKeyChanged(privateKey string) { if privateKey == dlg.lastPrivateKey { return } @@ -284,7 +284,7 @@ func (dlg *TunnelEditDialog) onSyntaxEditPrivateKeyChanged(privateKey string) { } } -func (dlg *TunnelEditDialog) onSaveButtonClicked() { +func (dlg *EditDialog) onSaveButtonClicked() { newName := dlg.nameEdit.Text() if newName == "" { walk.MsgBox(dlg, "Invalid configuration", "Name is required", walk.MsgBoxIconWarning) diff --git a/ui/tunnelsview.go b/ui/listview.go index c2ce7946..d9ef057c 100644 --- a/ui/tunnelsview.go +++ b/ui/listview.go @@ -13,19 +13,19 @@ import ( "golang.zx2c4.com/wireguard/windows/service" ) -// TunnelModel is a struct to store the currently known tunnels to the GUI, suitable as a model for a walk.TableView. -type TunnelModel struct { +// ListModel is a struct to store the currently known tunnels to the GUI, suitable as a model for a walk.TableView. +type ListModel struct { walk.TableModelBase walk.SorterBase tunnels []service.Tunnel } -func (t *TunnelModel) RowCount() int { +func (t *ListModel) RowCount() int { return len(t.tunnels) } -func (t *TunnelModel) Value(row, col int) interface{} { +func (t *ListModel) Value(row, col int) interface{} { tunnel := t.tunnels[row] switch col { @@ -37,7 +37,7 @@ func (t *TunnelModel) Value(row, col int) interface{} { } } -func (t *TunnelModel) Sort(col int, order walk.SortOrder) error { +func (t *ListModel) Sort(col int, order walk.SortOrder) error { sort.SliceStable(t.tunnels, func(i, j int) bool { //TODO: use real string comparison for sorting with proper tunnel order return t.tunnels[i].Name < t.tunnels[j].Name @@ -46,16 +46,16 @@ func (t *TunnelModel) Sort(col int, order walk.SortOrder) error { return t.SorterBase.Sort(col, order) } -type TunnelsView struct { +type ListView struct { *walk.TableView - model *TunnelModel + model *ListModel tunnelChangedCB *service.TunnelChangeCallback tunnelsChangedCB *service.TunnelsChangeCallback } -func NewTunnelsView(parent walk.Container) (*TunnelsView, error) { +func NewTunnelsView(parent walk.Container) (*ListView, error) { var disposables walk.Disposables defer disposables.Treat() @@ -65,7 +65,7 @@ func NewTunnelsView(parent walk.Container) (*TunnelsView, error) { } disposables.Add(tv) - model := new(TunnelModel) + model := new(ListModel) if model.tunnels, err = service.IPCClientTunnels(); err != nil { return nil, err } @@ -75,7 +75,7 @@ func NewTunnelsView(parent walk.Container) (*TunnelsView, error) { tv.SetHeaderHidden(true) tv.Columns().Add(walk.NewTableViewColumn()) - tunnelsView := &TunnelsView{ + tunnelsView := &ListView{ TableView: tv, model: model, } @@ -91,7 +91,7 @@ func NewTunnelsView(parent walk.Container) (*TunnelsView, error) { return tunnelsView, nil } -func (tv *TunnelsView) Dispose() { +func (tv *ListView) Dispose() { if tv.tunnelChangedCB != nil { tv.tunnelChangedCB.Unregister() tv.tunnelChangedCB = nil @@ -103,7 +103,7 @@ func (tv *TunnelsView) Dispose() { tv.TableView.Dispose() } -func (tv *TunnelsView) StyleCell(style *walk.CellStyle) { +func (tv *ListView) StyleCell(style *walk.CellStyle) { canvas := style.Canvas() if canvas == nil { return @@ -123,7 +123,7 @@ func (tv *TunnelsView) StyleCell(style *walk.CellStyle) { iconProvider.PaintForTunnel(tunnel, canvas, b) } -func (tv *TunnelsView) CurrentTunnel() *service.Tunnel { +func (tv *ListView) CurrentTunnel() *service.Tunnel { idx := tv.CurrentIndex() if idx == -1 { return nil @@ -132,7 +132,7 @@ func (tv *TunnelsView) CurrentTunnel() *service.Tunnel { return &tv.model.tunnels[idx] } -func (tv *TunnelsView) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) { +func (tv *ListView) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) { tv.Synchronize(func() { idx := -1 for i := range tv.model.tunnels { @@ -149,7 +149,7 @@ func (tv *TunnelsView) onTunnelChange(tunnel *service.Tunnel, state service.Tunn }) } -func (tv *TunnelsView) onTunnelsChange() { +func (tv *ListView) onTunnelsChange() { tunnels, err := service.IPCClientTunnels() if err != nil { return @@ -198,7 +198,7 @@ func (tv *TunnelsView) onTunnelsChange() { }) } -func (tv *TunnelsView) selectTunnel(tunnelName string) { +func (tv *ListView) selectTunnel(tunnelName string) { for i, tunnel := range tv.model.tunnels { if tunnel.Name == tunnelName { tv.SetCurrentIndex(i) @@ -207,7 +207,7 @@ func (tv *TunnelsView) selectTunnel(tunnelName string) { } } -func (tv *TunnelsView) SelectFirstActiveTunnel() { +func (tv *ListView) SelectFirstActiveTunnel() { tunnels := make([]service.Tunnel, len(tv.model.tunnels)) copy(tunnels, tv.model.tunnels) go func() { diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index 8cb64904..10a6c782 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -23,7 +23,7 @@ import ( type TunnelsPage struct { *walk.TabPage - tunnelsView *TunnelsView + tunnelsView *ListView confView *ConfView fillerButton *walk.PushButton fillerHandler func() |