From 3bf115b56e75db0488a797f110c8717ff9a5a966 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 26 May 2019 15:03:20 -0700 Subject: open and close windows on linux for the VM Signed-off-by: Jeff Carr --- .gitignore | 1 + .structs.go.swp | Bin 16384 -> 0 bytes gui.go | 6 ++++++ mainCloudBox.go | 11 +++++++++-- structs.go | 2 ++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .gitignore delete mode 100644 .structs.go.swp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/.structs.go.swp b/.structs.go.swp deleted file mode 100644 index 5f7effd..0000000 Binary files a/.structs.go.swp and /dev/null differ diff --git a/gui.go b/gui.go index 36d297e..9199eca 100644 --- a/gui.go +++ b/gui.go @@ -142,6 +142,12 @@ func mouseClick(b *ButtonMap) { createVmBox(Data.cloudTab, b.VM) } } + if (b.Action == "WINDOW CLOSE") { + b.W.Hide() + // TODO: fix this (seems to crash? maybe because we are in the button here?) + // b.W.Destroy() + return + } if (b.Action == "ADD") { log.Println("\tgui.mouseClick() SHOULD ADD VM HERE?") } diff --git a/mainCloudBox.go b/mainCloudBox.go index 8109c96..973d510 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -239,12 +239,19 @@ func ShowVM() { name := Data.CurrentVM.Name log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM) VMwin := ui.NewWindow("VM " + name, 500, 300, false) + + // create a 'fake' button entry for the mouse clicks + var newButtonMap ButtonMap + newButtonMap.Action = "WINDOW CLOSE" + newButtonMap.W = VMwin + Data.AllButtons = append(Data.AllButtons, newButtonMap) + VMwin.OnClosing(func(*ui.Window) bool { + mouseClick(&newButtonMap) return true }) ui.OnShouldQuit(func() bool { - VMwin.Destroy() - VMwin = nil + mouseClick(&newButtonMap) return true }) diff --git a/structs.go b/structs.go index 903034d..b5377ee 100644 --- a/structs.go +++ b/structs.go @@ -101,6 +101,8 @@ type ButtonMap struct { B *ui.Button FB *ui.FontButton A *ui.Area + W *ui.Window + Account *pb.Account VM *pb.Event_VM Action string // what type of button -- cgit v1.2.3