For my Ymuse project, which has quite a few widgets, I've created an extended version of Builder. It features the BindWidgets() method, which uses reflection to bind widgets from a .glade file to the same-named fields in a struct.
It saves a lot of searching and casting, and binding a struct is as simple as:
w := &MainWindow{}
if err := builder.BindWidgets(w); err != nil {
log.Fatalf("BindWidgets() failed: %v", err)
}
The method is quite generic and would bind widgets of any type reflection can recognize. It's also unit-tested.
Would it be interesting to incorporate that in gotk3's codebase?
I was searching for glade in the issue tracker and I'm glad at least there is some code to allow me to design my UI on Glade and use it with this project.
For my Ymuse project, which has quite a few widgets, I've created an extended version of
Builder
. It features theBindWidgets()
method, which uses reflection to bind widgets from a.glade
file to the same-named fields in a struct.It saves a lot of searching and casting, and binding a struct is as simple as:
The method is quite generic and would bind widgets of any type reflection can recognize. It's also unit-tested.
Would it be interesting to incorporate that in gotk3's codebase?