diff options
-rw-r--r-- | src/tab.c | 61 |
1 files changed, 61 insertions, 0 deletions
@@ -28,6 +28,67 @@ #include "tab-body.h" static void +update_positions(MqTab *node, step) +{ + if (node) { + node->position += step; + update_tab_label(node); + if (node->next) { + update_positions(node->next); + } else if (node->parent && node->parent->next) { + update_positions(node->parent->next); + } + } +} + +static void +update_tree_sizes(MqTab node, guint step) +{ + if (node) { + node->tree_size += step; + update_tree_sizes(node->parent, step); + } +} + +static void +append_child(MqTab *new_node, MqTab *parent) +{ + new_node->parent = parent; + new_node->next = NULL; + new_node->prev = parent->last_child; /* May be NULL */ + new_node->first_child = new_node->last_child = NULL; + new_node->position = parent->position; /* Will be updated */ + new_node->tree_size = 0; /* Will be updated */ + if (parent->last_child) { + parent->last_child->next = new_node; + } else { + parent->first_child = new_node; + } + parent->last_child = new_node; + update_positions(new_node, 1); + update_tree_sizes(new_node, 1); +} + +static void +append_sibling(MqTab *new_node, MqTab *prev_sibling) +{ + new_node->parent = prev_sibling->parent; + new_node->prev = prev_sibling; + new_node->next = prev_sibling->next; /* May be NULL */ + new_node->first_child = new_node->last_child = NULL; + new_node->position = prev_sibling->position; /* Will be updated */ + new_node->tree_size = 0; /* Will be updated */ + if (parent->last_child) { + parent->last_child->next = new_node; + } else { + parent->first_child = new_node; + } + parent->last_child = new_node; + update_positions(new_node, 1); + update_tree_sizes(new_node, 1); +} + +static void reload_tab_clicked_cb(GtkWidget __attribute__((unused)) *button, MqTab *tab) { webkit_web_view_reload(tab->web_view); |