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 "config.h"
#include <glib/gi18n.h>
#include "sysprof-application.h" #include "sysprof-application.h"
#include "sysprof-recording-pad.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 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 * static char *
format_time (GObject *unused, format_time (GObject *unused,
gint64 duration) 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_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_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_time);
gtk_widget_class_bind_template_callback (widget_class, format_event_count);
} }
static void static void

View File

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