summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 0db8b8fd..56b05aa6 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -33,7 +33,12 @@ void destroyPending_Widget(void) {
33 iForEach(PtrSet, i, rootData_.pendingDestruction) { 33 iForEach(PtrSet, i, rootData_.pendingDestruction) {
34 iWidget *widget = *i.value; 34 iWidget *widget = *i.value;
35 remove_PtrSet(onTop_RootData_(), widget); 35 remove_PtrSet(onTop_RootData_(), widget);
36 iRelease(removeChild_Widget(widget->parent, widget)); 36 if (widget->parent) {
37 iRelease(removeChild_Widget(widget->parent, widget));
38 }
39 else {
40 iRelease(widget);
41 }
37 remove_PtrSetIterator(&i); 42 remove_PtrSetIterator(&i);
38 } 43 }
39} 44}
@@ -481,6 +486,7 @@ iAny *addChildFlags_Widget(iWidget *d, iAnyObject *child, int childFlags) {
481} 486}
482 487
483iAny *removeChild_Widget(iWidget *d, iAnyObject *child) { 488iAny *removeChild_Widget(iWidget *d, iAnyObject *child) {
489 iAssert(child);
484 ref_Object(child); 490 ref_Object(child);
485 iBool found = iFalse; 491 iBool found = iFalse;
486 iForEach(ObjectList, i, d->children) { 492 iForEach(ObjectList, i, d->children) {
@@ -505,6 +511,17 @@ iAny *child_Widget(iWidget *d, size_t index) {
505 return NULL; 511 return NULL;
506} 512}
507 513
514size_t childIndex_Widget(const iWidget *d, const iAnyObject *child) {
515 size_t index = 0;
516 iConstForEach(ObjectList, i, d->children) {
517 if (i.object == child) {
518 return index;
519 }
520 index++;
521 }
522 return iInvalidPos;
523}
524
508iAny *findChild_Widget(const iWidget *d, const char *id) { 525iAny *findChild_Widget(const iWidget *d, const char *id) {
509 if (cmp_String(id_Widget(d), id) == 0) { 526 if (cmp_String(id_Widget(d), id) == 0) {
510 return iConstCast(iAny *, d); 527 return iConstCast(iAny *, d);