sysprof: show recording duration

This commit is contained in:
Christian Hergert
2023-07-07 17:37:04 -07:00
parent d5a13ccdb4
commit 7847aa1a74
2 changed files with 22 additions and 6 deletions

View File

@ -42,6 +42,17 @@ G_DEFINE_FINAL_TYPE (SysprofRecordingPad, sysprof_recording_pad, ADW_TYPE_WINDOW
static GParamSpec *properties[N_PROPS];
static char *
format_time (GObject *unused,
gint64 duration)
{
double elapsed = duration / (double)G_USEC_PER_SEC;
int minutes = floor (elapsed / 60);
int seconds = floor (elapsed - (minutes * 60));
return g_strdup_printf ("%02u:%02u", minutes, seconds);
}
static gboolean
sysprof_recording_pad_close_request (GtkWindow *window)
{
@ -127,6 +138,7 @@ sysprof_recording_pad_class_init (SysprofRecordingPadClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-recording-pad.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofRecordingPad, stop_button);
gtk_widget_class_bind_template_callback (widget_class, format_time);
}
static void

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofRecordingPad" parent="AdwWindow">
<property name="width-request">300</property>
<property name="height-request">200</property>
<property name="resizable">false</property>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
@ -19,11 +22,13 @@
<property name="orientation">vertical</property>
<child type="center">
<object class="GtkLabel">
<property name="label">00:00</property>
<property name="margin-top">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-bottom">18</property>
<binding name="label">
<closure type="gchararray" function="format_time">
<lookup name="duration" type="SysprofRecording">
<lookup name="recording">SysprofRecordingPad</lookup>
</lookup>
</closure>
</binding>
<attributes>
<attribute name="scale" value="4"/>
<attribute name="font-features" value="'tnum'"/>
@ -37,7 +42,6 @@
<child>
<object class="GtkLabel">
<property name="label">1234 events</property>
<property name="margin-top">12</property>
<property name="margin-bottom">18</property>
<property name="valign">start</property>
<property name="vexpand">true</property>