From cdd487f86a94f6159040809ed6941602f811fb6d Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 10 May 2013 15:26:14 -0400 Subject: [PATCH] fiddling with the buttons. i'm new to gui things... --- gimgsrv/main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gimgsrv/main.go b/gimgsrv/main.go index 462fc3c..d811482 100644 --- a/gimgsrv/main.go +++ b/gimgsrv/main.go @@ -6,8 +6,10 @@ import ( "github.com/ziutek/gtk" ) +// this happens when the X is clicked (to close the app) func cbDelete(w *gtk.Widget, ev *gdk.Event) bool { fmt.Println("Delete") + defer gtk.MainQuit() return true } @@ -23,10 +25,14 @@ func main() { w.SetBorderWidth(10) w.Show() - a := A{"Hello World!\n"} + f := gtk.NewFileChooserButton("Select File", gtk.FILE_CHOOSER_ACTION_OPEN) + w.Add(f.AsWidget()) + f.Show() - b := gtk.NewButtonWithLabel("Hello World") - b.Connect("clicked", (*A).Hello, &a) + a := Action{"Hello World!\n"} + + b := gtk.NewButtonWithLabel("Quit") + b.Connect("clicked", (*Action).Quit, &a) b.ConnectNoi("clicked", (*gtk.Widget).Destroy, w.AsWidget()) w.Add(b.AsWidget()) b.Show() @@ -34,10 +40,10 @@ func main() { gtk.Main() } -type A struct { +type Action struct { s string } -func (a *A) Hello(w *gtk.Widget) { +func (a *Action) Quit(w *gtk.Widget) { fmt.Printf(a.s) }