From 3bc68118113bb96ab1306363d984cce23b15957a Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 6 Apr 2019 05:50:51 -0700 Subject: [PATCH] clean up the code more Signed-off-by: Jeff Carr --- make-sdcard/main.go | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/make-sdcard/main.go b/make-sdcard/main.go index 7c63adb..912d711 100644 --- a/make-sdcard/main.go +++ b/make-sdcard/main.go @@ -89,37 +89,16 @@ func format(mybut *ui.Button) { simpleProcess("dd if=../u-boot/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1K seek=8") } -func hostnameButton(hostname string, something func(*ui.Button)) ui.Control { - tmpbox := ui.NewHorizontalBox() - tmpbox.SetPadded(true) +func addButton(vbox *ui.Box, label string, click func(*ui.Button)) { + hbox := ui.NewHorizontalBox() + hbox.SetPadded(true) - tmpButton := ui.NewButton(hostname) - tmpbox.Append(tmpButton, false) - tmpButton.OnClicked(something) -/* - tmpButton.OnClicked(func(*ui.Button) { - log.Println("hostname =", config.String("hostname"), tmpButton) - }) -*/ + // look up translation here for 'label' + button := ui.NewButton(label) + hbox.Append(button, false) + button.OnClicked(click) - return tmpbox -} - -func addButton(vbox *ui.Box, hostname string, buttonClick func(*ui.Button)) { - tmpbox := ui.NewHorizontalBox() - tmpbox.SetPadded(true) - -/* - tmpButton := ui.NewButton(hostname) - tmpbox.Append(tmpButton, false) - tmpButton.OnClicked(doButton) - log.Println("addButton() set doButton =", tmpButton) - tmpButton.OnClicked(func(*ui.Button) { - log.Println("hostname =", config.String("hostname"), tmpButton) - }) -*/ - - vbox.Append(hostnameButton(hostname, buttonClick), false) + vbox.Append(hbox, false) } func makeButtonsPage(names []string) ui.Control {