sysprof: add logs section to sidebar

This commit is contained in:
Christian Hergert
2023-07-09 15:01:18 -07:00
parent 22b2510179
commit afc88890ce
7 changed files with 320 additions and 2 deletions

View File

@ -3,11 +3,12 @@ sysprof_sources = [
'sysprof-application.c',
'sysprof-files-dialog.c',
'sysprof-greeter.c',
'sysprof-recording-pad.c',
'sysprof-logs-section.c',
'sysprof-metadata-dialog.c',
'sysprof-recording-pad.c',
'sysprof-samples-section.c',
'sysprof-sidebar.c',
'sysprof-section.c',
'sysprof-sidebar.c',
'sysprof-window.c',
]

View File

@ -0,0 +1,93 @@
/* sysprof-logs-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 <sysprof-gtk.h>
#include "sysprof-logs-section.h"
struct _SysprofLogsSection
{
SysprofSection parent_instance;
GtkColumnView *column_view;
};
G_DEFINE_FINAL_TYPE (SysprofLogsSection, sysprof_logs_section, SYSPROF_TYPE_SECTION)
static char *
format_severity (gpointer unused,
GLogLevelFlags severity)
{
if (severity & G_LOG_LEVEL_CRITICAL)
return g_strdup (_("Critical"));
if (severity & G_LOG_LEVEL_WARNING)
return g_strdup (_("Warning"));
if (severity & G_LOG_LEVEL_DEBUG)
return g_strdup (_("Debug"));
if (severity & G_LOG_LEVEL_MESSAGE)
return g_strdup (_("Message"));
if (severity & G_LOG_LEVEL_INFO)
return g_strdup (_("Info"));
if (severity & G_LOG_LEVEL_ERROR)
return g_strdup (_("Error"));
return g_strdup ("");
}
static void
sysprof_logs_section_dispose (GObject *object)
{
SysprofLogsSection *self = (SysprofLogsSection *)object;
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_LOGS_SECTION);
G_OBJECT_CLASS (sysprof_logs_section_parent_class)->dispose (object);
}
static void
sysprof_logs_section_class_init (SysprofLogsSectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = sysprof_logs_section_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-logs-section.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofLogsSection, column_view);
gtk_widget_class_bind_template_callback (widget_class, format_severity);
g_type_ensure (SYSPROF_TYPE_DOCUMENT_LOG);
g_type_ensure (SYSPROF_TYPE_TIME_LABEL);
}
static void
sysprof_logs_section_init (SysprofLogsSection *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}

View File

@ -0,0 +1,32 @@
/* sysprof-logs-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_LOGS_SECTION (sysprof_logs_section_get_type())
G_DECLARE_FINAL_TYPE (SysprofLogsSection, sysprof_logs_section, SYSPROF, LOGS_SECTION, SysprofSection)
G_END_DECLS

View File

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofLogsSection" parent="SysprofSection">
<property name="title" translatable="yes">Logs</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-row-separators">true</property>
<style>
<class name="data-table"/>
</style>
<property name="model">
<object class="GtkMultiSelection">
<property name="model">
<object class="GtkSortListModel">
<binding name="sorter">
<lookup name="sorter">column_view</lookup>
</binding>
<binding name="model">
<lookup name="logs" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofLogsSection</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="SysprofDocumentLog"/>
</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="SysprofDocumentLog">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="severity_column">
<property name="title" translatable="yes">Severity</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="expression">
<lookup name="severity" type="SysprofDocumentLog"/>
</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">
<closure type="gchararray" function="format_severity">
<lookup name="severity" type="SysprofDocumentLog">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="domain_column">
<property name="title" translatable="yes">Domain</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="domain" type="SysprofDocumentLog"/>
</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>
<property name="max-width-chars">32</property>
<binding name="label">
<lookup name="domain" type="SysprofDocumentLog">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="message_column">
<property name="title" translatable="yes">Message</property>
<property name="expand">true</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="message" type="SysprofDocumentLog"/>
</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="message" type="SysprofDocumentLog">
<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

@ -26,6 +26,7 @@
#include "sysprof-files-dialog.h"
#include "sysprof-greeter.h"
#include "sysprof-logs-section.h"
#include "sysprof-metadata-dialog.h"
#include "sysprof-samples-section.h"
#include "sysprof-sidebar.h"
@ -198,6 +199,7 @@ sysprof_window_class_init (SysprofWindowClass *klass)
gtk_widget_class_install_action (widget_class, "capture.show-metadata", NULL, sysprof_window_show_metadata_action);
g_type_ensure (SYSPROF_TYPE_DOCUMENT);
g_type_ensure (SYSPROF_TYPE_LOGS_SECTION);
g_type_ensure (SYSPROF_TYPE_SAMPLES_SECTION);
g_type_ensure (SYSPROF_TYPE_SESSION);
g_type_ensure (SYSPROF_TYPE_SIDEBAR);

View File

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

View File

@ -5,6 +5,7 @@
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file preprocess="xml-stripblanks">sysprof-files-dialog.ui</file>
<file preprocess="xml-stripblanks">sysprof-greeter.ui</file>
<file preprocess="xml-stripblanks">sysprof-logs-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-metadata-dialog.ui</file>
<file preprocess="xml-stripblanks">sysprof-recording-pad.ui</file>
<file preprocess="xml-stripblanks">sysprof-samples-section.ui</file>