GTK3
GTK3 notes
Add CSS class to widgets
func GtkWidgetAddClass(widget *gtk.Widget, class string) {
context, err := widget.GetStyleContext()
if err != nil {
log.Fatal(err)
}
context.AddClass(class)
}
Apply styles from a CSS file
For CSS syntax: GTK3 CSS overview
mRefProvider, _ := gtk.CssProviderNew()
mRefProvider.LoadFromPath("style.css")
// Apply to whole app
screen, _ := gdk.ScreenGetDefault()
gtk.AddProviderForScreen(screen, mRefProvider, 999)
Kill application when out of focus
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
...
win.SetEvents(int(gdk.FOCUS_CHANGE_MASK))
win.Connect("focus-out-event", func() { gtk.MainQuit() })