From 1d1e550fb446da03d9f8389e41e159679170b0fe Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 17 Oct 2017 19:32:23 -0400 Subject: mq_tab_foreach(): New function --- (limited to 'src') diff --git a/src/tab.c b/src/tab.c index 74c9085..364e3a5 100644 --- a/src/tab.c +++ b/src/tab.c @@ -21,6 +21,7 @@ #include "tab.h" +#include #include #include @@ -31,15 +32,6 @@ #include "web-view.h" static void -foreach_tab(MqTab *node, void (*cb)(MqTab *node)) -{ - for (; node; node = node->next) { - cb(node); - foreach_tab(node->first_child, cb); - } -} - -static void update_positions(MqTab *node, gint step) { if (node) { @@ -274,6 +266,32 @@ mq_tab_seek(MqTab *node, guint position) return mq_tab_seek(node->first_child, position); } +static void +foreach_tab(MqTab *node, void (*cb)(MqTab *node, va_list ap), va_list ap) +{ + va_list aq; + + for (; node; node = node->next) { + va_copy(ap, aq); + cb(node, aq); + va_end(aq); + + va_copy(ap, aq); + foreach_tab(node->first_child, cb, aq); + va_end(aq); + } +} + +void +mq_tab_foreach(MqTab *node, void (*cb)(MqTab *node, va_list ap), ...) +{ + va_list ap; + + va_start(ap, cb); + foreach_tab(node->root->first_child, cb, ap); + va_end(ap); +} + void mq_tab_scroll_tab_labels(MqTab *node) { diff --git a/src/tab.h b/src/tab.h index 83eed19..53ce9ce 100644 --- a/src/tab.h +++ b/src/tab.h @@ -24,6 +24,8 @@ typedef struct MqTab MqTab; #ifndef MQ_TAB_H #define MQ_TAB_H +#include + #include #include #include @@ -82,6 +84,9 @@ MqTab * mq_tab_seek(MqTab *node, guint position); void +mq_tab_foreach(MqTab *node, void (*cb)(MqTab *node, va_list ap), ...); + +void mq_tab_scroll_tab_labels(MqTab *node); void -- cgit v0.9.1