From 8dac5910395e89d034f177303e5ae38f2628a627 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 12 Jun 2014 12:09:24 -0400 Subject: [PATCH] Converted the GTK+ custom stylesheet to a single string using CSS comments because cgo complains about the current one. While I'm at it, also remove the need for the null terminator on that string. Thanks to various people in irc.gimp.net/#gtk+ (grawity, dro|desrt, Company) and irc.freenode.net/#go-nuts and the Gopher Academy Slack. --- gtkcalls_unix.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go index a6aa405..8f202b3 100644 --- a/gtkcalls_unix.go +++ b/gtkcalls_unix.go @@ -28,23 +28,27 @@ import ( // } import "C" -var gtkStyles = []byte( - // this first one is for ProgressBar so we can arbitrarily resize it - // min-horizontal-bar-width is a style property; we do it through CSS - // thanks tristan in irc.gimp.net/#gtk+ - `* { +var gtkStyles = []byte(` +/* +this first one is for ProgressBar so we can arbitrarily resize it +min-horizontal-bar-width is a style property; we do it through CSS +thanks tristan in irc.gimp.net/#gtk+ +*/ +* { -GtkProgressBar-min-horizontal-bar-width: 1; } -` + - // on some themes, such as oxygen-gtk, GtkLayout draws a solid-color background, not the window background (as GtkFixed and GtkDrawingArea do) - // this CSS fixes it - // thanks to drahnr and ptomato in http://stackoverflow.com/questions/22940588/how-do-i-really-make-a-gtk-3-gtklayout-transparent-draw-theme-background - // this has now been reported to the Oyxgen maintainers (https://bugs.kde.org/show_bug.cgi?id=333983); I'm not sure if I'll remove this or not when that's fixed (only if it breaks other styles... I *think* it breaks elementary OS? need to check again) - `GtkLayout { + +/* +on some themes, such as oxygen-gtk, GtkLayout draws a solid-color background, not the window background (as GtkFixed and GtkDrawingArea do) +this CSS fixes it +thanks to drahnr and ptomato in http://stackoverflow.com/questions/22940588/how-do-i-really-make-a-gtk-3-gtklayout-transparent-draw-theme-background +this has now been reported to the Oyxgen maintainers (https://bugs.kde.org/show_bug.cgi?id=333983); I'm not sure if I'll remove this or not when that's fixed (only if it breaks other styles... I *think* it breaks elementary OS? need to check again) +TODO write a program that does the comparison +*/ +GtkLayout { background-color: transparent; } -` + - "\000") +`) func gtk_init() error { var err *C.GError = nil // redundant in Go, but let's explicitly assign it anyway @@ -58,7 +62,7 @@ func gtk_init() error { // now apply our custom program-global styles provider := C.gtk_css_provider_new() - if C.gtk_css_provider_load_from_data(provider, (*C.gchar)(unsafe.Pointer(>kStyles[0])), -1, &err) == C.FALSE { + if C.gtk_css_provider_load_from_data(provider, (*C.gchar)(unsafe.Pointer(>kStyles[0])), C.gssize(len(gtkStyles)), &err) == C.FALSE { return fmt.Errorf("error applying package ui's custom program-global styles to GTK+: %v", fromgstr(err.message)) } // GDK (at least as far back as GTK+ 3.4, but officially documented as of 3.10) merges all screens into one big one, so we don't need to worry about multimonitor