summaryrefslogtreecommitdiff
path: root/redo/controls_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'redo/controls_unix.go')
-rw-r--r--redo/controls_unix.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/redo/controls_unix.go b/redo/controls_unix.go
index 1be152b..e48aab2 100644
--- a/redo/controls_unix.go
+++ b/redo/controls_unix.go
@@ -13,6 +13,8 @@ import "C"
type widgetbase struct {
widget *C.GtkWidget
+ parentw *window
+ floating bool
}
func newWidget(w *C.GtkWidget) *widgetbase {
@@ -21,6 +23,29 @@ func newWidget(w *C.GtkWidget) *widgetbase {
}
}
+// these few methods are embedded by all the various Controls since they all will do the same thing
+
+func (w *widgetbase) unparent() {
+ if w.parentw != nil {
+ // add another reference so it doesn't get removed by accident
+ C.g_object_ref(C.gpointer(unsafe.Pointer(w.widget)))
+ // we unref this in parent() below
+ w.floating = true
+ C.gtk_container_remove(w.parentw.layoutc, w.widget)
+ w.parentw = nil
+ }
+}
+
+func (w *widgetbase) parent(win *window) {
+ C.gtk_container_add(win.layoutc, w.widget)
+ w.parentw = win
+ // was previously parented; unref our saved ref
+ if w.floating {
+ C.g_object_unref(C.gpointer(unsafe.Pointer(w.widget)))
+ w.floating = false
+ }
+}
+
type button struct {
*widgetbase
button *C.GtkButton