summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtkcalls_unix.go26
-rw-r--r--todo.md1
2 files changed, 26 insertions, 1 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index 7d2c4ca..158f5f9 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -6,6 +6,7 @@
package ui
import (
+ "fmt"
"unsafe"
)
@@ -60,10 +61,35 @@ func gtk_window_get_size(window *C.GtkWidget) (int, int) {
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
+// TODO report to oxygen-gtk devs
+var gtkLayoutCSS = []byte(`GtkLayout {
+ background-color: transparent;
+}
+`)
+
+func makeTransparent(layout *C.GtkWidget) {
+ var err *C.GError = nil // redundant in Go, but let's explicitly assign it anyway
+
+ provider := C.gtk_css_provider_new()
+ added := C.gtk_css_provider_load_from_data(provider,
+ (*C.gchar)(unsafe.Pointer(&gtkLayoutCSS[0])), C.gssize(len(gtkLayoutCSS)), &err)
+ if added == C.FALSE {
+ message := C.GoString(fromgchar(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
// thanks to Company in irc.gimp.net/#gtk+
func gtkNewWindowLayout() *C.GtkWidget {
layout := C.gtk_layout_new(nil, nil)
+ makeTransparent(layout)
scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil))
C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(scrollarea)), layout)
// never show scrollbars; we're just doing this to allow arbitrary resizes
diff --git a/todo.md b/todo.md
index 822e421..0026957 100644
--- a/todo.md
+++ b/todo.md
@@ -57,7 +57,6 @@ super ultra important things:
- frame sizes are a bit of a hack: the preferred size of a NSScrollView is the preferred size of its document view; the frameSize method described on the above link might be better but a real solution is optimal
- make sure the image drawn on an Area looks correct on all platforms (is not cropped incorrectly or blurred)
- when resizing a GTK+ window smaller than a certain size, the controls inside will start clipping in bizarre ways (progress bars/entry lines will just cut off; editable comboboxes will stretch slightly longer than noneditable ones; the horizontal scrollbar in Area will disappear smoothly; etc.)
-- the window background of a GTK+ window seems to be... off - I think it has to do with the GtkLayout
- see update 18 March 2014 in README
- resizing seems to be completely and totally broken in the Wayland backend
- TODO find out if this is a problem on the GTK+/Wayland side (no initial window-configure event?)