summaryrefslogtreecommitdiff
path: root/redo/window_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-07 15:30:55 -0400
committerPietro Gagliardi <[email protected]>2014-07-07 15:30:55 -0400
commitc0c38ac8f5ded52f0db925ca7ca4bc6efedcb648 (patch)
treedfd26c04614de99081742446f422559fc9d3f289 /redo/window_unix.go
parent7966d7023015ba3ec5e0ed3c3e5682651b5b33fb (diff)
Added the GTK+ implementation of Window, added the Window constructors, and rewrote the GTK+ Button constructor to use Requests.
Diffstat (limited to 'redo/window_unix.go')
-rw-r--r--redo/window_unix.go110
1 files changed, 110 insertions, 0 deletions
diff --git a/redo/window_unix.go b/redo/window_unix.go
new file mode 100644
index 0000000..f76c350
--- /dev/null
+++ b/redo/window_unix.go
@@ -0,0 +1,110 @@
+// 7 july 2014
+
+package ui
+
+import (
+ "unsafe"
+)
+
+// #include "gtk_unix.h"
+import "C"
+
+type window struct {
+ widget *C.GtkWidget
+ container *C.GtkContainer
+ bin *C.GtkBin
+ window *C.GtkWindow
+}
+
+func newWindow(title string, width int, height int) *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ widget := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
+ ctext := togstr(text)
+ defer freegstr(ctext)
+ w := &window{
+ widget: widget,
+ container: (*C.GtkContainer)(unsafe.Pointer(widget)),
+ bin: (*C.GtkBin)(unsafe.Pointer(widget)),
+ window: (*C.GtkWindow)(unsafe.Pointer(widget)),
+ }
+ C.gtk_window_set_title(w.window, ctext)
+ // TODO size
+ // TODO content
+ c <- w
+ },
+ resp: c,
+ }
+}
+
+func (w *window) SetControl(c Control) *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ // TODO unparent
+ // TODO reparent
+ c <- struct{}{}
+ },
+ done: c,
+ }
+}
+
+func (w *window) Title() *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ c <- fromgstr(C.gtk_window_get_title(w.window))
+ },
+ resp: c,
+ }
+}
+
+func (w *window) SetTitle(title string) *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ ctext := togstr(text)
+ defer freegstr(ctext)
+ C.gtk_window_set_title(w.window, ctext)
+ c <- struct{}{}
+ },
+ resp: c,
+ }
+}
+
+
+func (w *window) Show() *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ C.gtk_widget_show_all(w.widget)
+ c <- struct{}{}
+ },
+ resp: c,
+ }
+}
+
+func (w *window) Hide() *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ C.gtk_widget_hide(w.widget)
+ c <- struct{}{}
+ },
+ resp: c,
+ }
+}
+
+func (w *window) Close() *Request {
+ c := make(chan interface{})
+ return &Request{
+ op: func() {
+ C.gtk_widget_destroy(w.widget)
+ c <- struct{}{}
+ },
+ resp: c,
+ }
+}
+
+// TODO OnClosing