- Hands-On GUI Application Development in Go
- Andrew Williams
- 395字
- 2025-04-04 14:54:22
GTK+ background
GTK+, or the GNU Image Manipulation Program (GIMP) Toolkit (a popular cross-platform image editor), is a cross-platform API for creating graphical applications. The project aims to provide a complete set of GUI widgets, supporting small graphical utilities up to large application suites:

Since its creation, the toolkit's adoption has rapidly expanded, supported by its open source license, which supports its use in commercial and freely available applications alike. While version 1.0 (released in 1998) was primarily to support the functions of the GIMP application, by 1.2 (released less than a year later) the toolkit was aiming at a broader audience. In 2002, version 2.0 was released, which saw GTK+ become the official tookit for the Gnome Linux desktop. This fully featured release greatly expanded adoption, to become one of the most popular widget sets available for cross-platform development—and minor releases of the 2.x version are still very popular in 2018. In 2011, 3.0 was released with many changes included, the most visual of which was a new theme engine based on Cascading Style Sheets (CSS), which is familiar to most web developers. Though CSS is easier to create themes for, there have been criticisms of the new approach, and many distributors continue to deliver version 2.24 despite it being more than seven years old.
One of the benefits of Go is that it offers a single API for applications that behave consistently across multiple platforms. GTK+ (and Qt, covered in the following chapter) is an API that has a similar approach to enabling GUI application development. By combining the two through a binding to the Go language, we can create applications that can (depending on a user's theme settings) look and behave the same across all supported operating systems (Windows, macOS, Linux, and many Unix distributions). The Go bindings that we're working with in this chapter were created by Yasuhiro Matsumoto and the project has a long list of maintainers. It focuses on GTK2 support and aims to offer bindings for the complete API, but currently many features aren't available. As you will see in this chapter, the bindings currently available support the needs of most applications and so the partial completion of their goal won't impact most developer's use of this API.