diff --git a/src/sysprof/icons/scalable/actions/address-layout-symbolic.svg b/src/sysprof/icons/scalable/actions/address-layout-symbolic.svg new file mode 100644 index 00000000..f0011c1b --- /dev/null +++ b/src/sysprof/icons/scalable/actions/address-layout-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/sysprof/icons/scalable/actions/process-mounts-symbolic.svg b/src/sysprof/icons/scalable/actions/process-mounts-symbolic.svg new file mode 100644 index 00000000..1910fbab --- /dev/null +++ b/src/sysprof/icons/scalable/actions/process-mounts-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build index 854b46ff..8fc49316 100644 --- a/src/sysprof/meson.build +++ b/src/sysprof/meson.build @@ -7,6 +7,7 @@ sysprof_sources = [ 'sysprof-marks-section.c', 'sysprof-memory-section.c', 'sysprof-metadata-section.c', + 'sysprof-process-dialog.c', 'sysprof-processes-section.c', 'sysprof-recording-pad.c', 'sysprof-samples-section.c', diff --git a/src/sysprof/sysprof-process-dialog.c b/src/sysprof/sysprof-process-dialog.c new file mode 100644 index 00000000..9296dd91 --- /dev/null +++ b/src/sysprof/sysprof-process-dialog.c @@ -0,0 +1,142 @@ +/* sysprof-process-dialog.c + * + * Copyright 2023 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 + */ + +#include "config.h" + +#include "sysprof-process-dialog.h" + +struct _SysprofProcessDialog +{ + AdwWindow parent_instance; + SysprofDocumentProcess *process; +}; + +enum { + PROP_0, + PROP_PROCESS, + N_PROPS +}; + +G_DEFINE_FINAL_TYPE (SysprofProcessDialog, sysprof_process_dialog, ADW_TYPE_WINDOW) + +static GParamSpec *properties [N_PROPS]; + +static char * +format_address (gpointer unused, + SysprofAddress addr) +{ + return g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", addr); +} + +static void +sysprof_process_dialog_dispose (GObject *object) +{ + SysprofProcessDialog *self = (SysprofProcessDialog *)object; + + gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_PROCESS_DIALOG); + + g_clear_object (&self->process); + + G_OBJECT_CLASS (sysprof_process_dialog_parent_class)->dispose (object); +} + +static void +sysprof_process_dialog_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + SysprofProcessDialog *self = SYSPROF_PROCESS_DIALOG (object); + + switch (prop_id) + { + case PROP_PROCESS: + g_value_set_object (value, sysprof_process_dialog_get_process (self)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +sysprof_process_dialog_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + SysprofProcessDialog *self = SYSPROF_PROCESS_DIALOG (object); + + switch (prop_id) + { + case PROP_PROCESS: + sysprof_process_dialog_set_process (self, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +sysprof_process_dialog_class_init (SysprofProcessDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = sysprof_process_dialog_dispose; + object_class->get_property = sysprof_process_dialog_get_property; + object_class->set_property = sysprof_process_dialog_set_property; + + properties [PROP_PROCESS] = + g_param_spec_object ("process", NULL, NULL, + SYSPROF_TYPE_DOCUMENT_PROCESS, + (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-process-dialog.ui"); + gtk_widget_class_bind_template_callback (widget_class, format_address); +} + +static void +sysprof_process_dialog_init (SysprofProcessDialog *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +SysprofDocumentProcess * +sysprof_process_dialog_get_process (SysprofProcessDialog *self) +{ + g_return_val_if_fail (SYSPROF_IS_PROCESS_DIALOG (self), NULL); + + return self->process; +} + +void +sysprof_process_dialog_set_process (SysprofProcessDialog *self, + SysprofDocumentProcess *process) +{ + g_return_if_fail (SYSPROF_IS_PROCESS_DIALOG (self)); + g_return_if_fail (!process || SYSPROF_IS_DOCUMENT_PROCESS (process)); + + if (g_set_object (&self->process, process)) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PROCESS]); +} diff --git a/src/sysprof/sysprof-process-dialog.h b/src/sysprof/sysprof-process-dialog.h new file mode 100644 index 00000000..fa1dc0cf --- /dev/null +++ b/src/sysprof/sysprof-process-dialog.h @@ -0,0 +1,37 @@ +/* sysprof-process-dialog.h + * + * Copyright 2023 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_PROCESS_DIALOG (sysprof_process_dialog_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofProcessDialog, sysprof_process_dialog, SYSPROF, PROCESS_DIALOG, AdwWindow) + +SysprofDocumentProcess *sysprof_process_dialog_get_process (SysprofProcessDialog *self); +void sysprof_process_dialog_set_process (SysprofProcessDialog *self, + SysprofDocumentProcess *process); + +G_END_DECLS diff --git a/src/sysprof/sysprof-process-dialog.ui b/src/sysprof/sysprof-process-dialog.ui new file mode 100644 index 00000000..5b660a71 --- /dev/null +++ b/src/sysprof/sysprof-process-dialog.ui @@ -0,0 +1,572 @@ + + + + diff --git a/src/sysprof/sysprof-processes-section.c b/src/sysprof/sysprof-processes-section.c index 8a57b309..75dbf557 100644 --- a/src/sysprof/sysprof-processes-section.c +++ b/src/sysprof/sysprof-processes-section.c @@ -25,6 +25,7 @@ #include #include +#include "sysprof-process-dialog.h" #include "sysprof-processes-section.h" #include "sysprof-single-model.h" @@ -37,6 +38,31 @@ struct _SysprofProcessesSection G_DEFINE_FINAL_TYPE (SysprofProcessesSection, sysprof_processes_section, SYSPROF_TYPE_SECTION) +static void +activate_layer_item_cb (GtkListItem *list_item, + SysprofChartLayer *layer, + SysprofDocumentProcess *process, + SysprofChart *chart) +{ + SysprofProcessDialog *dialog; + g_autofree char *title = NULL; + + g_assert (GTK_IS_LIST_ITEM (list_item)); + g_assert (SYSPROF_IS_CHART_LAYER (layer)); + g_assert (SYSPROF_IS_DOCUMENT_PROCESS (process)); + g_assert (SYSPROF_IS_CHART (chart)); + + title = sysprof_document_process_dup_title (process); + + dialog = g_object_new (SYSPROF_TYPE_PROCESS_DIALOG, + "process", process, + "transient-for", gtk_widget_get_root (GTK_WIDGET (chart)), + "title", title, + NULL); + + gtk_window_present (GTK_WINDOW (dialog)); +} + static void sysprof_processes_section_dispose (GObject *object) { @@ -57,6 +83,7 @@ sysprof_processes_section_class_init (SysprofProcessesSectionClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-processes-section.ui"); gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, list_view); + gtk_widget_class_bind_template_callback (widget_class, activate_layer_item_cb); g_type_ensure (SYSPROF_TYPE_CHART); g_type_ensure (SYSPROF_TYPE_CHART_LAYER); diff --git a/src/sysprof/sysprof-processes-section.ui b/src/sysprof/sysprof-processes-section.ui index 3a9bdeb6..420c72bf 100644 --- a/src/sysprof/sysprof-processes-section.ui +++ b/src/sysprof/sysprof-processes-section.ui @@ -42,6 +42,7 @@ 16 + true diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index e6427a56..659d79bc 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -9,15 +9,18 @@ sysprof-marks-section.ui sysprof-memory-section.ui sysprof-metadata-section.ui + sysprof-process-dialog.ui sysprof-processes-section.ui sysprof-recording-pad.ui sysprof-samples-section.ui sysprof-sidebar.ui sysprof-window.ui + icons/scalable/actions/address-layout-symbolic.svg icons/scalable/actions/mark-chart-symbolic.svg icons/scalable/actions/mark-table-symbolic.svg icons/scalable/actions/memory-allocations-symbolic.svg icons/scalable/actions/metadata-symbolic.svg + icons/scalable/actions/process-mounts-symbolic.svg icons/scalable/actions/system-log-symbolic.svg