sysprof: use a section for metadata

This is more discoverable than in the menu, and since it conveys user
information we should elevate that so they know what is in there before
sharing it with other people.
This commit is contained in:
Christian Hergert
2023-07-10 09:34:21 -07:00
parent bb0b7d672e
commit d0da970e86
7 changed files with 256 additions and 0 deletions

View File

@ -6,6 +6,7 @@ sysprof_sources = [
'sysprof-logs-section.c',
'sysprof-marks-section.c',
'sysprof-metadata-dialog.c',
'sysprof-metadata-section.c',
'sysprof-recording-pad.c',
'sysprof-samples-section.c',
'sysprof-section.c',

View File

@ -0,0 +1,68 @@
/* sysprof-metadata-section.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include <glib/gi18n.h>
#include <adwaita.h>
#include <sysprof-gtk.h>
#include "sysprof-metadata-section.h"
struct _SysprofMetadataSection
{
SysprofSection parent_instance;
GtkColumnView *column_view;
};
G_DEFINE_FINAL_TYPE (SysprofMetadataSection, sysprof_metadata_section, SYSPROF_TYPE_SECTION)
static void
sysprof_metadata_section_dispose (GObject *object)
{
SysprofMetadataSection *self = (SysprofMetadataSection *)object;
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_METADATA_SECTION);
G_OBJECT_CLASS (sysprof_metadata_section_parent_class)->dispose (object);
}
static void
sysprof_metadata_section_class_init (SysprofMetadataSectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = sysprof_metadata_section_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-metadata-section.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofMetadataSection, column_view);
g_type_ensure (SYSPROF_TYPE_DOCUMENT_METADATA);
g_type_ensure (SYSPROF_TYPE_TIME_LABEL);
}
static void
sysprof_metadata_section_init (SysprofMetadataSection *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}

View File

@ -0,0 +1,31 @@
/* sysprof-metadata-section.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include "sysprof-section.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_METADATA_SECTION (sysprof_metadata_section_get_type())
G_DECLARE_FINAL_TYPE (SysprofMetadataSection, sysprof_metadata_section, SYSPROF, METADATA_SECTION, SysprofSection)
G_END_DECLS

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofMetadataSection" parent="SysprofSection">
<property name="title" translatable="yes">Metadata</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="vexpand">true</property>
<child>
<object class="GtkColumnView" id="column_view">
<property name="show-column-separators">true</property>
<property name="show-row-separators">true</property>
<style>
<class name="data-table"/>
</style>
<property name="model">
<object class="GtkSingleSelection">
<property name="model">
<object class="GtkSortListModel">
<binding name="sorter">
<lookup name="sorter">column_view</lookup>
</binding>
<binding name="model">
<lookup name="metadata" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofMetadataSection</lookup>
</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</property>
<child>
<object class="GtkColumnViewColumn" id="time_column">
<property name="title" translatable="yes">Time</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="expression">
<lookup name="time" type="SysprofDocumentFrame"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="SysprofTimeLabel">
<binding name="time-offset">
<lookup name="time-offset" type="SysprofDocumentFrame">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="key_column">
<property name="title" translatable="yes">Key</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="id" type="SysprofDocumentMetadata"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="id" type="SysprofDocumentMetadata">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="value_column">
<property name="title" translatable="yes">Value</property>
<property name="expand">true</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="value" type="SysprofDocumentMetadata"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="value" type="SysprofDocumentMetadata">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -29,6 +29,7 @@
#include "sysprof-logs-section.h"
#include "sysprof-marks-section.h"
#include "sysprof-metadata-dialog.h"
#include "sysprof-metadata-section.h"
#include "sysprof-samples-section.h"
#include "sysprof-sidebar.h"
#include "sysprof-window.h"
@ -186,6 +187,7 @@ sysprof_window_class_init (SysprofWindowClass *klass)
g_type_ensure (SYSPROF_TYPE_FILES_SECTION);
g_type_ensure (SYSPROF_TYPE_LOGS_SECTION);
g_type_ensure (SYSPROF_TYPE_MARKS_SECTION);
g_type_ensure (SYSPROF_TYPE_METADATA_SECTION);
g_type_ensure (SYSPROF_TYPE_SAMPLES_SECTION);
g_type_ensure (SYSPROF_TYPE_SESSION);
g_type_ensure (SYSPROF_TYPE_SIDEBAR);

View File

@ -116,6 +116,13 @@
</binding>
</object>
</child>
<child>
<object class="SysprofMetadataSection">
<binding name="session">
<lookup name="session">SysprofWindow</lookup>
</binding>
</object>
</child>
</object>
</property>
</object>

View File

@ -8,6 +8,7 @@
<file preprocess="xml-stripblanks">sysprof-logs-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-marks-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-metadata-dialog.ui</file>
<file preprocess="xml-stripblanks">sysprof-metadata-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-recording-pad.ui</file>
<file preprocess="xml-stripblanks">sysprof-samples-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-sidebar.ui</file>