diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-17 19:32:23 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-17 19:32:23 (EDT) |
commit | 1d1e550fb446da03d9f8389e41e159679170b0fe (patch) | |
tree | 17240602a1119338fca59e3dc61f05e80ee12618 /src | |
parent | 12d11cc30c07ff99341a0e26300767a59b34d434 (diff) | |
download | marquee-1d1e550fb446da03d9f8389e41e159679170b0fe.zip marquee-1d1e550fb446da03d9f8389e41e159679170b0fe.tar.gz marquee-1d1e550fb446da03d9f8389e41e159679170b0fe.tar.bz2 |
mq_tab_foreach(): New function
Diffstat (limited to 'src')
-rw-r--r-- | src/tab.c | 36 | ||||
-rw-r--r-- | src/tab.h | 5 |
2 files changed, 32 insertions, 9 deletions
@@ -21,6 +21,7 @@ #include "tab.h" +#include <stdarg.h> #include <stdlib.h> #include <gtk/gtk.h> @@ -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) { @@ -24,6 +24,8 @@ typedef struct MqTab MqTab; #ifndef MQ_TAB_H #define MQ_TAB_H +#include <stdarg.h> + #include <glib.h> #include <gtk/gtk.h> #include <webkit2/webkit2.h> @@ -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 |