sysprof: add event count to recording pad and style like messagedialog

This commit is contained in:
Christian Hergert
2023-07-08 10:29:00 -07:00
parent b56f0ad444
commit 008b9f4cc1
2 changed files with 41 additions and 20 deletions

View File

@ -20,6 +20,8 @@
#include "config.h"
#include <glib/gi18n.h>
#include "sysprof-application.h"
#include "sysprof-recording-pad.h"
@ -42,6 +44,14 @@ G_DEFINE_FINAL_TYPE (SysprofRecordingPad, sysprof_recording_pad, ADW_TYPE_WINDOW
static GParamSpec *properties[N_PROPS];
static char *
format_event_count (GObject *unused,
gint64 event_count)
{
/* translators: this expands to the number of events recorded by the profiler as an indicator of progress */
return g_strdup_printf (_("%"G_GINT64_FORMAT" events"), event_count);
}
static char *
format_time (GObject *unused,
gint64 duration)
@ -139,6 +149,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);
gtk_widget_class_bind_template_callback (widget_class, format_event_count);
}
static void

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofRecordingPad" parent="AdwWindow">
<style>
<class name="messagedialog"/>
</style>
<property name="width-request">300</property>
<property name="height-request">200</property>
<property name="resizable">false</property>
@ -18,9 +21,9 @@
</object>
</child>
<property name="content">
<object class="GtkCenterBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child type="center">
<child>
<object class="GtkLabel">
<binding name="label">
<closure type="gchararray" function="format_time">
@ -35,29 +38,36 @@
</attributes>
</object>
</child>
<child type="end">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<binding name="label">
<closure type="gchararray" function="format_event_count">
<lookup name="event-count" type="SysprofRecording">
<lookup name="recording">SysprofRecordingPad</lookup>
</lookup>
</closure>
</binding>
<property name="margin-bottom">18</property>
<property name="valign">start</property>
<property name="vexpand">true</property>
<child>
<object class="GtkLabel">
<property name="label">1234 events</property>
<property name="margin-bottom">18</property>
<property name="valign">start</property>
<property name="vexpand">true</property>
<style>
<class name="caption"/>
</style>
<attributes>
<attribute name="font-features" value="'tnum'"/>
</attributes>
</object>
</child>
<style>
<class name="caption"/>
</style>
<attributes>
<attribute name="font-features" value="'tnum'"/>
</attributes>
</object>
</child>
<child>
<object class="GtkBox">
<style>
<class name="response-area"/>
</style>
<child>
<object class="GtkButton" id="stop_button">
<property name="hexpand">true</property>
<property name="label" translatable="yes">Stop Recording</property>
<property name="action-name">window.close</property>
<property name="valign">end</property>
<style>
<class name="destructive-action"/>
</style>