mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-gtk: start on track discovery
This commit is contained in:
@ -20,6 +20,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "sysprof-session.h"
|
||||
#include "sysprof-track.h"
|
||||
#include "sysprof-value-axis.h"
|
||||
@ -72,19 +74,74 @@ sysprof_session_update_axis (SysprofSession *self)
|
||||
self->selected_time.end_nsec);
|
||||
}
|
||||
|
||||
static SysprofDocumentCounter *
|
||||
sysprof_session_find_counter (SysprofSession *self,
|
||||
const char *category,
|
||||
const char *name)
|
||||
{
|
||||
g_autoptr(GListModel) counters = NULL;
|
||||
guint n_items;
|
||||
|
||||
g_assert (SYSPROF_IS_SESSION (self));
|
||||
g_assert (category != NULL);
|
||||
g_assert (name != NULL);
|
||||
|
||||
if (self->document == NULL)
|
||||
return NULL;
|
||||
|
||||
counters = sysprof_document_list_counters (self->document);
|
||||
n_items = g_list_model_get_n_items (counters);
|
||||
|
||||
for (guint i = 0; i < n_items; i++)
|
||||
{
|
||||
g_autoptr(SysprofDocumentCounter) counter = g_list_model_get_item (counters, i);
|
||||
|
||||
if (g_strcmp0 (category, sysprof_document_counter_get_category (counter)) == 0 &&
|
||||
g_strcmp0 (name, sysprof_document_counter_get_name (counter)) == 0)
|
||||
return g_steal_pointer (&counter);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_session_discover_tracks (SysprofSession *self)
|
||||
{
|
||||
g_autoptr(SysprofDocumentCounter) cpu = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_SESSION (self));
|
||||
|
||||
if ((cpu = sysprof_session_find_counter (self, "CPU Percent", "Combined")))
|
||||
{
|
||||
g_autoptr(SysprofTrack) cpu_track = NULL;
|
||||
|
||||
cpu_track = g_object_new (SYSPROF_TYPE_TRACK,
|
||||
"title", _("CPU Usage"),
|
||||
NULL);
|
||||
g_list_store_append (self->tracks, cpu_track);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_session_set_document (SysprofSession *self,
|
||||
SysprofDocument *document)
|
||||
{
|
||||
const SysprofTimeSpan *time_span;
|
||||
|
||||
g_assert (SYSPROF_IS_SESSION (self));
|
||||
g_assert (SYSPROF_IS_DOCUMENT (document));
|
||||
g_assert (!document || SYSPROF_IS_DOCUMENT (document));
|
||||
|
||||
g_set_object (&self->document, document);
|
||||
|
||||
self->visible_time = *sysprof_document_get_time_span (document);
|
||||
self->selected_time = self->visible_time;
|
||||
if (!g_set_object (&self->document, document))
|
||||
return;
|
||||
|
||||
/* Select/show the entire document time span */
|
||||
time_span = sysprof_document_get_time_span (document);
|
||||
memcpy (&self->visible_time, time_span, sizeof *time_span);
|
||||
memcpy (&self->selected_time, time_span, sizeof *time_span);
|
||||
sysprof_session_update_axis (self);
|
||||
|
||||
/* Discover tracks to show from the document */
|
||||
sysprof_session_discover_tracks (self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user