diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-25 10:19:08 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-25 10:19:08 (EDT) |
commit | 5f1541db4c3d4fd4d571d0010947c3c13caff3db (patch) | |
tree | ff0bc69240f25598908609a357fa9399d9342bb0 | |
parent | 6f05aac3da050ce0fe3fd23605d0dd8faac36ac8 (diff) | |
download | marquee-5f1541db4c3d4fd4d571d0010947c3c13caff3db.zip marquee-5f1541db4c3d4fd4d571d0010947c3c13caff3db.tar.gz marquee-5f1541db4c3d4fd4d571d0010947c3c13caff3db.tar.bz2 |
mq_tree_remove_allocated(): Implement
-rw-r--r-- | src/tree.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -181,8 +181,32 @@ mq_tree_append_sibling_allocated(MqTree *node, MqTree *sibling, gpointer data) void mq_tree_remove_allocated(MqTree *node) { - /* TODO */ - node = node; + MqTree *child; + + /* Link previous sibling or parent to children. */ + if (node->prev) { + node->prev->next = node->first_child; + } else { + node->parent->first_child = node->first_child; + if (!node->next) { + node->parent->last_child = node->last_child; + } + } + + /* Link children to siblings (may be NULL). */ + if (node->first_child) { + node->first_child->prev = node->prev; + } + if (node->last_child) { + node->last_child->next = node->next; + } + + /* Link children to parent. */ + for (child = node->first_child; child; child = child->next) { + child->parent = node->parent; + } + + update_positions(node, -1); } MqTree * |