summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-23 05:11:20 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-23 05:11:20 (EDT)
commiteea1cf3441ef435bd632bcd271ed11d304033cf9 (patch)
tree8cf441e101e38ea1eea7f6de237b28ca4a85f6aa
parent35d1f8e82cf469db07e28484f196aa676735db99 (diff)
downloadmarquee-eea1cf3441ef435bd632bcd271ed11d304033cf9.zip
marquee-eea1cf3441ef435bd632bcd271ed11d304033cf9.tar.gz
marquee-eea1cf3441ef435bd632bcd271ed11d304033cf9.tar.bz2
mq_notebook_insert_(): Allow NULL sibling/parent arguments
-rw-r--r--src/notebook.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/notebook.c b/src/notebook.c
index cc9a17e..870acf4 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -184,11 +184,18 @@ mq_notebook_insert_sibling(MqNotebook *notebook, const gchar *uri,
{
MqTabTree *node;
- find_node(notebook, sibling);
- node = MQ_TAB_TREE(mq_tree_insert_sibling_allocated(
- MQ_TREE(g_new0(MqTabTree, 1)),
- MQ_TREE(notebook->found_node),
- NULL));
+ if (sibling) {
+ find_node(notebook, sibling);
+ node = MQ_TAB_TREE(mq_tree_insert_sibling_allocated(
+ MQ_TREE(g_new0(MqTabTree, 1)),
+ MQ_TREE(notebook->found_node),
+ NULL));
+ } else {
+ node = MQ_TAB_TREE(mq_tree_insert_sibling_allocated(
+ MQ_TREE(g_new0(MqTabTree, 1)),
+ MQ_TREE(notebook->tree),
+ NULL));
+ }
insert_page(notebook, node, uri);
}
@@ -199,11 +206,19 @@ mq_notebook_insert_child(MqNotebook *notebook, const gchar *uri,
{
MqTabTree *node;
- find_node(notebook, child);
- node = MQ_TAB_TREE(mq_tree_insert_child_allocated(
- MQ_TREE(g_new0(MqTabTree, 1)),
- MQ_TREE(notebook->found_node),
- NULL));
+ if (child) {
+ find_node(notebook, child);
+ node = MQ_TAB_TREE(mq_tree_insert_child_allocated(
+ MQ_TREE(g_new0(MqTabTree, 1)),
+ MQ_TREE(notebook->found_node),
+ NULL));
+ } else {
+ find_node(notebook, child);
+ node = MQ_TAB_TREE(mq_tree_insert_child_allocated(
+ MQ_TREE(g_new0(MqTabTree, 1)),
+ MQ_TREE(notebook->tree),
+ NULL));
+ }
insert_page(notebook, node, uri);
}