[sysprof] libsysprof-ui: add stop-recording button
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: add stop-recording button
- Date: Wed, 29 May 2019 22:36:14 +0000 (UTC)
commit 183d079f2ca9e432d9bb62f0b7eb5faec3c07a3c
Author: Christian Hergert <chergert redhat com>
Date: Sun May 19 10:34:30 2019 -0700
libsysprof-ui: add stop-recording button
src/libsysprof-ui/sysprof-display.c | 43 +++++++++++++++++++++-
.../ui/sysprof-recording-state-view.ui | 29 +++++++--------
2 files changed, 56 insertions(+), 16 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index 57ed97b..ca4760e 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -102,12 +102,28 @@ sysprof_display_profiler_stopped_cb (SysprofDisplay *self,
SysprofProfiler *profiler)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+ SysprofCaptureWriter *writer;
g_assert (SYSPROF_IS_DISPLAY (self));
g_assert (SYSPROF_IS_PROFILER (profiler));
- gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->capture_view));
+ if ((writer = sysprof_profiler_get_writer (profiler)))
+ {
+ g_autoptr(SysprofCaptureReader) reader = NULL;
+ g_autoptr(GError) error = NULL;
+
+ if (!(reader = sysprof_capture_writer_create_reader (writer, &error)))
+ {
+ g_warning ("Failed to create capture creader: %s\n", error->message);
+ gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->failed_view));
+ goto notify;
+ }
+
+ sysprof_capture_view_load_async (priv->capture_view, reader, NULL, NULL, NULL);
+ gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->capture_view));
+ }
+notify:
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RECORDING]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
@@ -208,6 +224,21 @@ sysprof_display_get_is_recording (SysprofDisplay *self)
return GTK_WIDGET (priv->recording_view) == gtk_stack_get_visible_child (priv->stack);
}
+static void
+stop_recording_cb (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ SysprofDisplay *self = user_data;
+ SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+
+ g_assert (G_IS_SIMPLE_ACTION (action));
+ g_assert (SYSPROF_IS_DISPLAY (self));
+
+ if (priv->profiler != NULL)
+ sysprof_profiler_stop (priv->profiler);
+}
+
static void
sysprof_display_parent_set (GtkWidget *widget,
GtkWidget *old_parent)
@@ -313,9 +344,19 @@ static void
sysprof_display_init (SysprofDisplay *self)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+ g_autoptr(GSimpleActionGroup) group = g_simple_action_group_new ();
+ static const GActionEntry actions[] = {
+ { "stop-recording", stop_recording_cb },
+ };
gtk_widget_init_template (GTK_WIDGET (self));
+ g_action_map_add_action_entries (G_ACTION_MAP (group),
+ actions,
+ G_N_ELEMENTS (actions),
+ self);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "display", G_ACTION_GROUP (group));
+
g_signal_connect_object (priv->assistant,
"start-recording",
G_CALLBACK (sysprof_display_start_recording_cb),
diff --git a/src/libsysprof-ui/ui/sysprof-recording-state-view.ui
b/src/libsysprof-ui/ui/sysprof-recording-state-view.ui
index 12458d6..e9631c9 100644
--- a/src/libsysprof-ui/ui/sysprof-recording-state-view.ui
+++ b/src/libsysprof-ui/ui/sysprof-recording-state-view.ui
@@ -3,11 +3,13 @@
<template class="SysprofRecordingStateView" parent="GtkBin">
<child>
<object class="GtkBox">
+ <property name="width-request">500</property>
+ <property name="halign">center</property>
<property name="border-width">36</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="visible">true</property>
- <child type="center">
+ <child>
<object class="GtkImage">
<property name="icon-name">org.gnome.Sysprof-symbolic</property>
<property name="pixel-size">256</property>
@@ -27,12 +29,9 @@
<attributes>
<attribute name="scale" value="4"/>
<attribute name="weight" value="bold"/>
+ <attribute name="font-features" value="font-feature-settings: 'tnum'"/>
</attributes>
</object>
- <packing>
- <property name="pack-type">end</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
@@ -43,20 +42,20 @@
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="pack-type">end</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
- <property name="vexpand">true</property>
+ <object class="GtkButton">
+ <property name="action-name">display.stop-recording</property>
+ <property name="margin-top">24</property>
<property name="visible">true</property>
+ <property name="label" translatable="yes">_Stop Recording</property>
+ <property name="halign">end</property>
+ <property name="width-request">125</property>
+ <property name="use-underline">true</property>
+ <style>
+ <class name="destructive-action"/>
+ </style>
</object>
- <packing>
- <property name="position">0</property>
- <property name="pack-type">end</property>
- </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]