summaryrefslogtreecommitdiff
path: root/new/newcontrol_unix.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-08 18:58:59 -0400
committerPietro Gagliardi <[email protected]>2015-04-08 18:58:59 -0400
commit7c2a32fec6774f07fa4149526b0e10e87e52f456 (patch)
treea0378357f1b799619282f09387d8b967824de71c /new/newcontrol_unix.c
parentc1c78b5aeb6b9d85886af3ea00a3c9ddc1ed372d (diff)
Implemented the parent updating logic on GTK+.
Diffstat (limited to 'new/newcontrol_unix.c')
-rw-r--r--new/newcontrol_unix.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/new/newcontrol_unix.c b/new/newcontrol_unix.c
index c883a5a..0f050be 100644
--- a/new/newcontrol_unix.c
+++ b/new/newcontrol_unix.c
@@ -9,6 +9,7 @@ struct uiSingleWidgetControl {
GtkWidget *scrolledWindow;
GtkWidget *immediate; // the widget that is added to the parent container; either widget or scrolledWindow
void *data;
+ uintptr_t parent;
};
#define S(c) ((uiSingleWidgetControl *) (c))
@@ -25,7 +26,16 @@ static uintptr_t singleHandle(uiControl *c)
static void singleSetParent(uiControl *c, uintptr_t parent)
{
- gtk_container_add(GTK_CONTAINER(parent), S(c)->immediate);
+ uiSingleWidgetControl *s = S(c);
+ uintptr_t oldparent;
+
+ oldparent = s->parent;
+ s->parent = parent;
+ if (oldparent != 0)
+ gtk_container_remove(GTK_CONTAINER(oldparent), s->immediate);
+ gtk_container_add(GTK_CONTAINER(s->parent), s->immediate);
+ updateParent(oldparent);
+ updateParent(s->parent);
}
static uiSize singlePreferredSize(uiControl *c, uiSizing *d)
@@ -91,6 +101,7 @@ uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scro
// with this:
// - end user call works (shoudn't be in any container)
// - call in uiContainer works (both refs freed)
+ // this also ensures singleSetParent() works properly when changing parents
g_object_ref_sink(c->immediate);
// and let's free the uiSingleWidgetControl with it
g_signal_connect(c->immediate, "destroy", G_CALLBACK(onDestroy), c);