[gnome-builder/wip/gtk4-port: 1056/1774] libide/gui: wrap workspace helper for page callbacks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1056/1774] libide/gui: wrap workspace helper for page callbacks
- Date: Mon, 11 Jul 2022 22:31:32 +0000 (UTC)
commit a0242496f56ad1bb8fbcf87d9be9088471a67170
Author: Christian Hergert <chergert redhat com>
Date: Tue May 17 16:24:48 2022 -0700
libide/gui: wrap workspace helper for page callbacks
It already copies currently, so we can just use a state struct instead of
the duplicated list copies. Also, we can probably drop those too soon.
src/libide/gui/ide-workbench.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index 51c1fe26a..d8d733139 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -660,6 +660,26 @@ ide_workbench_foreach_workspace (IdeWorkbench *self,
g_list_free (copy);
}
+typedef struct
+{
+ IdePageCallback callback;
+ gpointer user_data;
+} ForeachPage;
+
+static void
+ide_workbench_foreach_page_cb (IdeWorkspace *workspace,
+ gpointer user_data)
+{
+ ForeachPage *state = user_data;
+
+ g_assert (IDE_IS_WORKSPACE (workspace));
+ g_assert (state != NULL);
+ g_assert (state->callback != NULL);
+
+ ide_workspace_foreach_page (workspace, state->callback, state->user_data);
+}
+
+
/**
* ide_workbench_foreach_page:
* @self: a #IdeWorkbench
@@ -674,20 +694,12 @@ ide_workbench_foreach_page (IdeWorkbench *self,
IdePageCallback callback,
gpointer user_data)
{
- GList *copy;
+ ForeachPage state = {callback, user_data};
g_return_if_fail (IDE_IS_WORKBENCH (self));
g_return_if_fail (callback != NULL);
- /* Make a copy to be safe against auto-cleanup removals */
- copy = g_list_copy (self->mru_queue.head);
- for (const GList *iter = copy; iter; iter = iter->next)
- {
- IdeWorkspace *workspace = iter->data;
- g_assert (IDE_IS_WORKSPACE (workspace));
- ide_workspace_foreach_page (workspace, callback, user_data);
- }
- g_list_free (copy);
+ ide_workbench_foreach_workspace (self, ide_workbench_foreach_page_cb, &state);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]