From 59daf6c6ed64d58e8903db35637527fa46ed9c94 Mon Sep 17 00:00:00 2001
From: Ruben Pollan <meskio@sindominio.net>
Date: Thu, 29 Nov 2018 13:55:27 +0100
Subject: [PATCH] [feat] don't need the cancel button

We can do just with two buttons and changing the names.
---
 systray.go              | 20 +++++---------------
 transifex/messages.json |  1 -
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/systray.go b/systray.go
index 4e4e3d51..a37c0e8a 100644
--- a/systray.go
+++ b/systray.go
@@ -37,7 +37,6 @@ type bmTray struct {
 	mTurnOn       *systray.MenuItem
 	mTurnOff      *systray.MenuItem
 	mDonate       *systray.MenuItem
-	mCancel       *systray.MenuItem
 	activeGateway *gatewayTray
 	autostart     autostart
 }
@@ -75,8 +74,6 @@ func (bt *bmTray) onReady() {
 	bt.mTurnOn.Hide()
 	bt.mTurnOff = systray.AddMenuItem(printer.Sprintf("Turn off"), "")
 	bt.mTurnOff.Hide()
-	bt.mCancel = systray.AddMenuItem(printer.Sprintf("Cancel"), printer.Sprintf("Cancel connection to %s", applicationName))
-	bt.mCancel.Hide()
 	systray.AddSeparator()
 
 	if bt.conf.SelectGateway {
@@ -114,11 +111,6 @@ func (bt *bmTray) onReady() {
 				bt.changeStatus("stopping")
 				bt.bm.StopVPN()
 				bt.conf.setUserStoppedVPN(true)
-			case <-bt.mCancel.ClickedCh:
-				log.Println("cancel")
-				bt.changeStatus("stopping")
-				bt.bm.StopVPN()
-				bt.conf.setUserStoppedVPN(true)
 
 			case <-mHelp.ClickedCh:
 				open.Run("https://riseup.net/vpn/support")
@@ -195,7 +187,6 @@ func (bt *bmTray) addGateways() {
 }
 
 func (bt *bmTray) changeStatus(status string) {
-	bt.mTurnOn.SetTitle(printer.Sprintf("Turn on"))
 	if bt.waitCh != nil {
 		bt.waitCh <- true
 		bt.waitCh = nil
@@ -205,25 +196,25 @@ func (bt *bmTray) changeStatus(status string) {
 	switch status {
 	case "on":
 		systray.SetIcon(icon.On)
+		bt.mTurnOff.SetTitle(printer.Sprintf("Turn off"))
 		statusStr = printer.Sprintf("%s on", applicationName)
 		bt.mTurnOn.Hide()
 		bt.mTurnOff.Show()
-		bt.mCancel.Hide()
 
 	case "off":
 		systray.SetIcon(icon.Off)
+		bt.mTurnOn.SetTitle(printer.Sprintf("Turn on"))
 		statusStr = printer.Sprintf("%s off", applicationName)
 		bt.mTurnOn.Show()
 		bt.mTurnOff.Hide()
-		bt.mCancel.Hide()
 
 	case "starting":
 		bt.waitCh = make(chan bool)
 		go bt.waitIcon()
+		bt.mTurnOff.SetTitle(printer.Sprintf("Cancel"))
 		statusStr = printer.Sprintf("Connecting to %s", applicationName)
 		bt.mTurnOn.Hide()
-		bt.mTurnOff.Hide()
-		bt.mCancel.Show()
+		bt.mTurnOff.Show()
 
 	case "stopping":
 		bt.waitCh = make(chan bool)
@@ -231,15 +222,14 @@ func (bt *bmTray) changeStatus(status string) {
 		statusStr = printer.Sprintf("Stopping %s", applicationName)
 		bt.mTurnOn.Hide()
 		bt.mTurnOff.Hide()
-		bt.mCancel.Hide()
 
 	case "failed":
 		systray.SetIcon(icon.Blocked)
 		bt.mTurnOn.SetTitle(printer.Sprintf("Retry"))
+		bt.mTurnOff.SetTitle(printer.Sprintf("Turn off"))
 		statusStr = printer.Sprintf("%s blocking internet", applicationName)
 		bt.mTurnOn.Show()
 		bt.mTurnOff.Show()
-		bt.mCancel.Hide()
 	}
 
 	systray.SetTooltip(statusStr)
diff --git a/transifex/messages.json b/transifex/messages.json
index f332f743..19610a87 100644
--- a/transifex/messages.json
+++ b/transifex/messages.json
@@ -2,7 +2,6 @@
     "About": "About",
     "About...": "About...",
     "Cancel": "Cancel",
-    "Cancel connection to {ApplicationName}": "Cancel connection to {ApplicationName}",
     "Checking status...": "Checking status...",
     "Connecting to {ApplicationName}": "Connecting to {ApplicationName}",
     "Donate": "Donate",
-- 
GitLab