This project is no longer actively developed. For a promising set of generated gtk bindings, take a look at https://github.com/diamondburned/gotk4.
gobject bindings
gobbi is a set of generated Go bindings for gobject based libraries. There are bindings, with varying degrees of completeness, for gtk, gdk, gdkpixbuf, gio, gobject, and glib.
The intention is to provide the bindings required for writing gtk applications. So the focus is on supporting functions in the higher level libraries such as gtk, gdk, gdkpixbuf and gio. Much of the functionality provided by the lower level libraries, such as glib and gobject, is adequately supported in Go core packages.
package main
import (
"github.com/pekim/gobbi/lib/gtk"
"os"
"runtime"
)
func init() {
runtime.LockOSThread()
}
func main() {
gtk.Init(os.Args)
window := gtk.WindowNew(gtk.GTK_WINDOW_TOPLEVEL)
window.SetTitle("A window title")
window.SetDefaultSize(300, 300)
window.Widget().ConnectDestroy(func(_ *gtk.Widget) {
gtk.MainQuit()
})
window.Widget().ShowAll()
gtk.Main()
}
go get github.com/pekim/gobbi
go run -tags "glib_2.48 gdk_3.4 gdkpixbuf_2.32 gio_2.32 gtk_3.18" gobbi-simple.go
https://pekim.github.io/gobbi/
At a minimum it's probably a good idea to read at least the Getting started and Application lifecycle pages.
The code that implements most of the APIs is generated from the GObject Introspection (gir) XML files in the internal/gir-files directory. The generation code is in the internal/generate package.
All of the generated API code, and a very small number of manually maintained files, is in the subdirectories of the lib directory.
The library should be perfectly servicable and complete enough to build most applications.
Some simple example applications have been created, and may be found in the example directory. It is possible that for more complex applications some necessary apis may be missing.
The API is reasonably stable, although some changes are certainly possible.
The generation code is rather messy in some areas, and needs tidying up. The generated code is simple, and fairly readable.
gotk3 is a more mature library than gobbi. It might be a safer choice than gobbi for those who are cautious. However gobbi should work just as well in most cases.
gobbi supports a larger number of apis than gotk3. However gotk3 supports some apis that gobbi does not, and vice versa.
gobbi is more type safe in some areas, notably the callbacks connected to signals.