summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-10-01 19:05:47 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-10-01 19:05:47 (EDT)
commitc5c9684a7cff6cc41520aea66b3ff7b5f79ed2ca (patch)
treeaa90d86672036ebd353b71bc5a41b573d125e55f
parent6039beb6de58ca6fc25a9c2e2e109b700c5c00a0 (diff)
downloadmarquee-c5c9684a7cff6cc41520aea66b3ff7b5f79ed2ca.zip
marquee-c5c9684a7cff6cc41520aea66b3ff7b5f79ed2ca.tar.gz
marquee-c5c9684a7cff6cc41520aea66b3ff7b5f79ed2ca.tar.bz2
mq_notebook_foreach_page(): New function
-rw-r--r--src/notebook.c25
-rw-r--r--src/notebook.h5
2 files changed, 30 insertions, 0 deletions
diff --git a/src/notebook.c b/src/notebook.c
index 7b846f4..9970a57 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -46,6 +46,8 @@ struct _MqNotebook {
MqTabTree *found_node;
MqTabPage *current_page;
GtkWidget *tab_tree_popover;
+ gboolean (*foreach_cb)(MqTabPage *page, gpointer user_data);
+ gpointer foreach_data;
};
enum {
@@ -481,3 +483,26 @@ mq_notebook_update_tab_title(MqNotebook *notebook, MqTabPage *tab_page,
mq_window_set_title(notebook->window, title);
}
}
+
+static gboolean
+foreach_page(MqTree *node, gpointer user_data)
+{
+ MqNotebook *notebook;
+
+ notebook = MQ_NOTEBOOK(user_data);
+
+ return notebook->foreach_cb(MQ_TAB_TREE(node)->page,
+ notebook->foreach_data);
+}
+
+void
+mq_notebook_foreach_page(MqNotebook *notebook,
+ gboolean (*cb)(MqTabPage *page, gpointer user_data),
+ gpointer user_data)
+{
+ notebook->foreach_cb = cb;
+ notebook->foreach_data = user_data;
+ mq_tree_foreach(MQ_TREE(notebook->tree), foreach_page, notebook);
+ notebook->foreach_cb = NULL;
+ notebook->foreach_data = NULL;
+}
diff --git a/src/notebook.h b/src/notebook.h
index 6538eb8..746a67a 100644
--- a/src/notebook.h
+++ b/src/notebook.h
@@ -78,6 +78,11 @@ void
mq_notebook_update_tab_title(MqNotebook *notebook, MqTabPage *tab_page,
const gchar *title);
+void
+mq_notebook_foreach_page(MqNotebook *notebook,
+ gboolean (*cb)(MqTabPage *page, gpointer user_data),
+ gpointer user_data);
+
G_END_DECLS
#endif /* MQ_NOTEBOOK_H */