conformal / gotk3

Go bindings for GTK3
ISC License
470 stars 81 forks source link

Added support to automatically bind events when using Builder. #98

Open joangs opened 9 years ago

joangs commented 9 years ago

type Test struct { patata int }

func (Test) On_button1_clicked(button gtk.Button) { // clicked }

.....

if builder, err = gtk.BuilderNew(); err != nil {
    log.Fatalf("Error: %s", err.Error())
}

builder.AddFromFile("gui.builder")
builder.BindCallbacks(builder, &Test{})

Changes to be committed: new file: glib/glib_extra.go modified: gtk/gtk.go new file: gtk/gtkbuilder_bridge.go new file: gtk/gtkbuilder_cgo.go

omac777 commented 9 years ago

Pardon my ignorance, but is Builder the next generation of glade?

The current samples of gotk3 dynamically create the gui. Your work seems to imply you have a Builder IDE that currently runs and is starting to play well with golang. Is that the case? Will that work be directly integrated within gotk3, Builder or somewhere else?

I noticed a funding campaign going on for Builder, but they never mentioned any golang support within as part of any of their funding campaign targets. I believe it should be mentioned as a target. Gophers I believe would chip in.

Why isn't gotk3 actually not trying to do a funding campaign? Again, I believe gophers would chip in here too.

Cheers :)

On 12/30/2014 04:24 PM, Joan Garcia i Silano wrote:

type Test struct { patata int }

func (Test) On_button1_clicked(button gtk.Button) { // clicked }

.....

if builder, err = gtk.BuilderNew(); err != nil { log.Fatalf("Error: %s", err.Error()) }

builder.AddFromFile("gui.builder") builder.BindCallbacks(builder, &Test{})

Changes to be committed: new file: glib/glib_extra.go modified: gtk/gtk.go new file: gtk/gtkbuilder_bridge.go new file: gtk/gtkbuilder_cgo.go You can merge this Pull Request by running:

git pull https://github.com/joangs/gotk3 master

Or you can view, comment on it, or merge it online at:

https://github.com/conformal/gotk3/pull/98

-- Commit Summary --

  • Added support to automatically bind events when using Builder.

-- File Changes --

A glib/glib_extra.go (24)
M gtk/gtk.go (5)
A gtk/gtkbuilder_bridge.go (70)
A gtk/gtkbuilder_cgo.go (91)

-- Patch Links --

https://github.com/conformal/gotk3/pull/98.patch https://github.com/conformal/gotk3/pull/98.diff


Reply to this email directly or view it on GitHub: https://github.com/conformal/gotk3/pull/98

joangs commented 9 years ago

The gtk Builder creates a GUI from a description (file, string, etc..), but you must bind the events associated to the GUI objects. You can use glade to edit the GUI and save it in GtkBuilder format.

https://developer.gnome.org/gtk3/stable/GtkBuilder.html