summaryrefslogtreecommitdiff
path: root/redo/window_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-25 19:44:32 -0400
committerPietro Gagliardi <[email protected]>2014-07-25 19:44:32 -0400
commitd1702d33e055fb254cfacb1ad7d3d3f60314bba6 (patch)
tree34aaaa02191d3ba81907b11a885bbd57a7da74c2 /redo/window_unix.go
parent010c97d686f8e10f940c98b62ffb5a6735f73490 (diff)
Updated the GTK+ backend to have the new parenting and sizing changes. Now to implement Tab! ...though I should probably implement the changes on Mac OS X first.
Diffstat (limited to 'redo/window_unix.go')
-rw-r--r--redo/window_unix.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/redo/window_unix.go b/redo/window_unix.go
index 26675e7..6ab68b1 100644
--- a/redo/window_unix.go
+++ b/redo/window_unix.go
@@ -16,7 +16,7 @@ import "C"
type window struct {
widget *C.GtkWidget
- container *C.GtkContainer
+ wc *C.GtkContainer
bin *C.GtkBin
window *C.GtkWindow
@@ -24,28 +24,32 @@ type window struct {
layoutc *C.GtkContainer
layout *C.GtkLayout
- child Control
-
closing *event
- spaced bool
+ *container
+}
+
+type controlParent interface {
+ setParent(*C.GtkContainer)
}
-func newWindow(title string, width int, height int) *window {
+func newWindow(title string, width int, height int, control Control) *window {
widget := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
ctitle := togstr(title)
defer freegstr(ctitle)
layoutw := C.gtk_layout_new(nil, nil)
w := &window{
widget: widget,
- container: (*C.GtkContainer)(unsafe.Pointer(widget)),
+ wc: (*C.GtkContainer)(unsafe.Pointer(widget)),
bin: (*C.GtkBin)(unsafe.Pointer(widget)),
window: (*C.GtkWindow)(unsafe.Pointer(widget)),
layoutw: layoutw,
layoutc: (*C.GtkContainer)(unsafe.Pointer(layoutw)),
layout: (*C.GtkLayout)(unsafe.Pointer(layoutw)),
closing: newEvent(),
+ container: new(container),
}
+ w.container.beginResize = w.beginResize
C.gtk_window_set_title(w.window, ctitle)
g_signal_connect(
C.gpointer(unsafe.Pointer(w.window)),
@@ -62,7 +66,9 @@ func newWindow(title string, width int, height int) *window {
C.GCallback(C.windowResizing),
C.gpointer(unsafe.Pointer(w)))
C.gtk_window_resize(w.window, C.gint(width), C.gint(height))
- C.gtk_container_add(w.container, layoutw)
+ C.gtk_container_add(w.wc, layoutw)
+ w.child = control
+ w.child.setParent(w.layoutc)
return w
}
@@ -105,6 +111,6 @@ func windowClosing(wid *C.GtkWidget, e *C.GdkEvent, data C.gpointer) C.gboolean
//export windowResizing
func windowResizing(wid *C.GtkWidget, r *C.GdkRectangle, data C.gpointer) {
w := (*window)(unsafe.Pointer(data))
- w.doresize(int(r.width), int(r.height))
+ w.resize(int(r.width), int(r.height))
fmt.Printf("new size %d x %d\n", r.width, r.height)
}