mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
sysprof: start on utility pane
This commit is contained in:
@ -14,6 +14,7 @@ sysprof_sources = [
|
||||
'sysprof-section.c',
|
||||
'sysprof-sidebar.c',
|
||||
'sysprof-single-model.c',
|
||||
'sysprof-traceables-utility.c',
|
||||
'sysprof-window.c',
|
||||
]
|
||||
|
||||
|
||||
137
src/sysprof/sysprof-traceables-utility.c
Normal file
137
src/sysprof/sysprof-traceables-utility.c
Normal file
@ -0,0 +1,137 @@
|
||||
/* sysprof-traceables-utility.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 <sysprof-gtk.h>
|
||||
|
||||
#include "sysprof-traceables-utility.h"
|
||||
|
||||
struct _SysprofTraceablesUtility
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
SysprofSession *session;
|
||||
GListModel *traceables;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION,
|
||||
PROP_TRACEABLES,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofTraceablesUtility, sysprof_traceables_utility, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties[N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_traceables_utility_finalize (GObject *object)
|
||||
{
|
||||
SysprofTraceablesUtility *self = (SysprofTraceablesUtility *)object;
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_TRACEABLES_UTILITY);
|
||||
|
||||
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
g_clear_object (&self->session);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_traceables_utility_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_traceables_utility_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTraceablesUtility *self = SYSPROF_TRACEABLES_UTILITY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (value, self->session);
|
||||
break;
|
||||
|
||||
case PROP_TRACEABLES:
|
||||
g_value_set_object (value, self->traceables);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_traceables_utility_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTraceablesUtility *self = SYSPROF_TRACEABLES_UTILITY (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION:
|
||||
g_set_object (&self->session, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_TRACEABLES:
|
||||
g_set_object (&self->traceables, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_traceables_utility_class_init (SysprofTraceablesUtilityClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_traceables_utility_finalize;
|
||||
object_class->get_property = sysprof_traceables_utility_get_property;
|
||||
object_class->set_property = sysprof_traceables_utility_set_property;
|
||||
|
||||
properties[PROP_SESSION] =
|
||||
g_param_spec_object ("session", NULL, NULL,
|
||||
SYSPROF_TYPE_SESSION,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties[PROP_TRACEABLES] =
|
||||
g_param_spec_object ("traceables", NULL, NULL,
|
||||
G_TYPE_LIST_MODEL,
|
||||
(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-traceables-utility.ui");
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_traceables_utility_init (SysprofTraceablesUtility *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
31
src/sysprof/sysprof-traceables-utility.h
Normal file
31
src/sysprof/sysprof-traceables-utility.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* sysprof-traceables-utility.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 <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TRACEABLES_UTILITY (sysprof_traceables_utility_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (SysprofTraceablesUtility, sysprof_traceables_utility, SYSPROF, TRACEABLES_UTILITY, GtkWidget)
|
||||
|
||||
G_END_DECLS
|
||||
10
src/sysprof/sysprof-traceables-utility.ui
Normal file
10
src/sysprof/sysprof-traceables-utility.ui
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="SysprofTraceablesUtility" parent="GtkWidget">
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="orientation">vertical</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@ -33,6 +33,7 @@
|
||||
#include "sysprof-processes-section.h"
|
||||
#include "sysprof-samples-section.h"
|
||||
#include "sysprof-sidebar.h"
|
||||
#include "sysprof-traceables-utility.h"
|
||||
#include "sysprof-window.h"
|
||||
|
||||
struct _SysprofWindow
|
||||
@ -41,6 +42,9 @@ struct _SysprofWindow
|
||||
|
||||
SysprofDocument *document;
|
||||
SysprofSession *session;
|
||||
|
||||
AdwViewStack *utility_stack;
|
||||
AdwWindowTitle *utility_title;
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -193,6 +197,9 @@ sysprof_window_class_init (SysprofWindowClass *klass)
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-window.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, utility_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, utility_title);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "win.open-capture", NULL, sysprof_window_open_capture_action);
|
||||
gtk_widget_class_install_action (widget_class, "win.record-capture", NULL, sysprof_window_record_capture_action);
|
||||
|
||||
@ -206,12 +213,39 @@ sysprof_window_class_init (SysprofWindowClass *klass)
|
||||
g_type_ensure (SYSPROF_TYPE_SAMPLES_SECTION);
|
||||
g_type_ensure (SYSPROF_TYPE_SESSION);
|
||||
g_type_ensure (SYSPROF_TYPE_SIDEBAR);
|
||||
g_type_ensure (SYSPROF_TYPE_TRACEABLES_UTILITY);
|
||||
}
|
||||
|
||||
static void
|
||||
utility_stack_notify_visible_child_cb (SysprofWindow *self,
|
||||
GParamSpec *pspec,
|
||||
AdwViewStack *utility_stack)
|
||||
{
|
||||
AdwViewStackPage *page;
|
||||
const char *title = NULL;
|
||||
GtkWidget *child;
|
||||
|
||||
g_assert (SYSPROF_IS_WINDOW (self));
|
||||
g_assert (ADW_IS_VIEW_STACK (utility_stack));
|
||||
|
||||
if ((child = adw_view_stack_get_visible_child (utility_stack)) &&
|
||||
(page = adw_view_stack_get_page (utility_stack, child)))
|
||||
title = adw_view_stack_page_get_title (page);
|
||||
|
||||
adw_window_title_set_title (self->utility_title, title);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_window_init (SysprofWindow *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
g_signal_connect_object (self->utility_stack,
|
||||
"notify::visible-child",
|
||||
G_CALLBACK (utility_stack_notify_visible_child_cb),
|
||||
self,
|
||||
G_CONNECT_SWAPPED);
|
||||
utility_stack_notify_visible_child_cb (self, NULL, self->utility_stack);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
||||
@ -169,11 +169,27 @@
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle">
|
||||
</object>
|
||||
<object class="AdwWindowTitle" id="utility_title"/>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<property name="content">
|
||||
<object class="AdwViewStack" id="utility_stack">
|
||||
<property name="vexpand">true</property>
|
||||
<child>
|
||||
<object class="AdwViewStackPage">
|
||||
<property name="title" translatable="yes">Stack Traces</property>
|
||||
<property name="child">
|
||||
<object class="SysprofTraceablesUtility">
|
||||
<binding name="session">
|
||||
<lookup name="session">SysprofWindow</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<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>
|
||||
<file preprocess="xml-stripblanks">sysprof-traceables-utility.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-window.ui</file>
|
||||
<file preprocess="xml-stripblanks">icons/scalable/actions/address-layout-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks">icons/scalable/actions/mark-chart-symbolic.svg</file>
|
||||
|
||||
Reference in New Issue
Block a user