Moved the GtkLayout transparency style to the new init-time style code in gtkcalls_unix.go.

This commit is contained in:
Pietro Gagliardi 2014-06-02 13:39:27 -04:00
parent 986bb201d9
commit 812d547a5a
1 changed files with 10 additions and 26 deletions

View File

@ -19,7 +19,16 @@ var gtkStyles = []byte(
// thanks tristan in irc.gimp.net/#gtk+ // thanks tristan in irc.gimp.net/#gtk+
`* { `* {
-GtkProgressBar-min-horizontal-bar-width: 1; -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 {
background-color: transparent;
}
` +
"\000") "\000")
func gtk_init() error { func gtk_init() error {
@ -83,35 +92,10 @@ func gtk_window_get_size(window *C.GtkWidget) (int, int) {
return int(width), int(height) return int(width), int(height)
} }
// 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)
var gtkLayoutCSS = []byte(`GtkLayout {
background-color: transparent;
}
` + "\000")
func makeTransparent(layout *C.GtkWidget) {
var err *C.GError = nil
provider := C.gtk_css_provider_new()
added := C.gtk_css_provider_load_from_data(provider,
(*C.gchar)(unsafe.Pointer(&gtkLayoutCSS[0])), -1, &err)
if added == C.FALSE {
message := fromgstr(err.message)
panic(fmt.Errorf("error loading transparent background CSS for GtkLayout: %s", message))
}
C.gtk_style_context_add_provider(C.gtk_widget_get_style_context(layout),
(*C.GtkStyleProvider)(unsafe.Pointer(provider)),
C.GTK_STYLE_PROVIDER_PRIORITY_USER)
}
// this should allow us to resize the window arbitrarily // this should allow us to resize the window arbitrarily
// thanks to Company in irc.gimp.net/#gtk+ // thanks to Company in irc.gimp.net/#gtk+
func gtkNewWindowLayout() *C.GtkWidget { func gtkNewWindowLayout() *C.GtkWidget {
layout := C.gtk_layout_new(nil, nil) layout := C.gtk_layout_new(nil, nil)
makeTransparent(layout)
scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil)) scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil))
C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(scrollarea)), layout) C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(scrollarea)), layout)
// never show scrollbars; we're just doing this to allow arbitrary resizes // never show scrollbars; we're just doing this to allow arbitrary resizes