From de06c0da45b7c7bebc0946d69b0e90d5d2ddc2da Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 15 May 2019 15:58:13 -0700 Subject: [PATCH] libsysprof-ui: start on details view --- src/libsysprof-ui/libsysprof-ui.gresource.xml | 1 + src/libsysprof-ui/meson.build | 1 + src/libsysprof-ui/sysprof-capture-view.c | 7 ++ src/libsysprof-ui/sysprof-details-view.c | 91 ++++++++++++++ src/libsysprof-ui/sysprof-details-view.h | 36 ++++++ src/libsysprof-ui/ui/sysprof-capture-view.ui | 9 ++ src/libsysprof-ui/ui/sysprof-details-view.ui | 113 ++++++++++++++++++ 7 files changed, 258 insertions(+) create mode 100644 src/libsysprof-ui/sysprof-details-view.c create mode 100644 src/libsysprof-ui/sysprof-details-view.h create mode 100644 src/libsysprof-ui/ui/sysprof-details-view.ui diff --git a/src/libsysprof-ui/libsysprof-ui.gresource.xml b/src/libsysprof-ui/libsysprof-ui.gresource.xml index 19220700..46ac5f86 100644 --- a/src/libsysprof-ui/libsysprof-ui.gresource.xml +++ b/src/libsysprof-ui/libsysprof-ui.gresource.xml @@ -11,6 +11,7 @@ ui/sysprof-callgraph-view.ui ui/sysprof-capture-view.ui + ui/sysprof-details-view.ui ui/sysprof-empty-state-view.ui ui/sysprof-failed-state-view.ui ui/sysprof-marks-view.ui diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build index 9fea8763..e7c46453 100644 --- a/src/libsysprof-ui/meson.build +++ b/src/libsysprof-ui/meson.build @@ -24,6 +24,7 @@ libsysprof_ui_public_sources = [ libsysprof_ui_private_sources = [ 'pointcache.c', 'rectangles.c', + 'sysprof-details-view.c', 'sysprof-cell-renderer-duration.c', 'sysprof-cell-renderer-percent.c', 'sysprof-theme-manager.c', diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c index 5f9d25a5..dbd2863d 100644 --- a/src/libsysprof-ui/sysprof-capture-view.c +++ b/src/libsysprof-ui/sysprof-capture-view.c @@ -24,6 +24,7 @@ #include "sysprof-callgraph-view.h" #include "sysprof-capture-view.h" +#include "sysprof-details-view.h" #include "sysprof-marks-view.h" #include "sysprof-visualizer-view.h" @@ -45,6 +46,7 @@ typedef struct /* Template Objects */ SysprofCallgraphView *callgraph_view; + SysprofDetailsView *details_view; SysprofMarksView *marks_view; SysprofVisualizerView *visualizer_view; SysprofZoomManager *zoom_manager; @@ -485,6 +487,8 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self, cancellable, sysprof_capture_view_load_scan_cb, g_steal_pointer (&task)); + + sysprof_details_view_set_reader (priv->details_view, reader); } static gboolean @@ -585,6 +589,7 @@ sysprof_capture_view_class_init (SysprofCaptureViewClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-capture-view.ui"); gtk_widget_class_bind_template_child_private (widget_class, SysprofCaptureView, callgraph_view); + gtk_widget_class_bind_template_child_private (widget_class, SysprofCaptureView, details_view); gtk_widget_class_bind_template_child_private (widget_class, SysprofCaptureView, marks_view); gtk_widget_class_bind_template_child_private (widget_class, SysprofCaptureView, visualizer_view); gtk_widget_class_bind_template_child_private (widget_class, SysprofCaptureView, zoom_manager); @@ -597,6 +602,8 @@ sysprof_capture_view_class_init (SysprofCaptureViewClass *klass) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_properties (object_class, N_PROPS, properties); + + g_type_ensure (SYSPROF_TYPE_DETAILS_VIEW); } static void diff --git a/src/libsysprof-ui/sysprof-details-view.c b/src/libsysprof-ui/sysprof-details-view.c new file mode 100644 index 00000000..d216563b --- /dev/null +++ b/src/libsysprof-ui/sysprof-details-view.c @@ -0,0 +1,91 @@ +/* sysprof-details-view.c + * + * Copyright 2019 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "sysprof-details-view" + +#include "config.h" + +#include + +#include "sysprof-details-view.h" + +struct _SysprofDetailsView +{ + GtkBin parent_instance; + GtkLabel *filename; + GtkLabel *start_time; +}; + +G_DEFINE_TYPE (SysprofDetailsView, sysprof_details_view, GTK_TYPE_BIN) + +static void +sysprof_details_view_finalize (GObject *object) +{ + G_OBJECT_CLASS (sysprof_details_view_parent_class)->finalize (object); +} + +static void +sysprof_details_view_class_init (SysprofDetailsViewClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->finalize = sysprof_details_view_finalize; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-details-view.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, filename); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, start_time); +} + +static void +sysprof_details_view_init (SysprofDetailsView *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +GtkWidget * +sysprof_details_view_new (void) +{ + return g_object_new (SYSPROF_TYPE_DETAILS_VIEW, NULL); +} + +void +sysprof_details_view_set_reader (SysprofDetailsView *self, + SysprofCaptureReader *reader) +{ + g_autoptr(GDateTime) dt = NULL; + g_autoptr(GDateTime) local = NULL; + const gchar *filename; + const gchar *capture_at; + + g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); + + if (!(filename = sysprof_capture_reader_get_filename (reader))) + filename = _("Memory Capture"); + gtk_label_set_label (self->filename, filename); + + if ((capture_at = sysprof_capture_reader_get_time (reader)) && + (dt = g_date_time_new_from_iso8601 (capture_at, NULL)) && + (local = g_date_time_to_local (dt))) + { + g_autofree gchar *str = g_date_time_format (local, "%x %X"); + gtk_label_set_label (self->start_time, str); + } +} diff --git a/src/libsysprof-ui/sysprof-details-view.h b/src/libsysprof-ui/sysprof-details-view.h new file mode 100644 index 00000000..d11d7f6d --- /dev/null +++ b/src/libsysprof-ui/sysprof-details-view.h @@ -0,0 +1,36 @@ +/* sysprof-details-view.h + * + * Copyright 2019 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include +#include + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_DETAILS_VIEW (sysprof_details_view_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofDetailsView, sysprof_details_view, SYSPROF, DETAILS_VIEW, GtkBin) + +GtkWidget *sysprof_details_view_new (void); +void sysprof_details_view_set_reader (SysprofDetailsView *self, + SysprofCaptureReader *reader); + +G_END_DECLS diff --git a/src/libsysprof-ui/ui/sysprof-capture-view.ui b/src/libsysprof-ui/ui/sysprof-capture-view.ui index 8c1cc087..dacb4943 100644 --- a/src/libsysprof-ui/ui/sysprof-capture-view.ui +++ b/src/libsysprof-ui/ui/sysprof-capture-view.ui @@ -126,6 +126,15 @@ Timings + + + 36 + true + + + Details + + diff --git a/src/libsysprof-ui/ui/sysprof-details-view.ui b/src/libsysprof-ui/ui/sysprof-details-view.ui new file mode 100644 index 00000000..a828c286 --- /dev/null +++ b/src/libsysprof-ui/ui/sysprof-details-view.ui @@ -0,0 +1,113 @@ + + + + + +