diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-09 16:21:09 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-09 16:21:09 -0400 |
| commit | 92b43720b6b33e838f8e9b5dffaa556529de3d52 (patch) | |
| tree | 5bbfb07548bab0cdbecb2b38a479321e6730d6b4 /new/newcontrol_unix.c | |
| parent | 3f05be544ce9e57e8b00dfe99a64f223c6c2539b (diff) | |
Decided to split control removal from parent into its own method removeParent() rather than automatically doing it in setParent().
Diffstat (limited to 'new/newcontrol_unix.c')
| -rw-r--r-- | new/newcontrol_unix.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/new/newcontrol_unix.c b/new/newcontrol_unix.c index 0f050be..870406c 100644 --- a/new/newcontrol_unix.c +++ b/new/newcontrol_unix.c @@ -27,17 +27,23 @@ static uintptr_t singleHandle(uiControl *c) static void singleSetParent(uiControl *c, uintptr_t parent) { 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 void singleRemoveParent(uiControl *c) +{ + uiSingleWidgetControl *s = S(c); + uintptr_t oldparent; + + oldparent = s->parent; + s->parent = 0; + gtk_container_remove(GTK_CONTAINER(oldparent), s->immediate); + updateParent(oldparent); +} + static uiSize singlePreferredSize(uiControl *c, uiSizing *d) { uiSize size; @@ -101,7 +107,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 + // this also ensures singleRemoveParent() works properly g_object_ref_sink(c->immediate); // and let's free the uiSingleWidgetControl with it g_signal_connect(c->immediate, "destroy", G_CALLBACK(onDestroy), c); @@ -109,6 +115,7 @@ uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scro c->control.destroy = singleDestroy; c->control.handle = singleHandle; c->control.setParent = singleSetParent; + c->control.removeParent = singleRemoveParent; c->control.preferredSize = singlePreferredSize; c->control.resize = singleResize; |
