From c18b401ab6ef3b940e48ec216d7d253165c69ae3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 8 May 2023 12:24:26 -0700 Subject: [PATCH] libsysprof-analyze: add listmodel of traceables It can be handy to iterate through the traceables and we already have a bitset index for that. Use the new bitset index listmodel to provide that filtered list externally without having to inflate every object in the underlying listmodel, as GtkFilterListModel would have to do. --- src/libsysprof-analyze/sysprof-document.c | 19 +++++++++++++++++++ src/libsysprof-analyze/sysprof-document.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-document.c b/src/libsysprof-analyze/sysprof-document.c index 4deeaba4..718be6b8 100644 --- a/src/libsysprof-analyze/sysprof-document.c +++ b/src/libsysprof-analyze/sysprof-document.c @@ -25,6 +25,8 @@ #include #include "sysprof-document-private.h" + +#include "sysprof-document-bitset-index-private.h" #include "sysprof-document-file-chunk.h" #include "sysprof-document-frame-private.h" #include "sysprof-document-symbols-private.h" @@ -495,3 +497,20 @@ _sysprof_document_traceables (SysprofDocument *self) return self->traceables; } + +/** + * sysprof_document_list_traceables: + * @self: a #SysprofDocument + * + * Gets a #GListModel containing #SysprofDocumentTraceable found within + * the #SysprofDocument. + * + * Returns: (transfer full): a #GListModel + */ +GListModel * +sysprof_document_list_traceables (SysprofDocument *self) +{ + g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL); + + return _sysprof_document_bitset_index_new (G_LIST_MODEL (self), self->traceables); +} diff --git a/src/libsysprof-analyze/sysprof-document.h b/src/libsysprof-analyze/sysprof-document.h index fb62bdbb..c9afd003 100644 --- a/src/libsysprof-analyze/sysprof-document.h +++ b/src/libsysprof-analyze/sysprof-document.h @@ -60,5 +60,7 @@ SYSPROF_AVAILABLE_IN_ALL GBytes *sysprof_document_lookup_file_finish (SysprofDocument *self, GAsyncResult *result, GError **error); +SYSPROF_AVAILABLE_IN_ALL +GListModel *sysprof_document_list_traceables (SysprofDocument *self); G_END_DECLS